本文整理汇总了Java中org.eclipse.jetty.servlet.ServletHolder.setServlet方法的典型用法代码示例。如果您正苦于以下问题:Java ServletHolder.setServlet方法的具体用法?Java ServletHolder.setServlet怎么用?Java ServletHolder.setServlet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.servlet.ServletHolder
的用法示例。
在下文中一共展示了ServletHolder.setServlet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createServletForConnector
import org.eclipse.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
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;
}
示例2: addEndpoint
import org.eclipse.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public void addEndpoint(int udID) {
String endpoint = StaticVariables.WS_ENDPOINT + udID;
logger.debug("Endpoint [{}] created for : {}", endpoint, udID);
ServletHolder holder = new ServletHolder();
ChartServiceSocketServlet chartServiceSocketServlet = new ChartServiceSocketServlet(udID);
holder.setServlet(chartServiceSocketServlet);
ctx.addServlet(holder, endpoint);
}
示例3: createServletForConnector
import org.eclipse.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
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;
boolean jetty = endpoint.getUseContinuation() != null ? endpoint.getUseContinuation() : isUseContinuation();
if (jetty) {
// use Jetty continuations
CamelContinuationServlet jettyServlet = new CamelContinuationServlet();
// configure timeout and log it so end user know what we are using
Long timeout = endpoint.getContinuationTimeout() != null ? endpoint.getContinuationTimeout() : getContinuationTimeout();
if (timeout != null) {
LOG.info("Using Jetty continuation timeout: " + timeout + " millis for: " + endpoint);
jettyServlet.setContinuationTimeout(timeout);
} else {
LOG.info("Using default Jetty continuation timeout for: " + endpoint);
}
// use the jetty servlet
camelServlet = jettyServlet;
} else {
// do not use jetty so use a plain servlet
camelServlet = new CamelServlet();
LOG.info("Jetty continuation is disabled for: " + endpoint);
}
ServletHolder holder = new ServletHolder();
holder.setServlet(camelServlet);
context.addServlet(holder, "/*");
// use rest enabled resolver in case we use rest
camelServlet.setServletResolveConsumerStrategy(new JettyRestServletResolveConsumerStrategy());
return camelServlet;
}
示例4: createServletForConnector
import org.eclipse.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
protected CometDServlet createServletForConnector(Server server, Connector connector, CometdEndpoint endpoint) throws Exception {
CometDServlet servlet = new CometDServlet();
ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);
ServletHolder holder = new ServletHolder();
holder.setServlet(servlet);
holder.setAsyncSupported(true);
// Use baseResource to pass as a parameter the url
// pointing to by example classpath:webapp
if (endpoint.getBaseResource() != null) {
String[] resources = endpoint.getBaseResource().split(":");
if (LOG.isDebugEnabled()) {
LOG.debug(">>> Protocol found: " + resources[0] + ", and resource: " + resources[1]);
}
if (resources[0].equals("file")) {
context.setBaseResource(Resource.newResource(resources[1]));
} else if (resources[0].equals("classpath")) {
// Create a URL handler using classpath protocol
URL url = this.getCamelContext().getClassResolver().loadResourceAsURL(resources[1]);
context.setBaseResource(Resource.newResource(url));
}
}
applyCrossOriginFiltering(endpoint, context);
context.addServlet(holder, "/cometd/*");
context.addServlet("org.eclipse.jetty.servlet.DefaultServlet", "/");
context.setSessionHandler(new SessionHandler(new HashSessionManager()));
holder.setInitParameter("timeout", Integer.toString(endpoint.getTimeout()));
holder.setInitParameter("interval", Integer.toString(endpoint.getInterval()));
holder.setInitParameter("maxInterval", Integer.toString(endpoint.getMaxInterval()));
holder.setInitParameter("multiFrameInterval", Integer.toString(endpoint.getMultiFrameInterval()));
holder.setInitParameter("JSONCommented", Boolean.toString(endpoint.isJsonCommented()));
holder.setInitParameter("logLevel", Integer.toString(endpoint.getLogLevel()));
return servlet;
}