public class FreezableHandler extends StatefulExtensionHandler implements TempFreezable<Object>
| Modifier and Type | Field and Description |
|---|---|
static ExtensionSupport |
SUPPORT
ExtensionSupport related to this handler supposed to be used when
configuring extension handlers in IBeanFactorys, for example in
ProxyIBeanFactory.Builder#withInterfaceSupport(ExtensionSupport). |
| Constructor and Description |
|---|
FreezableHandler() |
| Modifier and Type | Method and Description |
|---|---|
Object |
freeze()
Set the bean to immutable and prevents all further setter calls.
|
Object |
interceptSetterCall(IBeanContext<?> context,
IBeanFieldMetaInfo fieldMeta,
Object newValue,
Object proxyInstance)
Called as an optional hook with every setter call on an IBean.
|
boolean |
isFrozen() |
void |
onInitStateful(Object proxyInstance,
IBeanTypeMetaInfo<?> metaInfo,
IBeanFactory unused)
Initialization method for stateful handlers that is called after
initialization of the IBean.
|
Object |
unfreeze() |
handleExtendedInterfaceCallclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinterceptGetterCallpublic static final ExtensionSupport SUPPORT
ExtensionSupport related to this handler supposed to be used when
configuring extension handlers in IBeanFactorys, for example in
ProxyIBeanFactory.Builder#withInterfaceSupport(ExtensionSupport).public void onInitStateful(Object proxyInstance, IBeanTypeMetaInfo<?> metaInfo, IBeanFactory unused)
ExtensionHandlerExtensionHandler implementation 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.
onInitStateful in interface ExtensionHandlerproxyInstance - the IBean instancemetaInfo - meta information about the IBeanunused - the factory that creates the IBean instancepublic Object interceptSetterCall(IBeanContext<?> context, IBeanFieldMetaInfo fieldMeta, Object newValue, Object proxyInstance)
ExtensionHandlerExtensionHandler can implement this method to hook into the
setter call. It can just peak on the new 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 also
ProxyIBeanFactory.Builder.withInterfaceSupport(ExtensionSupport).
The default implementation just returns newValue.
interceptSetterCall in interface ExtensionHandlercontext - provides meta information about the IBeanfieldMeta - provides meta information about the field related to the
setternewValue - the current new value of the field. This must not match to the
initial value given in the setter call of the IBean as the
value might have already been changed by intercept calls from
other handlersproxyInstance - the IBean instance itselfnewValuepublic Object freeze()
Freezablefreeze in interface Freezable<Object>ModernBeanStylepublic boolean isFrozen()
isFrozen in interface Freezable<Object>true if the bean was switched to immutable with a
previous Freezable.freeze() callpublic Object unfreeze()
unfreeze in interface TempFreezable<Object>