}
public BrokerService createBroker(URI config) throws Exception {
String uri = config.getSchemeSpecificPart();
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(uri);
BrokerService broker = null;
try {
broker = (BrokerService) context.getBean("broker");
}
catch (BeansException e) {
}
if (broker == null) {
// lets try find by type
String[] names = context.getBeanNamesForType(BrokerService.class);
for (int i = 0; i < names.length; i++) {
String name = names[i];
broker = (BrokerService) context.getBean(name);
if (broker != null) {
break;
}
}
}