|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory
public class AnnotProxyFieldValueFactory
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 AnnotSpringInjector
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 beacause proxies for the same dependency will not be serialized twice.
LazyInitProxyFactory
,
SpringBean
,
SpringBeanLocator
Constructor Summary | |
---|---|
AnnotProxyFieldValueFactory(ISpringContextLocator contextLocator)
|
Method Summary | |
---|---|
java.lang.Object |
getFieldValue(java.lang.reflect.Field field,
java.lang.Object fieldOwner)
Returns the value the field will be set to |
void |
setFailFast(boolean failFast)
|
boolean |
supportsField(java.lang.reflect.Field field)
Returns true if the factory can generate a value for the field, false otherwise. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AnnotProxyFieldValueFactory(ISpringContextLocator contextLocator)
contextLocator
- spring context locatorMethod Detail |
---|
public java.lang.Object getFieldValue(java.lang.reflect.Field field, java.lang.Object fieldOwner)
IFieldValueFactory
getFieldValue
in interface IFieldValueFactory
field
- field being injectedfieldOwner
- instance of object being injected
IFieldValueFactory.getFieldValue(java.lang.reflect.Field,
java.lang.Object)
public void setFailFast(boolean failFast)
failFast
- true if the locator fails if a bean can't be locatedpublic boolean supportsField(java.lang.reflect.Field field)
IFieldValueFactory
supportsField
in interface IFieldValueFactory
field
- field
IFieldValueFactory.supportsField(java.lang.reflect.Field)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |