本文整理匯總了Java中org.eclipse.jetty.servlet.ServletHolder.setAsyncSupported方法的典型用法代碼示例。如果您正苦於以下問題:Java ServletHolder.setAsyncSupported方法的具體用法?Java ServletHolder.setAsyncSupported怎麽用?Java ServletHolder.setAsyncSupported使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jetty.servlet.ServletHolder
的用法示例。
在下文中一共展示了ServletHolder.setAsyncSupported方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUp
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
@BeforeClass
public static void setUp() throws Exception {
System.out.println("Jetty [Configuring]");
ServletContextHandler servletContext = new ServletContextHandler();
servletContext.setContextPath("/");
servletContext.addServlet(PingPongServlet.class, PingPongServlet.PATH);
servletContext.addServlet(ExceptionServlet.class, ExceptionServlet.PATH);
ServletHolder servletHolder = servletContext.addServlet(AsyncServlet.class, AsyncServlet.PATH);
servletHolder.setAsyncSupported(true);
jetty = new Server(0);
jetty.setHandler(servletContext);
System.out.println("Jetty [Starting]");
jetty.start();
System.out.println("Jetty [Started]");
serverPort = ((ServerConnector) jetty.getConnectors()[0]).getLocalPort();
}
示例2: createReverseProxy
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
private ServletHandler createReverseProxy(ProxyMap proxyMap) {
AsyncProxyServlet servlet = new ReverseProxy(proxyMap);
ServletHolder proxyServletHolder = new ServletHolder(servlet);
proxyServletHolder.setAsyncSupported(true);
proxyServletHolder.setInitParameter("maxThreads", "256");
proxyServletHolder.setInitParameter("idleTimeout", String.valueOf(idleTimeout));
proxyServletHolder.setInitParameter("timeout", String.valueOf(totalTimeout));
ServletHandler proxyHandler = new ServletHandler();
proxyHandler.addServletWithMapping(proxyServletHolder, "/*");
return proxyHandler;
}
示例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 = 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;
}
示例4: configServer
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
@Override
protected void configServer(Server server, int port) {
ServletHandler handler = new ServletHandler();
ProxyServlet servlet = new SimpleProxyServlet(ConfUtils.proxyConf);
ServletHolder servletHolder = new ServletHolder(servlet);
servletHolder.setAsyncSupported(true);
servletHolder.setInitParameter("maxThreads", "100");
handler.addServletWithMapping(servletHolder, "/*");
server.setHandler(handler);
}
示例5: beforeTest
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
@Before
public void beforeTest() throws Exception {
mockTracer = Mockito.spy(new MockTracer(new ThreadLocalScopeManager(), MockTracer.Propagator.TEXT_MAP));
ServletContextHandler servletContext = new ServletContextHandler();
servletContext.setContextPath(contextPath);
servletContext.addServlet(TestServlet.class, "/hello");
ServletHolder asyncServletHolder = new ServletHolder(new AsyncServlet(mockTracer));
servletContext.addServlet(asyncServletHolder, "/async");
asyncServletHolder.setAsyncSupported(true);
servletContext.addServlet(AsyncImmediateExitServlet.class, "/asyncImmediateExit")
.setAsyncSupported(true);
servletContext.addServlet(new ServletHolder(new LocalSpanServlet(mockTracer)), "/localSpan");
servletContext.addServlet(new ServletHolder(new CurrentSpanServlet(mockTracer)), "/currentSpan");
servletContext.addServlet(ExceptionServlet.class, "/servletException");
servletContext.addFilter(new FilterHolder(tracingFilter()), "/*", EnumSet.of(DispatcherType.REQUEST,
DispatcherType.FORWARD, DispatcherType.ASYNC, DispatcherType.ERROR, DispatcherType.INCLUDE));
servletContext.addFilter(ErrorFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
jettyServer = new Server(0);
jettyServer.setHandler(servletContext);
jettyServer.start();
serverPort = ((ServerConnector)jettyServer.getConnectors()[0]).getLocalPort();
}
示例6: createReverseProxy
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
private ServletHandler createReverseProxy(Cluster cluster, ProxyMap proxyMap, boolean allowUntrustedInstances, AppRequestListener appRequestListener) {
ReverseProxy servlet = new ReverseProxy(cluster, proxyMap, allowUntrustedInstances, appRequestListener);
ServletHolder proxyServletHolder = new ServletHolder(servlet);
proxyServletHolder.setAsyncSupported(true);
proxyServletHolder.setInitParameter("maxThreads", "256");
proxyServletHolder.setInitParameter("idleTimeout", String.valueOf(idleTimeout));
proxyServletHolder.setInitParameter("timeout", String.valueOf(totalTimeout));
ServletHandler proxyHandler = new ServletHandler();
proxyHandler.addServletWithMapping(proxyServletHolder, "/*");
return proxyHandler;
}
示例7: addRestResources
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
public void addRestResources(String basePath, String javaPackages, WebSocketService service) {
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
provider.setMapper(ObjectMapperFactory.create());
ResourceConfig config = new ResourceConfig();
config.packages("jersey.config.server.provider.packages", javaPackages);
config.register(provider);
ServletHolder servletHolder = new ServletHolder(new ServletContainer(config));
servletHolder.setAsyncSupported(true);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath(basePath);
context.addServlet(servletHolder, "/*");
context.setAttribute(ATTRIBUTE_PROXY_SERVICE_NAME, service);
handlers.add(context);
}
示例8: addRestResources
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
public void addRestResources(String basePath, String javaPackages, boolean requiresAuthentication) {
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
provider.setMapper(ObjectMapperFactory.create());
ResourceConfig config = new ResourceConfig();
config.packages("jersey.config.server.provider.packages", javaPackages);
config.register(provider);
ServletHolder servletHolder = new ServletHolder(new ServletContainer(config));
servletHolder.setAsyncSupported(true);
addServlet(basePath, servletHolder, requiresAuthentication);
}
示例9: setUp
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
/**
* Set up server with handler
*
* @param handler
* @return port
* @throws Exception
*/
public static String setUp(final Handler handler) throws Exception {
server = new Server();
if (handler != null)
server.setHandler(handler);
Connector connector = new SelectChannelConnector();
connector.setPort(0);
server.setConnectors(new Connector[] { connector });
server.start();
proxy = new Server();
Connector proxyConnector = new SelectChannelConnector();
proxyConnector.setPort(0);
proxy.setConnectors(new Connector[] { proxyConnector });
ServletHandler proxyHandler = new ServletHandler();
RequestHandler proxyCountingHandler = new RequestHandler() {
@Override
public void handle(Request request, HttpServletResponse response) {
proxyHitCount.incrementAndGet();
String auth = request.getHeader("Proxy-Authorization");
auth = auth.substring(auth.indexOf(' ') + 1);
try {
auth = B64Code.decode(auth, CHARSET_UTF8);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
int colon = auth.indexOf(':');
proxyUser.set(auth.substring(0, colon));
proxyPassword.set(auth.substring(colon + 1));
request.setHandled(false);
}
};
HandlerList handlerList = new HandlerList();
handlerList.addHandler(proxyCountingHandler);
handlerList.addHandler(proxyHandler);
proxy.setHandler(handlerList);
ServletHolder proxyHolder = proxyHandler.addServletWithMapping("org.eclipse.jetty.servlets.ProxyServlet", "/");
proxyHolder.setAsyncSupported(true);
proxy.start();
proxyPort = proxyConnector.getLocalPort();
return "http://localhost:" + connector.getLocalPort();
}
示例10: 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;
}