String message = "Error while creating Subscription Manager";
log.error(message, e);
if (e instanceof ClassNotFoundException) {
throw (ClassNotFoundException)e;
}
throw new ActivationException(message, e);
}
Map<String, String> subscriptionManagerParameters = getParameters(
subscriptionManagerElement.getChildrenWithName(new QName(
BROKER_CONFIG_NAMESPACE, LOCAL_NAME_PARAMETER)));
Set<Map.Entry<String, String>> parameters = subscriptionManagerParameters.entrySet();
for(Map.Entry<String, String> e : parameters) {
subscriptionManager.addProperty(e.getKey(), e.getValue());
}
OMElement notificationManagerElement = configElement.getFirstChildWithName(new QName(
BROKER_CONFIG_NAMESPACE, LOCAL_NAME_NOTIFICATION_MANAGER_CONFIG));
String notificationManagerClass = notificationManagerElement.getAttribute(
new QName(ATTR_CLASS)).getAttributeValue();
try {
notificationManager =
(NotificationManager) Class.forName(notificationManagerClass).newInstance();
if (notificationManager instanceof CarbonNotificationManager) {
Map<String, String> notificationManagerParameters = getParameters(
notificationManagerElement.getChildrenWithName(new QName(
BROKER_CONFIG_NAMESPACE, LOCAL_NAME_PARAMETER)));
((CarbonNotificationManager) notificationManager).init(
notificationManagerParameters);
}
} catch(Exception e) {
String message = "Error while creating Notification Manager";
log.error(message, e);
if (e instanceof ClassNotFoundException) {
throw (ClassNotFoundException)e;
}
throw new ActivationException(message, e);
}
/*String eventDispatcherName = configElement.getFirstChildWithName(new QName(
BROKER_CONFIG_NAMESPACE, LOCAL_NAME_EVENT_DISPATCHER_CONFIG)).getText().trim();
try {
eventDispatcher = (EventDispatcher) Class.forName(eventDispatcherName).newInstance();
if (eventDispatcher instanceof CarbonEventDispatcher) {
((CarbonEventDispatcher)eventDispatcher).init(serverConfigurationContext);
}
} catch(Exception e) {
String message = "Error while creating Event Dispatcher";
log.error(message, e);
if (e instanceof ClassNotFoundException) {
throw (ClassNotFoundException)e;
}
throw new ActivationException(message, e);
}*/
}else{
notificationManager = new CarbonNotificationManager();
((CarbonNotificationManager)notificationManager).init(new HashMap<String, String>());
subscriptionManager = new EmbeddedRegistryBasedSubscriptionManager();
}
try {
CarbonEventBroker broker = (CarbonEventBroker)CarbonEventBroker.getInstance();
broker.registerSubscriptionManager(subscriptionManager);
broker.registerNotificationManager(notificationManager);
subscriptionManager.init();
return broker;
} catch(Exception e) {
String message = "Error while initializing Event Source";
log.error(message, e);
throw new ActivationException(message, e);
}
}