1 18 package org.apache.activemq.broker; 19 20 import org.apache.activemq.broker.BrokerFactoryHandler; 21 import org.apache.activemq.util.IntrospectionSupport; 22 import org.apache.activemq.util.URISupport; 23 import org.apache.activemq.util.URISupport.CompositeData; 24 25 import java.net.URI ; 26 import java.util.HashMap ; 27 import java.util.Map ; 28 29 36 public class DefaultBrokerFactory implements BrokerFactoryHandler { 37 38 public BrokerService createBroker(URI brokerURI) throws Exception { 39 40 CompositeData compositeData = URISupport.parseComposite(brokerURI); 41 Map params = new HashMap (compositeData.getParameters()); 42 43 BrokerService brokerService = new BrokerService(); 44 IntrospectionSupport.setProperties(brokerService, params); 45 if( compositeData.getPath()!=null ) 46 brokerService.setBrokerName(compositeData.getPath()); 47 48 URI [] components = compositeData.getComponents(); 49 for (int i = 0; i < components.length; i++) { 50 if( "network".equals(components[i].getScheme()) ) { 51 brokerService.addNetworkConnector(components[i].getSchemeSpecificPart()); 52 } else if( "proxy".equals(components[i].getScheme()) ) { 53 brokerService.addProxyConnector(components[i].getSchemeSpecificPart()); 54 } else { 55 brokerService.addConnector(components[i]); 56 } 57 } 58 return brokerService; 59 } 60 61 } 62 | Popular Tags |