int waitForStart = -1; CompositeData data = URISupport.parseComposite(location); if (data.getComponents().length == 1 && "broker".equals(data.getComponents()[0].getScheme())) { brokerURI = data.getComponents()[0]; CompositeData brokerData = URISupport.parseComposite(brokerURI); host = brokerData.getParameters().get("brokerName"); if (host == null) { host = "localhost"; if (brokerData.getPath() != null) { host = brokerData.getPath(); options = data.getParameters(); location = new URI("vm://" + host); } else {
/** * sets the LDAP server URI * * @param uri * LDAP server URI */ public void setUri(URI uri) throws Exception { CompositeData data = URISupport.parseComposite(uri); if (data.getScheme().equals("failover")) { availableURIs = data.getComponents(); failover = true; } else { availableURIs = new URI[] { uri }; } }
/** * Given a composite URI, parse the individual URI elements contained within that URI and return * a CompsoteData instance that contains the parsed URI values. * * @param uri * The target URI that should be parsed. * * @return a new CompsiteData instance representing the parsed composite URI. * @throws URISyntaxException */ public static CompositeData parseComposite(URI uri) throws URISyntaxException { CompositeData rc = new CompositeData(); rc.scheme = uri.getScheme(); String ssp = stripPrefix(uri.getRawSchemeSpecificPart().trim(), "//").trim(); parseComposite(uri, rc, ssp); rc.fragment = uri.getFragment(); return rc; }
final Map<String, String> params = new HashMap<String, String>(compositeData.getParameters()); final PersistenceAdapter persistenceAdapter; if ("true".equals(params.remove("usekahadb"))) { final URI uri = new URI(cleanUpUri(brokerURI.getRawSchemeSpecificPart(), compositeData.getParameters(), params)); broker = "broker".equals(uri.getScheme()) ? newDefaultBroker(uri) : BrokerFactory.createBroker(uri); if (plugins != null) {
final Map<String, String> params = new HashMap<String, String>(compositeData.getParameters()); final PersistenceAdapter persistenceAdapter; if ("true".equals(params.remove("usekahadb"))) { final URI uri = new URI(cleanUpUri(brokerURI.getSchemeSpecificPart(), compositeData.getParameters(), params)); broker = BrokerFactory.createBroker(uri); broker.setUseShutdownHook(false);
int waitForStart = -1; CompositeData data = URISupport.parseComposite(location); if (data.getComponents().length == 1 && "broker".equals(data.getComponents()[0].getScheme())) { brokerURI = data.getComponents()[0]; CompositeData brokerData = URISupport.parseComposite(brokerURI); host = brokerData.getParameters().get("brokerName"); if (host == null) { host = "localhost"; if (brokerData.getPath() != null) { host = brokerData.getPath(); options = data.getParameters(); location = new URI("vm://" + host); } else {
int waitForStart = -1; CompositeData data = URISupport.parseComposite(location); if (data.getComponents().length == 1 && "broker".equals(data.getComponents()[0].getScheme())) { brokerURI = data.getComponents()[0]; CompositeData brokerData = URISupport.parseComposite(brokerURI); host = (String)brokerData.getParameters().get("brokerName"); if (host == null) { host = "localhost"; if (brokerData.getPath() != null) { host = brokerData.getPath(); options = data.getParameters(); location = new URI("vm://" + host); } else {
int waitForStart = -1; CompositeData data = URISupport.parseComposite(location); if (data.getComponents().length == 1 && "broker".equals(data.getComponents()[0].getScheme())) { brokerURI = data.getComponents()[0]; CompositeData brokerData = URISupport.parseComposite(brokerURI); host = brokerData.getParameters().get("brokerName"); if (host == null) { host = "localhost"; if (brokerData.getPath() != null) { host = brokerData.getPath(); options = data.getParameters(); location = new URI("vm://" + host); } else {
int waitForStart = -1; CompositeData data = URISupport.parseComposite(location); if (data.getComponents().length == 1 && "broker".equals(data.getComponents()[0].getScheme())) { brokerURI = data.getComponents()[0]; CompositeData brokerData = URISupport.parseComposite(brokerURI); host = brokerData.getParameters().get("brokerName"); if (host == null) { host = "localhost"; if (brokerData.getPath() != null) { host = brokerData.getPath(); options = data.getParameters(); location = new URI("vm://" + host); } else {
Map<String,Object> jmsOptionsMap = IntrospectionSupport.extractProperties(data.getParameters(), "jms."); if (buildFromMap(jmsOptionsMap)) { if (!jmsOptionsMap.isEmpty()) { this.brokerURL = data.toURI();
Map<String,Object> jmsOptionsMap = IntrospectionSupport.extractProperties(data.getParameters(), "jms."); if (buildFromMap(jmsOptionsMap)) { if (!jmsOptionsMap.isEmpty()) { this.brokerURL = data.toURI();
Map<String,Object> jmsOptionsMap = IntrospectionSupport.extractProperties(data.getParameters(), "jms."); if (buildFromMap(jmsOptionsMap)) { if (!jmsOptionsMap.isEmpty()) { this.brokerURL = data.toURI();
/** * Sets the <a * href="http://activemq.apache.org/configuring-transports.html">connection * URL</a> used to connect to the ActiveMQ broker. */ public void setBrokerURL(String brokerURL) { this.brokerURL = createURI(brokerURL); // Use all the properties prefixed with 'jms.' to set the connection // factory // options. if (this.brokerURL.getQuery() != null) { // It might be a standard URI or... try { Map map = URISupport.parseQuery(this.brokerURL.getQuery()); if (buildFromMap(IntrospectionSupport.extractProperties(map, "jms."))) { this.brokerURL = URISupport.createRemainingURI(this.brokerURL, map); } } catch (URISyntaxException e) { } } else { // It might be a composite URI. try { CompositeData data = URISupport.parseComposite(this.brokerURL); if (buildFromMap(IntrospectionSupport.extractProperties(data.getParameters(), "jms."))) { this.brokerURL = data.toURI(); } } catch (URISyntaxException e) { } } }
public BrokerService createBroker(URI brokerURI) throws Exception { CompositeData compositeData = URISupport.parseComposite(brokerURI); Map<String, String> params = new HashMap<String, String>(compositeData.getParameters()); BrokerService brokerService = new BrokerService(); IntrospectionSupport.setProperties(brokerService, params); if (!params.isEmpty()) { String msg = "There are " + params.size() + " Broker options that couldn't be set on the BrokerService." + " Check the options are spelled correctly." + " Unknown parameters=[" + params + "]." + " This BrokerService cannot be started."; throw new IllegalArgumentException(msg); } if (compositeData.getPath() != null) { brokerService.setBrokerName(compositeData.getPath()); } URI[] components = compositeData.getComponents(); for (int i = 0; i < components.length; i++) { if ("network".equals(components[i].getScheme())) { brokerService.addNetworkConnector(components[i].getSchemeSpecificPart()); } else if ("proxy".equals(components[i].getScheme())) { brokerService.addProxyConnector(components[i].getSchemeSpecificPart()); } else { brokerService.addConnector(components[i]); } } return brokerService; }
public BrokerService createBroker(URI brokerURI) throws Exception { CompositeData compositeData = URISupport.parseComposite(brokerURI); Map<String, String> params = new HashMap<String, String>(compositeData.getParameters()); BrokerService brokerService = new BrokerService(); IntrospectionSupport.setProperties(brokerService, params); if (!params.isEmpty()) { String msg = "There are " + params.size() + " Broker options that couldn't be set on the BrokerService." + " Check the options are spelled correctly." + " Unknown parameters=[" + params + "]." + " This BrokerService cannot be started."; throw new IllegalArgumentException(msg); } if (compositeData.getPath() != null) { brokerService.setBrokerName(compositeData.getPath()); } URI[] components = compositeData.getComponents(); for (int i = 0; i < components.length; i++) { if ("network".equals(components[i].getScheme())) { brokerService.addNetworkConnector(components[i].getSchemeSpecificPart()); } else if ("proxy".equals(components[i].getScheme())) { brokerService.addProxyConnector(components[i].getSchemeSpecificPart()); } else { brokerService.addConnector(components[i]); } } return brokerService; }
/** * Given a URI parse and extract any URI query options and return them as a Key / Value mapping. * * This method differs from the {@link parseQuery} method in that it handles composite URI types and * will extract the URI options from the outermost composite URI. * * @param uri * The URI whose query should be extracted and processed. * * @return A Mapping of the URI options. * @throws URISyntaxException */ public static Map<String, String> parseParameters(URI uri) throws URISyntaxException { if (!isCompositeURI(uri)) { return uri.getQuery() == null ? emptyMap() : parseQuery(stripPrefix(uri.getQuery(), "?")); } else { CompositeData data = URISupport.parseComposite(uri); Map<String, String> parameters = new HashMap<String, String>(); parameters.putAll(data.getParameters()); if (parameters.isEmpty()) { parameters = emptyMap(); } return parameters; } }
/** * Given a URI parse and extract any URI query options and return them as a Key / Value mapping. * * This method differs from the {@link parseQuery} method in that it handles composite URI types and * will extract the URI options from the outermost composite URI. * * @param uri * The URI whose query should be extracted and processed. * * @return A Mapping of the URI options. * @throws URISyntaxException */ public static Map<String, String> parseParameters(URI uri) throws URISyntaxException { if (!isCompositeURI(uri)) { return uri.getQuery() == null ? emptyMap() : parseQuery(stripPrefix(uri.getQuery(), "?")); } else { CompositeData data = URISupport.parseComposite(uri); Map<String, String> parameters = new HashMap<String, String>(); parameters.putAll(data.getParameters()); if (parameters.isEmpty()) { parameters = emptyMap(); } return parameters; } }
@Override public void validate(StartupForm target, List<String> errors, ConfigSource configSource) { if (isNullOrEmpty(target.getQueueUrl())) { if (!configSource.isFile()) { errors.add(String.format(ERROR_REQUIRED, QUEUE_URL)); } return; } try { String value = target.getQueueUrl().replace("localhost", "127.0.0.1"); URI brokerURL = new URI(value); if (isCompositeURI(brokerURL)) { URISupport.CompositeData data = parseComposite(brokerURL); String scheme = data.getScheme(); if (scheme != null && ("failover".equals(scheme) || "fanout".equals(scheme) || "vm".equals(scheme))) { for (URI uri : data.getComponents()) { validateUriContainSpecificScheme(target, errors, uri); } } else { errors.add(String.format(ERROR_INVALID, QUEUE_URL)); } } else { isValidUri(target, errors, value); } } catch (URISyntaxException e) { errors.add(String.format(ERROR_INVALID, QUEUE_URL)); } }
private BrokerService newDefaultBroker(final URI uri) throws Exception { final URISupport.CompositeData compositeData = URISupport.parseComposite(uri); final Map<String, String> params = new HashMap<String, String>(compositeData.getParameters()); final BrokerService brokerService = newPatchedBrokerService(); IntrospectionSupport.setProperties(brokerService, params); if (!params.isEmpty()) { String msg = "There are " + params.size() + " Broker options that couldn't be set on the BrokerService." + " Check the options are spelled correctly." + " Unknown parameters=[" + params + "]." + " This BrokerService cannot be started."; throw new IllegalArgumentException(msg); } if (compositeData.getPath() != null) { brokerService.setBrokerName(compositeData.getPath()); } for (final URI component : compositeData.getComponents()) { if ("network".equals(component.getScheme())) { brokerService.addNetworkConnector(component.getSchemeSpecificPart()); } else if ("proxy".equals(component.getScheme())) { brokerService.addProxyConnector(component.getSchemeSpecificPart()); } else { brokerService.addConnector(component); } } return brokerService; }
public BrokerService createBroker(URI brokerURI) throws Exception { CompositeData compositeData = URISupport.parseComposite(brokerURI); Map<String, String> params = new HashMap<String, String>(compositeData.getParameters()); BrokerService brokerService = new BrokerService(); IntrospectionSupport.setProperties(brokerService, params); if (!params.isEmpty()) { String msg = "There are " + params.size() + " Broker options that couldn't be set on the BrokerService." + " Check the options are spelled correctly." + " Unknown parameters=[" + params + "]." + " This BrokerService cannot be started."; throw new IllegalArgumentException(msg); } if (compositeData.getPath() != null) { brokerService.setBrokerName(compositeData.getPath()); } URI[] components = compositeData.getComponents(); for (int i = 0; i < components.length; i++) { if ("network".equals(components[i].getScheme())) { brokerService.addNetworkConnector(components[i].getSchemeSpecificPart()); } else if ("proxy".equals(components[i].getScheme())) { brokerService.addProxyConnector(components[i].getSchemeSpecificPart()); } else { brokerService.addConnector(components[i]); } } return brokerService; }