Secondary store notifiers can be dynamically installed and removed. They are installed by creating an instance of a notifier. Any notifier previously installed for the type are removed. See the section called “Chaining notifiers” for details on notifier chaining.
Notifiers are removed by deleting the notifier instance. They are also automatically removed when the JVM in which they were created is stopped. Notifiers must be reinstalled when the JVM is restarted.
Example 10.1. Secondary store notifier life-cycle
// $Revision: 1.1.2.2 $ package com.kabira.snippets.store; import com.kabira.platform.LockMode; import com.kabira.platform.ManagedObject; import com.kabira.platform.Transaction; import com.kabira.platform.annotation.Managed; import com.kabira.store.Extent; /** * Secondary store notifier life-cycle * <p> * <h2> Target Nodes</h2> * <ul> * <li> <b>domainnode</b> = A * </ul> */ public class LifeCycle { @Managed private static class A { }; private static class ExtentNotifier extends Extent<A> { public ExtentNotifier() { super(A.class); } @Override public void extent(Class<? extends A> type, LockMode lockMode) { // do something interesting here } } /** * Main entry point * @param args Not used */ public static void main(final String [ ] args) { // // Install an extent notifier for managed class A // new Transaction("Install") { @Override protected void run() throws Transaction.Rollback { m_notifier = new ExtentNotifier(); } }.execute(); // // Remove the extent notifier for managed class A // new Transaction("Remove") { @Override protected void run() throws Transaction.Rollback { ManagedObject.delete(m_notifier); m_notifier = null; } }.execute(); // // Re-install an extent notifier for managed class A // This notifier will be removed when the JVM is stopped // new Transaction("Re-Install") { @Override protected void run() throws Transaction.Rollback { m_notifier = new ExtentNotifier(); } }.execute(); } private static ExtentNotifier m_notifier; }