* @return
* @throws BrokerConfigException
*/
public static BrokerService createBrokerService() throws BrokerConfigException {
CarbonBrokerService brokerService = new CarbonBrokerService();
OMElement brokerConfig = loadConfigXML();
if (brokerConfig != null) {
if (!brokerConfig.getQName().equals(
new QName(BrokerConstants.BROKER_CONF_NS, BrokerConstants.BROKER_CONF_ELE_ROOT))) {
throw new BrokerConfigException("Broker config exception");
}
Iterator brokerTypesIter = brokerConfig.getChildrenWithName(
new QName(BrokerConstants.BROKER_CONF_NS,
BrokerConstants.BROKER_CONF_ELE_BROKER_TYPE));
for (; brokerTypesIter.hasNext();) {
OMElement brokerTypeOMElement = (OMElement) brokerTypesIter.next();
String className = brokerTypeOMElement.getAttributeValue(
new QName("", BrokerConstants.BROKER_CONF_ATTR_CLASS));
registerBrokerType(brokerService, className);
}
} else {
log.info("No broker types are given");
}
//by default we add the already existing broker types if they are not added
List<String> existingBrokerNames = brokerService.getBrokerTypeNames();
if (!existingBrokerNames.contains(BrokerConstants.BROKER_TYPE_LOCAL)){
registerBrokerType(brokerService, LocalBrokerTypeFactory.class.getName());
}