org.apache.click.extras.spring
Class PageScopeResolver
java.lang.Object
org.apache.click.extras.spring.PageScopeResolver
- All Implemented Interfaces:
- ScopeMetadataResolver
public class PageScopeResolver
- extends Object
- implements ScopeMetadataResolver
Provides a Spring bean scope resolver when using Spring
instantiated pages with the @Component annotation.
This scope meta data resolver will resolve "prototype" scope for any Click
Page bean, and "singleton" scope for any other bean.
Example @Component Page
An example Page class is provided below which uses the Spring @Component annotation.
package com.mycorp.page;
import javax.annotation.Resource;
import org.apache.click.Page;
import org.springframework.stereotype.Component;
import comp.mycorp.service.CustomerService;
@Component
public class CustomerEditPage extends Page {
@Resource(name="customerService")
private CustomerService customerService;
..
}
Note in this example page the customerService with the @Resource
annotation is injected by Spring after the page instance has been instantiated.
Example Spring Configuration
An example Spring XML configuration is provided below.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="com.mycorp" scope-resolver="org.apache.click.extras.spring.PageScopeResolver"/>
</beans>
In this example any page class under the base package "com.mycorp" which
includes the @Component annotation will have "prototype" scope.
- See Also:
SpringClickServlet
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PageScopeResolver
public PageScopeResolver()
resolveScopeMetadata
public ScopeMetadata resolveScopeMetadata(BeanDefinition beanDef)
- Return the scope meta data for the given bean definition. This scope meta
data resolver will resolve "prototype" scope for any Click Page bean
and will resolve "singleton" scope for other beans.
- Specified by:
resolveScopeMetadata
in interface ScopeMetadataResolver
- Parameters:
beanDef
- the component bean definition to resolve
- Returns:
- the scope meta data for the given bean definition.
- See Also:
ScopeMetadataResolver.resolveScopeMetadata(BeanDefinition)