public class SpringContextBootstrappingInitializer extends Object implements com.gemstone.gemfire.cache.Declarable, ApplicationListener<ContextRefreshedEvent>
Properties
,
ApplicationContext
,
ApplicationListener
,
ConfigurableApplicationContext
,
AnnotationConfigApplicationContext
,
ApplicationEventMulticaster
,
ContextRefreshedEvent
,
SimpleApplicationEventMulticaster
,
ClassPathXmlApplicationContext
,
Declarable
,
Setting Cache Initializer,
SGF-248Modifier and Type | Field and Description |
---|---|
static String |
BASE_PACKAGES_PARAMETER |
protected static String |
CHARS_TO_DELETE |
protected static String |
COMMA_DELIMITER |
static String |
CONTEXT_CONFIG_LOCATIONS_PARAMETER |
Constructor and Description |
---|
SpringContextBootstrappingInitializer() |
Modifier and Type | Method and Description |
---|---|
protected ConfigurableApplicationContext |
createApplicationContext(String[] configLocations)
Creates (constructs and configures) a ConfigurableApplicationContext instance based on the specified locations
of the context configuration meta-data files.
|
protected ConfigurableApplicationContext |
createApplicationContext(String[] basePackages,
String[] configLocations)
Creates (constructs and configures) an instance of the ConfigurableApplicationContext based on either the
specified base packages containing @Configuration, @Component or JSR 330 annotated classes to scan, or the
specified locations of context configuration meta-data files used to configure the context.
|
static ConfigurableApplicationContext |
getApplicationContext()
Gets a reference to the Spring ApplicationContext constructed, configured and initialized inside the GemFire
Server-based JVM process.
|
void |
init(Properties parameters)
Initializes a Spring ApplicationContext with the given parameters from a GemFire Initializer in GemFire native
configuration meta-data (e.g. cache.xml).
|
protected static void |
notifyListenerOfExistingContextRefreshedEvent(ApplicationListener<ContextRefreshedEvent> listener)
Notifies any Spring ApplicationListeners of a current and existing ContextRefreshedEvent if the
ApplicationContext was previously created, initialized and refreshed before any ApplicationListeners interested
in ContextRefreshedEvents get registered so that application components (such as LazyWiringDeclarableSupport
objects) arriving late to the game that also require configuration (auto-wiring) get wired accordingly too.
|
protected String |
nullSafeGetApplicationContextId(ApplicationContext applicationContext)
Gets the the ID of the Spring ApplicationContext in a null-safe manner.
|
void |
onApplicationEvent(ContextRefreshedEvent event)
Gets notified when the Spring ApplicationContext gets created and refreshed by GemFire.
|
static <T extends ApplicationListener<ContextRefreshedEvent>> |
register(T listener)
Registers a Spring ApplicationListener to be notified when the Spring ApplicationContext is created by GemFire
when instantiating and initializing declared Initializers from the GemFire native configuration file
(e.g. cache.xml).
|
static <T extends ApplicationListener<ContextRefreshedEvent>> |
unregister(T listener)
Unregisters the Spring ApplicationListener from this SpringContextBootstrappingInitializer in order to stop
receiving ApplicationEvents on Spring context refreshes.
|
public static final String BASE_PACKAGES_PARAMETER
public static final String CONTEXT_CONFIG_LOCATIONS_PARAMETER
protected static final String CHARS_TO_DELETE
protected static final String COMMA_DELIMITER
public SpringContextBootstrappingInitializer()
public static ConfigurableApplicationContext getApplicationContext()
ConfigurableApplicationContext
public static <T extends ApplicationListener<ContextRefreshedEvent>> T register(T listener)
T
- the Class type of the Spring ApplicationListener.listener
- the ApplicationListener to register for ContextRefreshedEvents by this
SpringContextBootstrappingInitializer.unregister(org.springframework.context.ApplicationListener)
,
ApplicationListener
,
ContextRefreshedEvent
,
#addApplicationListener(org.springframework.context.ApplicationListener)
protected static void notifyListenerOfExistingContextRefreshedEvent(ApplicationListener<ContextRefreshedEvent> listener)
listener
- a Spring ApplicationListener requiring notification of any ContextRefreshedEvents after the
ApplicationContext has already been created, initialized and/or refreshed.ApplicationListener.onApplicationEvent(org.springframework.context.ApplicationEvent)
,
ContextRefreshedEvent
public static <T extends ApplicationListener<ContextRefreshedEvent>> T unregister(T listener)
T
- the Class type of the Spring ApplicationListener.listener
- the ApplicationListener to unregister from receiving ContextRefreshedEvents by this
SpringContextBootstrappingInitializer.register(org.springframework.context.ApplicationListener)
,
ApplicationListener
,
ContextRefreshedEvent
,
#removeApplicationListener(org.springframework.context.ApplicationListener)
protected ConfigurableApplicationContext createApplicationContext(String[] configLocations)
configLocations
- a String array indicating the locations of the context configuration meta-data files
used to configure the ConfigurableApplicationContext instance.IllegalArgumentException
- if the configLocations parameter argument is null or empty.createApplicationContext(String[], String[])
,
ClassPathXmlApplicationContext
protected ConfigurableApplicationContext createApplicationContext(String[] basePackages, String[] configLocations)
basePackages
- the base application packages to scan for application @Components and @Configuration classes. *configLocations
- a String array indicating the locations of the context configuration meta-data files
used to configure the ConfigurableApplicationContext instance.IllegalArgumentException
- if both the basePackages and configLocation parameter arguments
are null or empty.createApplicationContext(String[])
,
AnnotationConfigApplicationContext
,
AnnotationConfigApplicationContext.scan(String...)
,
ClassPathXmlApplicationContext
public void init(Properties parameters)
init
in interface com.gemstone.gemfire.cache.Declarable
parameters
- a Properties object containing the configuration parameters and settings defined in the
GemFire cache.xml >initializer/< element.createApplicationContext(java.lang.String[])
,
Properties
protected String nullSafeGetApplicationContextId(ApplicationContext applicationContext)
applicationContext
- the Spring ApplicationContext to retrieve the ID for.ApplicationContext.getId()
public void onApplicationEvent(ContextRefreshedEvent event)
onApplicationEvent
in interface ApplicationListener<ContextRefreshedEvent>
event
- the ContextRefreshedEvent signaling that the Spring ApplicationContext has been created
and refreshed by GemFire.ContextRefreshedEvent
,
#multicastEvent(org.springframework.context.ApplicationEvent)