Package org.springframework.aop.target
Class LazyInitTargetSource
java.lang.Object
org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
org.springframework.aop.target.LazyInitTargetSource
- All Implemented Interfaces:
 Serializable,TargetClassAware,TargetSource,Aware,BeanFactoryAware
TargetSource that lazily accesses a
 singleton bean from a BeanFactory.
 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
 ApplicationContext (or BeanFactory) on startup.
 
For example:
 <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 postProcessTargetObject(Object) to
 perform some additional processing with the target object when it is first loaded.
- Since:
 - 1.1.4
 - Author:
 - Juergen Hoeller, Rob Harrop
 - See Also:
 
- 
Field Summary
Fields inherited from class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
logger, targetBeanName - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionReturn a target instance.protected voidpostProcessTargetObject(Object targetObject) Subclasses may override this method to perform additional processing on the target object when it is first loaded.Methods inherited from class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
copyFrom, equals, getBeanFactory, getTargetBeanName, getTargetClass, hashCode, setBeanFactory, setTargetBeanName, setTargetClass, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.aop.TargetSource
isStatic, releaseTarget 
- 
Constructor Details
- 
LazyInitTargetSource
public LazyInitTargetSource() 
 - 
 - 
Method Details
- 
getTarget
Description copied from interface:TargetSourceReturn a target instance. Invoked immediately before the AOP framework calls the "target" of an AOP method invocation.- Returns:
 - the target object which contains the joinpoint,
 or 
nullif there is no actual target instance - Throws:
 BeansException
 - 
postProcessTargetObject
Subclasses may override this method to perform additional processing on the target object when it is first loaded.- Parameters:
 targetObject- the target object that has just been instantiated (and configured)
 
 -