public static EventBroker createEventBroker() throws EventBrokerConfigurationException {
OMElement ebConfig = loadConfigXML();
if (!ebConfig.getQName().equals(
new QName(EventBrokerConstants.EB_CONF_NAMESPACE, EventBrokerConstants.EB_CONF_ELE_ROOT))) {
throw new EventBrokerConfigurationException("Invalid root element in event broker config");
}
OMElement eventBroker =
ebConfig.getFirstChildWithName(new QName(EventBrokerConstants.EB_CONF_NAMESPACE,
EventBrokerConstants.EB_CONF_ELE_EVENT_BROKER));
String className =
eventBroker.getAttributeValue(new QName(null, EventBrokerConstants.EB_CONF_ATTR_CLASS));
try {
Class brokerImplClass = Class.forName(className);
EventBrokerFactory eventBrokerFactory =
(EventBrokerFactory) brokerImplClass.newInstance();
return eventBrokerFactory.getEventBroker(eventBroker);
} catch (ClassNotFoundException e) {
throw new EventBrokerConfigurationException("Can not load the class " + className, e);
} catch (IllegalAccessException e) {
throw new EventBrokerConfigurationException("Can not access the class " + className, e);
} catch (InstantiationException e) {
throw new EventBrokerConfigurationException("Can not instantiate the class " + className, e);
}
}