public static boolean setProperties(Object target, Map<?, ?> props) { return setProperties(target, props, true); }
@Override public void buildFromProperties(Properties properties) { if (properties == null) { properties = new Properties(); } IntrospectionSupport.setProperties(this, properties); }
public FanoutTransport createTransport(Map<String,String> parameters) throws IOException { FanoutTransport transport = new FanoutTransport(); IntrospectionSupport.setProperties(transport, parameters); return transport; }
private PersistenceAdapter kahaDBFromTemplate(PersistenceAdapter template) throws IOException { try { Map<String, Object> configuration = new HashMap<String, Object>(); IntrospectionSupport.getProperties(template, configuration, null); PersistenceAdapter adapter = template.getClass().newInstance(); IntrospectionSupport.setProperties(adapter, configuration); return adapter; } catch (Exception e) { throw IOExceptionSupport.create(e); } }
/** * Overriding to allow for proper configuration through reflection but * delegate to get common configuration */ @Override public Transport compositeConfigure(Transport transport, WireFormat format, Map options) { if (transport instanceof SslTransport) { SslTransport sslTransport = (SslTransport) transport.narrow(SslTransport.class); IntrospectionSupport.setProperties(sslTransport, options); } else if (transport instanceof NIOSSLTransport) { NIOSSLTransport sslTransport = (NIOSSLTransport) transport.narrow(NIOSSLTransport.class); IntrospectionSupport.setProperties(sslTransport, options); } return super.compositeConfigure(transport, format, options); }
/** * Overriding to allow for proper configuration through reflection but delegate to get common * configuration */ @Override @SuppressWarnings("rawtypes") public Transport compositeConfigure(Transport transport, WireFormat format, Map options) { SslTransport sslTransport = transport.narrow(SslTransport.class); IntrospectionSupport.setProperties(sslTransport, options); return super.compositeConfigure(transport, format, options); }
public BrokerService createBroker(URI brokerURI) throws Exception { Map<Object, Object> properties = loadProperties(brokerURI); BrokerService brokerService = createBrokerService(brokerURI, properties); IntrospectionSupport.setProperties(brokerService, properties); return brokerService; }
protected WireFormatFactory createWireFormatFactory(Map<String, String> options) throws IOException { String wireFormat = options.remove("wireFormat"); if (wireFormat == null) { wireFormat = getDefaultWireFormatType(); } try { WireFormatFactory wff = (WireFormatFactory)WIREFORMAT_FACTORY_FINDER.newInstance(wireFormat); IntrospectionSupport.setProperties(wff, options, "wireFormat."); return wff; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create wire format factory for: " + wireFormat + ", reason: " + e, e); } }
protected DiscoveryAgent doCreateDiscoveryAgent(URI uri) throws IOException { try { if (LOG.isTraceEnabled()) { LOG.trace("doCreateDiscoveryAgent: uri = " + uri.toString()); } MulticastDiscoveryAgent mda = new MulticastDiscoveryAgent(); mda.setDiscoveryURI(uri); // allow MDA's params to be set via query arguments // (e.g., multicast://default?group=foo Map options = URISupport.parseParameters(uri); IntrospectionSupport.setProperties(mda, options); return mda; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create discovery agent: " + uri, e); } } }
public void setUri(URI discoveryURI) throws IOException { this.discoveryUri = discoveryURI; setDiscoveryAgent(DiscoveryAgentFactory.createDiscoveryAgent(discoveryURI)); try { parameters = URISupport.parseParameters(discoveryURI); // allow discovery agent to grab it's parameters IntrospectionSupport.setProperties(getDiscoveryAgent(), parameters); } catch (URISyntaxException e) { LOG.warn("failed to parse query parameters from discoveryURI: {}", discoveryURI, e); } }
protected DiscoveryAgent doCreateDiscoveryAgent(URI uri) throws IOException { try { Map options = URISupport.parseParameters(uri); ZeroconfDiscoveryAgent rc = new ZeroconfDiscoveryAgent(); rc.setGroup(uri.getHost()); IntrospectionSupport.setProperties(rc, options); return rc; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create discovery agent: " + uri, e); } } }
@Override public BrokerService createBroker(URI brokerURI) throws Exception { BrokerService service = new BrokerService(); IntrospectionSupport.setProperties(service, brokerOptions); service.setBrokerName(finalBroker); TransportConnector c = service.addConnector("tcp://0.0.0.0:0"); c.setDiscoveryUri(new URI("multicast://default?group=" + finalGroup)); service.addNetworkConnector("multicast://default?group=" + finalGroup); return service; } });
public FailoverTransport createTransport(Map<String, String> parameters) throws IOException { FailoverTransport transport = new FailoverTransport(); Map<String, Object> nestedExtraQueryOptions = IntrospectionSupport.extractProperties(parameters, "nested."); IntrospectionSupport.setProperties(transport, parameters); try { transport.setNestedExtraQueryOptions(URISupport.createQueryString(nestedExtraQueryOptions)); } catch (URISyntaxException e) { } return transport; }
private NetworkBridgeConfiguration getNetworkConfiguration(final BrokerInfo info) throws IOException { Properties properties = MarshallingSupport.stringToProperties(info.getNetworkProperties()); Map<String, String> props = createMap(properties); NetworkBridgeConfiguration config = new NetworkBridgeConfiguration(); IntrospectionSupport.setProperties(config, props, ""); return config; }
/** * @param location * @return a new Transport instance. * @throws Exception */ public Transport createTransport(CompositeData compositData) throws Exception { MockTransport transport = new MockTransport(TransportFactory.compositeConnect(compositData.getComponents()[0])); IntrospectionSupport.setProperties(transport, compositData.getParameters()); return transport; }
@Override public Transport compositeConfigure(Transport transport, WireFormat format, Map options) { IntrospectionSupport.setProperties(transport, options); final UdpTransport udpTransport = (UdpTransport)transport; // deal with fragmentation transport = new CommandJoiner(transport, asOpenWireFormat(format)); if (udpTransport.isTrace()) { try { transport = TransportLoggerSupport.createTransportLogger(transport); } catch (Throwable e) { log.error("Could not create TransportLogger, reason: " + e, e); } } transport = new InactivityMonitor(transport, format); if (format instanceof OpenWireFormat) { transport = configureClientSideNegotiator(transport, format, udpTransport); } return transport; }
/** * Creates a transport that reports discovered brokers to a specific composite transport. * * @param compositeTransport transport to report discovered brokers to * @param compositeData used to apply parameters to this transport * @return a transport that reports discovered brokers to a specific composite transport. * @throws IOException */ public static DiscoveryTransport createTransport(CompositeTransport compositeTransport, CompositeData compositeData, Map<String, String> parameters) throws IOException { DiscoveryTransport transport = new DiscoveryTransport(compositeTransport); IntrospectionSupport.setProperties(transport, parameters); transport.setParameters(parameters); URI discoveryAgentURI = compositeData.getComponents()[0]; DiscoveryAgent discoveryAgent = DiscoveryAgentFactory.createDiscoveryAgent(discoveryAgentURI); transport.setDiscoveryAgent(discoveryAgent); return transport; }
protected DiscoveryAgent doCreateDiscoveryAgent(URI uri) throws IOException { try { CompositeData data = URISupport.parseComposite(uri); Map options = data.getParameters(); SimpleDiscoveryAgent rc = new SimpleDiscoveryAgent(); IntrospectionSupport.setProperties(rc, options); rc.setServices(data.getComponents()); return rc; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create discovery agent: " + uri, e); } } }
@Override protected DiscoveryAgent doCreateDiscoveryAgent(URI uri) throws IOException { try { CompositeData data = URISupport.parseComposite(uri); Map options = data.getParameters(); MasterSlaveDiscoveryAgent rc = new MasterSlaveDiscoveryAgent(); IntrospectionSupport.setProperties(rc, options); rc.setServices(data.getComponents()); return rc; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create discovery agent: " + uri, e); } } }
@Override public TransportServer doBind(final URI location) throws IOException { try { Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location)); ServerSocketFactory serverSocketFactory = createServerSocketFactory(); TcpTransportServer server = createTcpTransportServer(location, serverSocketFactory); server.setWireFormatFactory(createWireFormatFactory(options)); IntrospectionSupport.setProperties(server, options); Map<String, Object> transportOptions = IntrospectionSupport.extractProperties(options, "transport."); server.setTransportOption(transportOptions); server.bind(); return server; } catch (URISyntaxException e) { throw IOExceptionSupport.create(e); } }