本文整理匯總了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;
}