}
// Implementation methods
// -------------------------------------------------------------------------
protected CamelServlet createServletForConnector(Server server, Connector connector, List<Handler> handlers) throws Exception {
ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);
context.setConnectorNames(new String[] {connector.getName()});
if (handlers != null && !handlers.isEmpty()) {
for (Handler handler : handlers) {
if (handler instanceof HandlerWrapper) {
((HandlerWrapper) handler).setHandler(server.getHandler());
server.setHandler(handler);
} else {
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.addHandler(server.getHandler());
handlerCollection.addHandler(handler);
server.setHandler(handlerCollection);
}
}
}
// use Jetty continuations
CamelServlet camelServlet = new CamelContinuationServlet();
ServletHolder holder = new ServletHolder();
holder.setServlet(camelServlet);
CamelContext camelContext = this.getCamelContext();
FilterHolder filterHolder = new FilterHolder();
filterHolder.setInitParameter("deleteFiles", "true");
if (ObjectHelper.isNotEmpty(camelContext.getProperties().get(TMP_DIR))) {
File file = new File(camelContext.getProperties().get(TMP_DIR));
if (!file.isDirectory()) {
throw new RuntimeCamelException("The temp file directory of camel-jetty is not exists, please recheck it with directory name :"
+ camelContext.getProperties().get(TMP_DIR));
}
context.setAttribute("javax.servlet.context.tempdir", file);
}
filterHolder.setFilter(new MultiPartFilter());
//add the default MultiPartFilter filter for it
context.addFilter(filterHolder, "/*", 0);
context.addServlet(holder, "/*");
return camelServlet;
}