public ConnectionFactoryConfiguration createDefaultFactory(String name, ConnectionFactoryType type) { ConnectionFactoryConfiguration configuration = new ConnectionFactoryConfiguration(name, "activemq"); configuration.addAttribute("broker.uri", defaultBrokerName); configuration.setType(type); return configuration; } }
private Map<String, String> getProperties(ConnectionFactoryConfiguration configuration) { Properties properties = configuration.getFactoryProperties(); Map<String, String> factoryProperties = new HashMap<>(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { factoryProperties.put(entry.getKey().toString(), entry.getValue().toString()); } return factoryProperties; } }
private void parseFactoryProperties(ConnectionFactoryConfiguration configuration, XMLStreamReader reader) throws XMLStreamException { while (true) { switch (reader.next()) { case XMLStreamConstants.START_ELEMENT: configuration.setFactoryProperty(reader.getName().getLocalPart(), reader.getElementText()); break; case XMLStreamConstants.END_ELEMENT: if ("factory.properties".equals(reader.getName().getLocalPart())) { return; } break; case XMLStreamConstants.END_DOCUMENT: return; } } }
context.addError(error); ConnectionFactoryConfiguration configuration = new ConnectionFactoryConfiguration(name, "activemq"); configuration.setClientId(clientId); configuration.setUsername(username); String password = reader.getAttributeValue(null, "password"); configuration.setPassword(password); configuration.setType(type); configuration.addAttribute("broker.uri", uri); } catch (URISyntaxException e) { InvalidValue error = new InvalidValue("Invalid broker URL", location, e);
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; } }
private ConnectionFactoryResourceBuilder(String name) { definition = new ConnectionFactoryResource(new ConnectionFactoryConfiguration(name)); }
/** * Sets the client id. The runtime name can be used via the <code>{runtime}</code> parameter. * * @param clientId the client id * @return the builder */ public ConnectionFactoryResourceBuilder clientId(String clientId) { checkState(); definition.getConfiguration().setClientId(clientId); return this; }
public ConnectionFactoryResourceBuilder username(String username) { checkState(); definition.getConfiguration().setUsername(username); return this; }
public ConnectionFactoryResourceBuilder password(String password) { checkState(); definition.getConfiguration().setPassword(password); return this; }
public ConnectionFactoryResourceBuilder attribute(String key, Object value) { checkState(); definition.getConfiguration().addAttribute(key, value); return this; }
public ConnectionFactoryResourceBuilder type(ConnectionFactoryType type) { checkState(); definition.getConfiguration().setType(type); return this; }
private URI getUri(ConnectionFactoryConfiguration configuration) { URI attribute = configuration.getAttribute(URI.class, "broker.uri"); if (attribute != null) { return attribute; } return brokerUri; }
private Map<String, String> getProperties(ConnectionFactoryConfiguration configuration) { Properties properties = configuration.getFactoryProperties(); Map<String, String> factoryProperties = new HashMap<>(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { factoryProperties.put(entry.getKey().toString(), entry.getValue().toString()); } return factoryProperties; }
public ConnectionFactoryResourceBuilder property(String key, String value) { checkState(); definition.getConfiguration().setFactoryProperty(key, value); return this; }