当前位置: 首页>>代码示例>>Java>>正文


Java ServletHolder.setAsyncSupported方法代码示例

本文整理汇总了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();
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:19,代码来源:JettyFilterInstrumentationTest.java

示例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;
}
 
开发者ID:danielflower,项目名称:app-runner,代码行数:12,代码来源:WebServer.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:JettyHttpComponent.java

示例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);
}
 
开发者ID:BriData,项目名称:DBus,代码行数:12,代码来源:HttpProxy.java

示例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();
}
 
开发者ID:opentracing-contrib,项目名称:java-web-servlet-filter,代码行数:28,代码来源:AbstractJettyTest.java

示例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;
}
 
开发者ID:danielflower,项目名称:app-runner-router,代码行数:12,代码来源:WebServer.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:15,代码来源:ProxyServer.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:11,代码来源:WebService.java

示例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();
}
 
开发者ID:junicorn,项目名称:NiuBi,代码行数:57,代码来源:ServerTestCase.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:42,代码来源:CometdComponent.java


注:本文中的org.eclipse.jetty.servlet.ServletHolder.setAsyncSupported方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。