use of org.apache.camel.http.common.HttpRestServletResolveConsumerStrategy in project camel by apache.
the class JettyHttpComponent method createServletForConnector.
protected CamelServlet createServletForConnector(Server server, Connector connector, List<Handler> handlers, JettyHttpEndpoint endpoint) throws Exception {
ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);
if (Server.getVersion().startsWith("8")) {
context.getClass().getMethod("setConnectorNames", new Class[] { String[].class }).invoke(context, new Object[] { new String[] { connector.getName() } });
}
addJettyHandlers(server, handlers);
CamelServlet camelServlet = new CamelContinuationServlet();
ServletHolder holder = new ServletHolder();
holder.setServlet(camelServlet);
holder.setAsyncSupported(true);
holder.setInitParameter(CamelServlet.ASYNC_PARAM, Boolean.toString(endpoint.isAsync()));
context.addServlet(holder, "/*");
// use rest enabled resolver in case we use rest
camelServlet.setServletResolveConsumerStrategy(new HttpRestServletResolveConsumerStrategy());
return camelServlet;
}
use of org.apache.camel.http.common.HttpRestServletResolveConsumerStrategy in project camel by apache.
the class CamelHttpTransportServlet method init.
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
// use rest enabled resolver in case we use rest
this.setServletResolveConsumerStrategy(new HttpRestServletResolveConsumerStrategy());
String ignore = config.getInitParameter("ignoreDuplicateServletName");
Boolean bool = ObjectConverter.toBoolean(ignore);
if (bool != null) {
ignoreDuplicateServletName = bool;
} else {
// always log so people can see it easier
String msg = "Invalid parameter value for init-parameter ignoreDuplicateServletName with value: " + ignore;
LOG.error(msg);
throw new ServletException(msg);
}
String name = config.getServletName();
String contextPath = config.getServletContext().getContextPath();
if (httpRegistry == null) {
httpRegistry = DefaultHttpRegistry.getHttpRegistry(name);
CamelServlet existing = httpRegistry.getCamelServlet(name);
if (existing != null) {
String msg = "Duplicate ServletName detected: " + name + ". Existing: " + existing + " This: " + this.toString() + ". Its advised to use unique ServletName per Camel application.";
// always log so people can see it easier
if (isIgnoreDuplicateServletName()) {
LOG.warn(msg);
} else {
LOG.error(msg);
throw new ServletException(msg);
}
}
httpRegistry.register(this);
}
LOG.info("Initialized CamelHttpTransportServlet[name={}, contextPath={}]", getServletName(), contextPath);
}
Aggregations