Package org.coliper.ibean.proxy.handler
Class LazyInitHandler
- java.lang.Object
-
- org.coliper.ibean.proxy.handler.StatefulExtensionHandler
-
- org.coliper.ibean.proxy.handler.LazyInitHandler
-
- All Implemented Interfaces:
ExtensionHandler
public class LazyInitHandler extends StatefulExtensionHandler
ExtensionHandlerimplementation for bean extension interfacesLazyInit,LazyInitParentandLazyInitChild.
-
-
Field Summary
Fields Modifier and Type Field Description static ExtensionSupportSUPPORTExtensionSupportrelated to this handler supposed to be used when configuring extension handlers inIBeanFactorys, for example inProxyIBeanFactory.Builder.withInterfaceSupport(ExtensionSupport).
-
Constructor Summary
Constructors Constructor Description LazyInitHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectinterceptGetterCall(IBeanContext<?> context, IBeanFieldMetaInfo fieldMeta, Object returnValue, Object proxyInstance)Called as an optional hook with every getter call on an IBean.voidonInitStateful(Object proxyInstance, IBeanTypeMetaInfo<?> metaInfo, IBeanFactory factory)Initialization method for stateful handlers that is called after initialization of the IBean.-
Methods inherited from class org.coliper.ibean.proxy.handler.StatefulExtensionHandler
handleExtendedInterfaceCall
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.coliper.ibean.proxy.ExtensionHandler
interceptSetterCall
-
-
-
-
Field Detail
-
SUPPORT
public static final ExtensionSupport SUPPORT
ExtensionSupportrelated to this handler supposed to be used when configuring extension handlers inIBeanFactorys, for example inProxyIBeanFactory.Builder.withInterfaceSupport(ExtensionSupport).
-
-
Method Detail
-
onInitStateful
public void onInitStateful(Object proxyInstance, IBeanTypeMetaInfo<?> metaInfo, IBeanFactory factory)
Description copied from interface:ExtensionHandlerInitialization method for stateful handlers that is called after initialization of the IBean. If a handler is registered as stateful a new instance of theExtensionHandlerimplementation is created for each new IBean. After the IBean itself and all handlers created this method is called on all stateful handlers. This method should therefore be overwritten if a handler needs some initialization after creation.The default implementation does nothing.
- Parameters:
proxyInstance- the IBean instancemetaInfo- meta information about the IBeanfactory- the factory that creates the IBean instance
-
interceptGetterCall
public Object interceptGetterCall(IBeanContext<?> context, IBeanFieldMetaInfo fieldMeta, Object returnValue, Object proxyInstance)
Description copied from interface:ExtensionHandlerCalled as an optional hook with every getter call on an IBean. Getter calls on IBeans are handled by the IBean implementation itself but anExtensionHandlercan implement this method to hook into the getter call. It can just peak on the return value or it can even change it or throw an exception.When you have several extension handlers registered for an IBean type the intercept calls will be called in the order in which the handlers are registered in the
ProxyIBeanFactory. See alsoProxyIBeanFactory.Builder.withInterfaceSupport(ExtensionSupport).The default implementation just returns
returnValue.- Parameters:
context- provides meta information about the IBeanfieldMeta- provides meta information about the field related to the getterreturnValue- the current return value of the getter. This must not match to the field value of the IBean as the value might have already been changed by intercept calls from other handlersproxyInstance- the IBean instance itself- Returns:
- the value to be returned from the getter call. If you do not want
to change the getter return value just pass the value provided in
returnValue
-
-