I use something like this:
[code] /**
* Subscribe application conf events.
*
* @param appDBID the app dbid
*/
public synchronized void subscribeApplicationConfEvents(int appDBID) {
unSubscribeNotifications();
// Create notification query:
NotificationQuery notificationQuery = new NotificationQuery();
notificationQuery.setObjectType(CfgObjectType.CFGApplication);
notificationQuery.setObjectDbid(appDBID);
NotificationFilter notificationFilter = new NotificationFilter(notificationQuery);
Predicate<ConfEvent> mFilter = notificationFilter;
log.info("Subscribing for Application ConfigServer Events for Application DBID: " + appDBID);
Subscriber<ConfEvent> subscriber = new ConfigSubscriber(mFilter);
confService.register(subscriber);
log.info("Subscribed for Application ConfigServer Events for Application DBID: " + appDBID);
try {
Subscription mySubscription = confService.subscribe(notificationQuery);
subscriptions.put("App", mySubscription);
} catch (Exception e) {
log.error("Error Subscribing for Application Update Events", e);
}
}
/**
* The Class ConfigSubscriber.
*/
public class ConfigSubscriber implements Subscriber<ConfEvent> {
/** The log. */
private static Logger log = Logger.getLogger(ConfigSubscriber.class);
/**
* Instantiates a new config subscriber.
*
* @param mFilter
* the m filter
*/
public ConfigSubscriber(Predicate<ConfEvent> mFilter) {
this.mFilter = mFilter;
}
/** The m filter. */
private Predicate<ConfEvent> mFilter;
/*
* (non-Javadoc)
*
* @see
* com.genesyslab.platform.applicationblocks.commons.broker.Subscriber#getFilter
* ()
*/
public Predicate<ConfEvent> getFilter() {
return mFilter;
}
/**
* Gets the m filter.
*
* @return the m filter
*/
public Predicate<ConfEvent> getMFilter() {
return mFilter;
}
/*
* (non-Javadoc)
*
* @see
* com.genesyslab.platform.applicationblocks.commons.Action#handle(java.
* lang.Object)
*/
public void handle(ConfEvent event) {
try {
log.warn("Config Update Event " + event.toString());
if (event.getObjectType() == CfgObjectType.CFGApplication) {
ParseConfigApplicationEvent parse = new ParseConfigApplicationEvent(event);
} else if (event.getObjectType() == CfgObjectType.CFGCampaign) {
//ParseConfigCampaignEvent parse = new ParseConfigCampaignEvent(event);
} else if (event.getObjectType() == CfgObjectType.CFGPerson) {
//ParseConfigPersonEvent parse = new ParseConfigPersonEvent(event);
} else if (event.getObjectType() == CfgObjectType.CFGDN) {
//ParseConfigDNEvent parse = new ParseConfigDNEvent(event);
} else if(event.getObjectType()== CfgObjectType.CFGCallingList){
//ParseCallingListEvent parse = new ParseCallingListEvent(event);
}else if(event.getObjectType()== CfgObjectType.CFGAgentGroup){
//ParseAgentGroupEvent parse = new ParseAgentGroupEvent(event);
}
else if(event.getObjectType()== CfgObjectType.CFGAgentLogin){
//ParseAgentLoginEvent parse = new ParseAgentLoginEvent(event);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
/**
* Sets the m filter.
*
* @param filter
* the new m filter
*/
public void setMFilter(Predicate<ConfEvent> filter) {
mFilter = filter;
}
}[/code]