@Override protected String createEndpointUri() { ObjectHelper.notNull(configuration, "configuration"); return "netty4:" + getConfiguration().getProtocol() + "://" + getConfiguration().getHost() + ":" + getConfiguration().getPort(); }
public static Object getIn(NettyEndpoint endpoint, Exchange exchange) { if (endpoint.getConfiguration().isTransferExchange()) { // we should transfer the entire exchange over the wire (includes in/out) return DefaultExchangeHolder.marshal(exchange, true, endpoint.getConfiguration().isAllowSerializedHeaders()); } else { if (endpoint.getConfiguration().isUseByteBuf()) { // Just leverage the type converter return exchange.getIn().getBody(ByteBuf.class); } else { // normal transfer using the body only return exchange.getIn().getBody(); } } }
public static Object getOut(NettyEndpoint endpoint, Exchange exchange) { if (endpoint.getConfiguration().isTransferExchange()) { // we should transfer the entire exchange over the wire (includes in/out) return DefaultExchangeHolder.marshal(exchange); } else { // normal transfer using the body only return exchange.getOut().getBody(); } }
LOG.trace("Closing channel when complete at address: {}", getEndpoint().getConfiguration().getAddress());
@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<>(); if (IntrospectionSupport.getProperties(bootstrapConfiguration, options, null, false)) { IntrospectionSupport.setProperties(getCamelContext().getTypeConverter(), config, options); } } if (config.getSslContextParameters() == null) { config.setSslContextParameters(retrieveGlobalSslContextParameters()); } // validate config config.validateConfiguration(); NettyEndpoint nettyEndpoint = new NettyEndpoint(remaining, this, config); setProperties(nettyEndpoint.getConfiguration(), parameters); return nettyEndpoint; }
/** * Gets the object we want to use as the response object for sending to netty. * * @param exchange the exchange * @return the object to use as response * @throws Exception is thrown if error getting the response body */ protected Object getResponseBody(Exchange exchange) throws Exception { // if there was an exception then use that as response body boolean exception = exchange.getException() != null && !consumer.getEndpoint().getConfiguration().isTransferExchange(); if (exception) { return exchange.getException(); } if (exchange.hasOut()) { return NettyPayloadHelper.getOut(consumer.getEndpoint(), exchange); } else { return NettyPayloadHelper.getIn(consumer.getEndpoint(), exchange); } }