Class AnnotProxyFieldValueFactory
java.lang.Object
org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory
- All Implemented Interfaces:
org.apache.wicket.injection.IFieldValueFactory
public class AnnotProxyFieldValueFactory
extends Object
implements org.apache.wicket.injection.IFieldValueFactory
IFieldValueFactory
that uses LazyInitProxyFactory
to create proxies for Spring
dependencies based on the SpringBean
annotation applied to a field. This class is usually
used by the SpringComponentInjector
to inject objects with lazy init proxies. However,
this class can be used on its own to create proxies for any field decorated with a
SpringBean
annotation.
Example:
IFieldValueFactory factory = new AnnotProxyFieldValueFactory(contextLocator); field = obj.getClass().getDeclaredField("dependency"); IDependency dependency = (IDependency)factory.getFieldValue(field, obj);In the example above the
dependency
object returned is a lazy init proxy that will look up the actual
IDependency bean from spring context upon first access to one of the methods.
This class will also cache any produced proxies so that the same proxy is always returned for the same spring dependency. This helps cut down on session size because proxies for the same dependency will not be serialized twice.
- Author:
- Igor Vaynberg (ivaynberg), Istvan Devai, Tobias Soloschenko
- See Also:
-
LazyInitProxyFactory
SpringBean
SpringBeanLocator
Inject
-
Constructor Summary
ConstructorsConstructorDescriptionAnnotProxyFieldValueFactory
(ISpringContextLocator contextLocator) AnnotProxyFieldValueFactory
(ISpringContextLocator contextLocator, boolean wrapInProxies) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.beans.factory.config.BeanDefinition
getBeanDefinition
(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, String name) getFieldValue
(Field field, Object fieldOwner) boolean
supportsField
(Field field)
-
Constructor Details
-
AnnotProxyFieldValueFactory
- Parameters:
contextLocator
- spring context locator
-
AnnotProxyFieldValueFactory
- Parameters:
contextLocator
- spring context locatorwrapInProxies
- whether or not wicket should wrap dependencies with specialized proxies that can be safely serialized. in most cases this should be set to true.
-
-
Method Details
-
getFieldValue
- Specified by:
getFieldValue
in interfaceorg.apache.wicket.injection.IFieldValueFactory
-
getBeanDefinition
public org.springframework.beans.factory.config.BeanDefinition getBeanDefinition(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, String name) -
supportsField
- Specified by:
supportsField
in interfaceorg.apache.wicket.injection.IFieldValueFactory
-