Hippo Repository uses JMS for sending update notification events, the Update Notifier component can be configured to listen to these events
Interface UpdateNotificationService is the main interface of the update notification component.
For Maven: groupId=hippo, artifactId=hippo-repository-update-notifier, version=[see download page]
Create a UpdateNotificationConfig object. Either by supplying a java.util.Properties object or an InputStream on a properties file. Here is an example properties file that should work for an 'out of the box' instance of Hippo Repository:
# Hippo Repository Update Notifier configuration file. # These setting should match the settings in [repository-install-dir]/config/openjms.xml # # JNDI parameters for lookiing up the JMS connection java.naming.factory.initial = org.exolab.jms.jndi.InitialContextFactory java.naming.provider.url = tcp://localhost:3035 # Name of the JMS topic connection factory hippo.client.jms.factory = TCPTopicConnectionFactory # Name of the JMS topic hippo.client.jms.topic = repository # JMS username/password, only mandatory if securityEnabled has been set to true. hippo.client.jms.username = admin hippo.client.jms.password = openjms # This setting determines the time interval the update notifier will wait between reconnect attempts # if the JMS connection has been lost. hippo.client.jms.reconnect.delay = 1000 # Optional prefix that appears in log messages hippo.client.loglabel =
UpdateNotificationConfig config = new UpdateNotificationConfig(new FileInputStream("updatenotifier.properties");
The update notifier is implemented as a daemon thread that listens to JMS events in an endless loop and must be explicitely started after creation:
UpdateNotificationService updateNotifier = new UpdateNotificationServiceImpl(config); updateNotifier.start();
Implementations of interface EventAware like...
public class MyRepositoryListener implements EventAware {
public void processEvent(NamedEvent e) {
System.out.println("A repository change event occurred: " + e.toString());
}
}
...can register themselves to be notified for repository changes in a specific repository namespace. Here our class is registered on the default namespace:
EventAwareManager eventManager = updateNotifier.getEventAwareManager(); eventManager.addListener(new MyRepositoryListener(), "default");
The cachemanager can be seen as an example of this, it uses the update notifier for keeping the cache clean of stale entries (content which has been updated using the CMS).