Class ModificationAwareHandler

    • Constructor Detail

      • ModificationAwareHandler

        public ModificationAwareHandler()
    • Method Detail

      • onInitStateful

        public void onInitStateful​(Object proxyInstance,
                                   IBeanTypeMetaInfo<?> metaInfo,
                                   IBeanFactory unused)
        Description copied from interface: ExtensionHandler
        Initialization method for stateful handlers that is called after initialization of the IBean. If a handler is registered as stateful a new instance of the ExtensionHandler 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.

        Specified by:
        onInitStateful in interface ExtensionHandler
        Parameters:
        proxyInstance - the IBean instance
        metaInfo - meta information about the IBean
        unused - the factory that creates the IBean instance
      • interceptSetterCall

        public Object interceptSetterCall​(IBeanContext<?> context,
                                          IBeanFieldMetaInfo fieldMeta,
                                          Object newValue,
                                          Object proxyInstance)
        Description copied from interface: ExtensionHandler
        Called as an optional hook with every setter call on an IBean. Setter calls on IBeans are handled by the IBean implementation itself but an ExtensionHandler 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.

        Specified by:
        interceptSetterCall in interface ExtensionHandler
        Parameters:
        context - provides meta information about the IBean
        fieldMeta - provides meta information about the field related to the setter
        newValue - 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 handlers
        proxyInstance - the IBean instance itself
        Returns:
        the value the field is supposed to be set to. If you do not want to change the value just pass the value provided in newValue
      • getModifiedFieldNames

        public String[] getModifiedFieldNames()
        Description copied from interface: ModificationAwareExt
        Gives the names of all bean fields that have been modified since creation or respectively since the last call of ModificationAware.resetModified().
        Specified by:
        getModifiedFieldNames in interface ModificationAwareExt
        Returns:
        a string array containing the names of the modified fields. If no fields have been modified an empty array will be returned. The names of the fields are deducible from the getter and setter names depending on the bean style.
        The order of field names returned is random and not be reliable!