@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { NettyConfiguration config; if (configuration != null) { config = configuration.copy(); } else { config = new NettyConfiguration(); } config = parseConfiguration(config, remaining, parameters); // merge any custom bootstrap configuration on the config NettyServerBootstrapConfiguration bootstrapConfiguration = resolveAndRemoveReferenceParameter( parameters, "bootstrapConfiguration", NettyServerBootstrapConfiguration.class); if (bootstrapConfiguration != null) { Map<String, Object> options = new HashMap<String, Object>(); if (IntrospectionSupport.getProperties(bootstrapConfiguration, options, null, false)) { IntrospectionSupport.setProperties(getCamelContext().getTypeConverter(), config, options); } } // validate config config.validateConfiguration(); NettyEndpoint nettyEndpoint = new NettyEndpoint(remaining, this, config); nettyEndpoint.setTimer(getTimer()); setProperties(nettyEndpoint.getConfiguration(), parameters); return nettyEndpoint; }
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { NettyConfiguration config; if (configuration != null) { config = configuration.copy(); } else { config = new NettyConfiguration(); } config.parseURI(new URI(remaining), parameters, this); NettyEndpoint nettyEndpoint = new NettyEndpoint(remaining, this, config); nettyEndpoint.setTimer(getTimer()); setProperties(nettyEndpoint.getConfiguration(), parameters); return nettyEndpoint; }
@Test public void testNettyComponentWithConfiguration() throws Exception { NettyComponent comp = context.getComponent("netty", NettyComponent.class); NettyConfiguration cfg = new NettyConfiguration(); comp.setConfiguration(cfg); assertSame(cfg, comp.getConfiguration()); NettyEndpoint e1 = (NettyEndpoint) comp.createEndpoint("netty://tcp://localhost:4455"); NettyEndpoint e2 = (NettyEndpoint) comp.createEndpoint("netty://tcp://localhost:5566?sync=false&needClientAuth=true"); // should not be same assertNotSame(e1, e2); assertNotSame(e1.getConfiguration(), e2.getConfiguration()); assertEquals(0, e2.getConfiguration().getReceiveBufferSizePredictor()); e2.getConfiguration().setReceiveBufferSizePredictor(1024); assertEquals(1024, e2.getConfiguration().getReceiveBufferSizePredictor()); e2.getConfiguration().setPort(5566); assertEquals(true, e1.getConfiguration().isSync()); assertEquals(false, e1.getConfiguration().isNeedClientAuth()); assertEquals(false, e2.getConfiguration().isSync()); assertEquals(true, e2.getConfiguration().isNeedClientAuth()); assertEquals(4455, e1.getConfiguration().getPort()); assertEquals(5566, e2.getConfiguration().getPort()); }