net.sf.navel.beans
Interface ConstructionDelegate

All Known Implementing Classes:
DefaultConstructor

public interface ConstructionDelegate

Instances of this interface may be registered for types of interest and whenever those types are included in the total set for a new Navel bean, any matching delegate instances will be called before and after construction.

Author:
thomas

Method Summary
 java.util.Collection<java.lang.Class<?>> additionalTypes(int nestingDepth, java.lang.Class<?> thisType, java.lang.Class<?> primaryType, java.lang.Class<?>[] allTypes, java.util.Map<java.lang.String,java.lang.Object> initialValues)
          Give callers a chance to hook into the ProxyFactory for purposes of conditionally augmenting the interfaces any given dynamic proxy will implement based on information made available declaratively through the create call.
 void initBehaviors(int nestingDepth, java.lang.Class<?> thisType, java.lang.Object bean)
          This code will get invoked any any new Navel been that implements the type for which this instance is registered immediately after the Proxy is created but before the reference is returned out of ProxyFactory making this suitable to do custom "construction" work.
 void initValues(int nestingDepth, java.lang.Class<?> thisType, java.lang.Object bean)
          This code will get invoked any any new Navel bean that implements the type for which this instance is registered immediately after the Proxy is created but before the reference is returned out of ProxyFactory making this suitable to do custom "construction" work.
 

Method Detail

additionalTypes

java.util.Collection<java.lang.Class<?>> additionalTypes(int nestingDepth,
                                                         java.lang.Class<?> thisType,
                                                         java.lang.Class<?> primaryType,
                                                         java.lang.Class<?>[] allTypes,
                                                         java.util.Map<java.lang.String,java.lang.Object> initialValues)
Give callers a chance to hook into the ProxyFactory for purposes of conditionally augmenting the interfaces any given dynamic proxy will implement based on information made available declaratively through the create call. Any kind of copy on ProxyFactory, including those that produce unmodifiable beans, will bypass this method on construction as the contract of copy is to preserve exactly the typing of the source.

Parameters:
nestingDepth - For directly or indirectly recursive relationships between types, this argument lets the delegate consider nesting depth as part of its criteria as to whether it should do anything special.
primaryType - The primary type for the Proxy about to be created, may or may not match the thisType argument.
thisType - This is the type that triggered the call into the delegate, specifically.
allTypes - All of the original types requested, in case the code that initially invoked create already included an interface of interest.
initialValues - May be empty, will never be null; allows type augmentation based on the initial values for a new JavaBeanHandler. The value based in will be immutable as this method is not meant to alter the state of the bean under construction.
Returns:
Any additional interfaces that the Proxy should implement or null if no additional interfaces should be added. Any duplicates from other ConstructionDelegate instances invoked before Proxy creation will be eliminated.

initValues

void initValues(int nestingDepth,
                java.lang.Class<?> thisType,
                java.lang.Object bean)
This code will get invoked any any new Navel bean that implements the type for which this instance is registered immediately after the Proxy is created but before the reference is returned out of ProxyFactory making this suitable to do custom "construction" work. The implementer should take care of both direct value initialization on the bean argument and attachment of any stock PropertyDelegate instances, as these are both germane to the initial observable state of the object under construction. This code will not get invoked during a copy of any kind, this includes ProxyFactory.unmodifiableObject(Object) and ProxyFactory.unmodifiableObjectAs(Class, Object). Copy operations will perform a shallow copy of the source's already attached PropertyDelegate instances, so copies will carry forward synthetic properties consistent with their sources and should prevent any issues with copy bypassing the call into this method.

Parameters:
nestingDepth - For directly or indirectly recursive relationships between types, this argument lets the delegate consider nesting depth as part of its criteria as to whether it should do anything special.
thisType - This is the type that triggered the call into the delegate, specifically. Navel will guarantee that it is safe to cast the bean argument to this type.
bean - Dynamic Proxy that was just created, provided so that its state may be initialized as desired.

initBehaviors

void initBehaviors(int nestingDepth,
                   java.lang.Class<?> thisType,
                   java.lang.Object bean)
This code will get invoked any any new Navel been that implements the type for which this instance is registered immediately after the Proxy is created but before the reference is returned out of ProxyFactory making this suitable to do custom "construction" work. The implementer should take care of both direct value initialization on the bean argument and attachment of any stock PropertyDelegate instances, as these are both germane to the initial observable state of the object under construction. This code will get invoked during a copy of all kinds, this includes ProxyFactory.unmodifiableObject(Object) and ProxyFactory.unmodifiableObjectAs(Class, Object).

Parameters:
nestingDepth - For directly or indirectly recursive relationships between types, this argument lets the delegate consider nesting depth as part of its criteria as to whether it should do anything special.
thisType - This is the type that triggered the call into the delegate, specifically. Navel will guarantee that it is safe to cast the bean argument to this type.
bean - Dynamic Proxy that was just created, provided so that its state may be initialized as desired.