public ConnectionFactory create(ConnectionFactoryConfiguration configuration) throws Fabric3Exception { ConnectionFactoryType type = configuration.getType(); String clientId = configuration.getClientId(); switch (type) { case XA: ActiveMQXAConnectionFactory xaFactory = new ActiveMQXAConnectionFactory(getUri(configuration)); xaFactory.setProperties(configuration.getFactoryProperties()); xaFactory.setUserName(configuration.getUsername()); xaFactory.setPassword(configuration.getPassword()); if (clientId != null) { // since a client id is specified (possibly for a durable subscription), create a singleton connection so the connection id is unique setClientId(clientId, xaFactory); return new XaSingletonConnectionFactory(xaFactory, monitor); } return xaFactory; default: // default to local pooled ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(getUri(configuration)); factory.setProperties(configuration.getFactoryProperties()); factory.setUserName(configuration.getUsername()); factory.setPassword(configuration.getPassword()); if (clientId != null) { // since a client id is specified (possibly for a durable subscription), create a singleton connection so the connection id is unique setClientId(clientId, factory); return new SingletonConnectionFactory(factory, monitor); } return factory; } }