Launching an Application after Initializing the Cache
Launching an Application after Initializing the Cache
You can specify a callback application that is launched after the cache initialization.
By specifying an <initializer> element in your cache.xml file, you can trigger a callback application, which is run after the cache has been initialized. Applications that use the cacheserver script to start up a server can also use this feature to hook into a callback application. To use this feature, you need to specify the callback class within the <initializer> element. This element should be added to the end of your cache.xml file.
You can specify the <initializer> element for either server caches or client caches.
The callback class must implement the Declarable interface. When the callback class is loaded, its init method is called, and any parameters defined in the <initializer> element are passed as properties.
The following is an example specification.
<initializer> <class-name>MyInitializer</class-name> <parameter name="members"> <string>2</string> </parameter> </initializer>
import com.gemstone.gemfire.cache.Declarable; public class MyInitializer implements Declarable { public void init(Properties properties) { System.out.println(properties.getProperty("members")); } }
- Start a SystemMembershipListener
<initializer> <class-name>TestSystemMembershipListener</class-name> </initializer>
- Write a custom tool that monitors cache
resources
<initializer> <class-name>ResourceMonitorCacheXmlLoader</class-name> </initializer>
Any singleton or timer task or thread can be instantiated and started using the initializer element.