本文整理汇总了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;
}