org.springframework.data.gemfire.serialization
Class WiringInstantiator

java.lang.Object
  extended by com.gemstone.gemfire.Instantiator
      extended by org.springframework.data.gemfire.serialization.WiringInstantiator
All Implemented Interfaces:
Aware, BeanFactoryAware, DisposableBean, InitializingBean

public class WiringInstantiator
extends com.gemstone.gemfire.Instantiator
implements BeanFactoryAware, InitializingBean, DisposableBean

Instantiator that performs instance wiring using the Spring IoC container, allowing common properties to be injected before the object is hydrated/deserialized. The newly created instances can be configured either by relying on an existing bean definition (which acts as a template) or by providing an embedded configuration through annotations.

Can reuse existing instantiators to optimize instance creation. If one is not provided, it will fallback to reflection invocation.

By default, on initialization, the class will register itself as an Instantiator through Instantiator.register(Instantiator). This behaviour can be disabled through setAutoRegister(boolean). Additionally, the instantiator registration is not distributed by default, to allow the application context to be reused. This can be changed through setDistribute(boolean).

See Also:
BeanConfigurerSupport, BeanWiringInfoResolver, Autowired, Resource, Inject

Constructor Summary
WiringInstantiator(Class<? extends com.gemstone.gemfire.DataSerializable> c, int classId)
           
WiringInstantiator(com.gemstone.gemfire.Instantiator instantiator)
           
 
Method Summary
 void afterPropertiesSet()
           
 void destroy()
           
 com.gemstone.gemfire.DataSerializable newInstance()
           
 void setAutoRegister(boolean autoRegister)
          Sets the auto-registration of this Instantiator during the container startup.
 void setBeanFactory(BeanFactory beanFactory)
           
 void setConfigurer(BeanConfigurerSupport configurer)
          Sets the manager responsible for configuring the newly created instances.
 void setDistribute(boolean distribute)
          Sets the distribution of the region of this Instantiator during the container startup.
 
Methods inherited from class com.gemstone.gemfire.Instantiator
getContext, getEventId, getId, getInstantiatedClass, register, register, setContext, setEventId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WiringInstantiator

public WiringInstantiator(com.gemstone.gemfire.Instantiator instantiator)

WiringInstantiator

public WiringInstantiator(Class<? extends com.gemstone.gemfire.DataSerializable> c,
                          int classId)
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface InitializingBean

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface DisposableBean
Throws:
Exception

setBeanFactory

public void setBeanFactory(BeanFactory beanFactory)
                    throws BeansException
Specified by:
setBeanFactory in interface BeanFactoryAware
Throws:
BeansException

newInstance

public com.gemstone.gemfire.DataSerializable newInstance()
Specified by:
newInstance in class com.gemstone.gemfire.Instantiator

setConfigurer

public void setConfigurer(BeanConfigurerSupport configurer)
Sets the manager responsible for configuring the newly created instances. The given configurer needs to be configured and initialized before-hand.

Parameters:
configurer - the configurer to set

setAutoRegister

public void setAutoRegister(boolean autoRegister)
Sets the auto-registration of this Instantiator during the container startup. Default is true, meaning the registration will occur once this factory is initialized.

Parameters:
autoRegister - the autoRegister to set
See Also:
Instantiator.register(Instantiator)

setDistribute

public void setDistribute(boolean distribute)
Sets the distribution of the region of this Instantiator during the container startup. Default is false, meaning the registration will not be distributed to other clients.

Parameters:
distribute - whether the registration is distributable or not
See Also:
Instantiator.register(Instantiator, boolean)