host = "localhost";
}
VMTransportServer server = SERVERS.get(host);
// validate the broker is still active
if (!validateBroker(host) || server == null) {
BrokerService broker = null;
// Synchronize on the registry so that multiple concurrent threads
// doing this do not think that the broker has not been created and
// cause multiple
// brokers to be started.
synchronized (BrokerRegistry.getInstance().getRegistryMutext()) {
broker = BrokerRegistry.getInstance().lookup(host);
if (broker == null) {
if (!create) {
throw new IOException("Broker named '" + host + "' does not exist.");
}
try {
if (brokerFactoryHandler != null) {
broker = brokerFactoryHandler.createBroker(brokerURI);
} else {
broker = BrokerFactory.createBroker(brokerURI);
}
broker.start();
} catch (URISyntaxException e) {
throw IOExceptionSupport.create(e);
}
BROKERS.put(host, broker);
}
server = SERVERS.get(host);
if (server == null) {
server = (VMTransportServer)bind(location, true);
TransportConnector connector = new TransportConnector(broker.getBroker(), server);
connector.setUri(location);
connector.setTaskRunnerFactory(broker.getTaskRunnerFactory());
connector.start();
CONNECTORS.put(host, connector);
}
}