public class LazyInitTargetSource extends AbstractBeanFactoryBasedTargetSource
TargetSourcethat lazily accesses a singleton bean from a
Useful when a proxy reference is needed on initialization but
the actual target object should not be initialized until first use.
When the target bean is defined in an
ApplicationContext (or a
BeanFactory that is eagerly pre-instantiating singleton beans)
it must be marked as "lazy-init" too, else it will be instantiated by said
BeanFactory) on startup.
<bean id="serviceTarget" class="example.MyService" lazy-init="true"> ... </bean> <bean id="service" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="targetSource"> <bean class="org.springframework.aop.target.LazyInitTargetSource"> <property name="targetBeanName"><idref local="serviceTarget"/></property> </bean> </property> </bean>The "serviceTarget" bean will not get initialized until a method on the "service" proxy gets invoked.
Subclasses can extend this class and override the
perform some additional processing with the target object when it is first loaded.
|Constructor and Description|
|Modifier and Type||Method and Description|
Return a target instance.
Subclasses may override this method to perform additional processing on the target object when it is first loaded.
copyFrom, equals, getBeanFactory, getTargetBeanName, getTargetClass, hashCode, isStatic, releaseTarget, setBeanFactory, setTargetBeanName, setTargetClass, toString
public Object getTarget() throws BeansException
nullif there is no actual target instance
protected void postProcessTargetObject(Object targetObject)
targetObject- the target object that has just been instantiated (and configured)