org.springframework.data.gemfire
Class LazyWiringDeclarableSupport

java.lang.Object
  extended by org.springframework.data.gemfire.LazyWiringDeclarableSupport
All Implemented Interfaces:
com.gemstone.gemfire.cache.Declarable, EventListener, DisposableBean, ApplicationListener<ContextRefreshedEvent>

public abstract class LazyWiringDeclarableSupport
extends Object
implements ApplicationListener<ContextRefreshedEvent>, com.gemstone.gemfire.cache.Declarable, DisposableBean

The LazyWiringDeclarableSupport class is an implementation of the GemFire Declarable interface that enables support for wiring GemFire components with Spring bean dependencies defined in the Spring context.

Since:
1.3.4
See Also:
Properties, DisposableBean, ApplicationListener, ContextRefreshedEvent, DeclarableSupport, WiringDeclarableSupport, Declarable

Field Summary
protected static String BEAN_NAME_PARAMETER
           
protected  boolean initialized
           
 
Constructor Summary
LazyWiringDeclarableSupport()
          Constructs an instance of the LazyWiringDeclarableSupport class registered with the SpringContextBootstrappingInitializer to receive notification when the Spring context is created and initialized (refreshed) by GemFire in order for this Declarable component to be configured and properly initialized with any required Spring bean dependencies.
 
Method Summary
protected  void assertInitialized()
          Asserts that this Declarable object has been properly configured and initialized by the Spring container after GemFire has constructed this Declarable object during startup.
 void destroy()
          When this bean gets destroyed by the Spring container, make sure this component gets unregistered from the SpringContextBootstrappingInitializer.
protected  void doPostInit(Properties parameters)
          Default no operation method performed post initialization of this Declarable GemFire component to be overridden by subclasses for application specific extension and behavior.
 void init(Properties parameters)
          Initialization method called by GemFire with the configured parameters once this Declarable object has been constructed during GemFire startup using an <initalizer> element in GemFire's configuration meta-data.
protected  boolean isInitialized()
          Determines whether this Declarable object has been configured and initialized (i.e. the doInit method has been called) by the Spring container.
 void onApplicationEvent(ContextRefreshedEvent event)
          Event handler method called when GemFire has created and initialized (refreshed) the Spring ApplicationContext using the SpringContextBootstrappingInitializer Declarable class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEAN_NAME_PARAMETER

protected static final String BEAN_NAME_PARAMETER
See Also:
Constant Field Values

initialized

protected volatile boolean initialized
Constructor Detail

LazyWiringDeclarableSupport

public LazyWiringDeclarableSupport()
Constructs an instance of the LazyWiringDeclarableSupport class registered with the SpringContextBootstrappingInitializer to receive notification when the Spring context is created and initialized (refreshed) by GemFire in order for this Declarable component to be configured and properly initialized with any required Spring bean dependencies.

See Also:
#register(org.springframework.context.ApplicationListener)
Method Detail

assertInitialized

protected void assertInitialized()
Asserts that this Declarable object has been properly configured and initialized by the Spring container after GemFire has constructed this Declarable object during startup. It is recommended that this method be called in any GemFire CacheCallback/Declarable object operational method (e.g. CacheLoader.load(..)) before use in order to ensure that this Declarable was properly constructed, configured and initialized.

Throws:
IllegalStateException - if the Declarable object has not been properly configured or initialized by the Spring container.
See Also:
init(java.util.Properties), isInitialized()

doPostInit

protected void doPostInit(Properties parameters)
Default no operation method performed post initialization of this Declarable GemFire component to be overridden by subclasses for application specific extension and behavior.

Parameters:
parameters - Properties instance containing the parameters from GemFire's configuration file (e.g. cache.xml) to configure and initialize this Declarable object.
See Also:
doInit(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.util.Properties)

init

public final void init(Properties parameters)
Initialization method called by GemFire with the configured parameters once this Declarable object has been constructed during GemFire startup using an <initalizer> element in GemFire's configuration meta-data.

Specified by:
init in interface com.gemstone.gemfire.cache.Declarable
Parameters:
parameters - the configured parameters passed from the GemFire configuration (e.g. cache.xml) to this Declarable as a Properties instance.
Throws:
IllegalStateException - if the Declarable object's init method has already been invoked.
See Also:
doInit(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.util.Properties), Properties

isInitialized

protected boolean isInitialized()
Determines whether this Declarable object has been configured and initialized (i.e. the doInit method has been called) by the Spring container.

Returns:
a boolean value indicating whether this Declarable object has been configured and initialized by the Spring container.
See Also:
assertInitialized(), doInit(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.util.Properties)

onApplicationEvent

public final void onApplicationEvent(ContextRefreshedEvent event)
Event handler method called when GemFire has created and initialized (refreshed) the Spring ApplicationContext using the SpringContextBootstrappingInitializer Declarable class.

Specified by:
onApplicationEvent in interface ApplicationListener<ContextRefreshedEvent>
Parameters:
event - the ContextRefreshedEvent published by the Spring ApplicationContext after it is successfully created and initialized by GemFire.
Throws:
IllegalStateException - if the parameters have not been passed to this Declarable (i.e. GemFire has not called this Declarable object's init method yet, which is probably a bug and violates the lifecycle contract of Declarable GemFire objects).
IllegalArgumentException - if the ApplicationContext is not an instance of ConfigurableApplicationContext.
See Also:
doInit(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.util.Properties), ApplicationListener.onApplicationEvent(org.springframework.context.ApplicationEvent), ContextRefreshedEvent

destroy

public void destroy()
             throws Exception
When this bean gets destroyed by the Spring container, make sure this component gets unregistered from the SpringContextBootstrappingInitializer.

Specified by:
destroy in interface DisposableBean
Throws:
Exception - if bean destruction is unsuccessful.
See Also:
SpringContextBootstrappingInitializer.unregister( org.springframework.context.ApplicationListener)