Java Code Examples for org.eclipse.jetty.servlet.ServletHolder#setAsyncSupported()
The following examples show how to use
org.eclipse.jetty.servlet.ServletHolder#setAsyncSupported() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JettyHttpServer.java From spring-analysis-note with MIT License | 6 votes |
@Override protected void initServer() throws Exception { this.jettyServer = new Server(); ServletHttpHandlerAdapter servlet = createServletAdapter(); ServletHolder servletHolder = new ServletHolder(servlet); servletHolder.setAsyncSupported(true); this.contextHandler = new ServletContextHandler(this.jettyServer, "", false, false); this.contextHandler.addServlet(servletHolder, "/"); this.contextHandler.start(); ServerConnector connector = new ServerConnector(this.jettyServer); connector.setHost(getHost()); connector.setPort(getPort()); this.jettyServer.addConnector(connector); }
Example 2
Source File: JettyHttpServer.java From java-technology-stack with MIT License | 6 votes |
@Override protected void initServer() throws Exception { this.jettyServer = new Server(); ServletHttpHandlerAdapter servlet = createServletAdapter(); ServletHolder servletHolder = new ServletHolder(servlet); servletHolder.setAsyncSupported(true); this.contextHandler = new ServletContextHandler(this.jettyServer, "", false, false); this.contextHandler.addServlet(servletHolder, "/"); this.contextHandler.start(); ServerConnector connector = new ServerConnector(this.jettyServer); connector.setHost(getHost()); connector.setPort(getPort()); this.jettyServer.addConnector(connector); }
Example 3
Source File: Bootstrap.java From qmq with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { DynamicConfig config = DynamicConfigLoader.load("broker.properties"); ServerWrapper wrapper = new ServerWrapper(config); Runtime.getRuntime().addShutdownHook(new Thread(wrapper::destroy)); wrapper.start(true); if (wrapper.isSlave()) { final ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath("/"); context.setResourceBase(System.getProperty("java.io.tmpdir")); final QueryMessageServlet servlet = new QueryMessageServlet(config, wrapper.getStorage()); ServletHolder servletHolder = new ServletHolder(servlet); servletHolder.setAsyncSupported(true); context.addServlet(servletHolder, "/api/broker/message"); final int port = config.getInt("slave.server.http.port", 8080); final Server server = new Server(port); server.setHandler(context); server.start(); server.join(); } }
Example 4
Source File: ClientJettyStreamAsyncITest.java From hawkular-apm with Apache License 2.0 | 6 votes |
@BeforeClass public static void initClass() { server = new Server(8180); ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); ServletHolder asyncHolder = context.addServlet(EmbeddedAsyncServlet.class, "/hello"); asyncHolder.setAsyncSupported(true); server.setHandler(context); try { server.start(); //server.join(); } catch (Exception e) { fail("Failed to start server: " + e); } }
Example 5
Source File: ITSpanCustomizingAsyncHandlerInterceptor.java From brave with Apache License 2.0 | 6 votes |
@Override public void init(ServletContextHandler handler) { AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext() { // overriding this allows us to register dependencies of TracingHandlerInterceptor // without passing static state to a configuration class. @Override protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) { beanFactory.registerSingleton("httpTracing", httpTracing); super.loadBeanDefinitions(beanFactory); } }; appContext.register(Servlet3TestController.class); // the test resource appContext.register(TracingConfig.class); // generic tracing setup DispatcherServlet servlet = new DispatcherServlet(appContext); servlet.setDispatchOptionsRequest(true); ServletHolder servletHolder = new ServletHolder(servlet); servletHolder.setAsyncSupported(true); handler.addServlet(servletHolder, "/*"); handler.addEventListener(new ContextLoaderListener(appContext)); // add the trace filter, which lazy initializes a real tracing filter from the spring context Dynamic filterRegistration = handler.getServletContext().addFilter("tracingFilter", DelegatingTracingFilter.class); filterRegistration.setAsyncSupported(true); filterRegistration.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); }
Example 6
Source File: AbstractJettyTest.java From java-web-servlet-filter with Apache License 2.0 | 5 votes |
@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); ServletHolder timeoutServletHolder = new ServletHolder(new AsyncTimeoutServlet()); timeoutServletHolder.setAsyncSupported(true); servletContext.addServlet(timeoutServletHolder, "/asyncTimeout"); 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)); initServletContext(servletContext); jettyServer = new Server(0); jettyServer.setHandler(servletContext); jettyServer.start(); serverPort = ((ServerConnector)jettyServer.getConnectors()[0]).getLocalPort(); }
Example 7
Source File: ManagementApiServer.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
public void attachHandlers() { // Create the servlet context final ServletContextHandler context = new ServletContextHandler(this.server, entrypoint, ServletContextHandler.SESSIONS); // REST configuration final ServletHolder servletHolder = new ServletHolder(ServletContainer.class); servletHolder.setInitParameter("javax.ws.rs.Application", ManagementApplication.class.getName()); servletHolder.setInitOrder(1); servletHolder.setAsyncSupported(true); AnnotationConfigWebApplicationContext webApplicationContext = new AnnotationConfigWebApplicationContext(); webApplicationContext.setEnvironment((ConfigurableEnvironment) applicationContext.getEnvironment()); webApplicationContext.setParent(applicationContext); webApplicationContext.setServletContext(context.getServletContext()); webApplicationContext.register(ManagementConfiguration.class); context.addEventListener(new ContextLoaderListener(webApplicationContext)); context.addServlet(servletHolder, "/*"); context.addServlet(new ServletHolder(new DispatcherServlet(webApplicationContext)), "/auth/*"); // X-Forwarded-* support context.addFilter(ForwardedHeaderFilter.class, "/*", EnumSet.allOf(DispatcherType.class)); // Spring Security filter context.addFilter(new FilterHolder(new DelegatingFilterProxy("springSecurityFilterChain")), "/*", EnumSet.allOf(DispatcherType.class)); }
Example 8
Source File: ServerCmdlet.java From HongsCORE with MIT License | 5 votes |
private void addServlet(ServletContextHandler context, Class clso, WebServlet anno) { ServletHolder hd = new ServletHolder(clso ); hd.setName (anno./****/name( )); hd.setAsyncSupported(anno.asyncSupported()); for(WebInitParam nv : anno.initParams ()) { hd.setInitParameter(nv.name( ), nv.value()); } for(String ur : anno.urlPatterns()) { context.addServlet(hd, ur/**/); } }
Example 9
Source File: ProxyServer.java From pulsar with Apache License 2.0 | 5 votes |
public void addRestResources(String basePath, String javaPackages, String attribute, Object attributeValue) { ResourceConfig config = new ResourceConfig(); config.packages("jersey.config.server.provider.packages", javaPackages); config.register(JsonMapperProvider.class); 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, attributeValue); handlers.add(context); }
Example 10
Source File: WebService.java From pulsar with Apache License 2.0 | 5 votes |
public void addRestResources(String basePath, String javaPackages, boolean requiresAuthentication, Map<String,Object> attributeMap) { ResourceConfig config = new ResourceConfig(); config.packages("jersey.config.server.provider.packages", javaPackages); config.register(JsonMapperProvider.class); config.register(MultiPartFeature.class); ServletHolder servletHolder = new ServletHolder(new ServletContainer(config)); servletHolder.setAsyncSupported(true); addServlet(basePath, servletHolder, requiresAuthentication, attributeMap); }
Example 11
Source File: WebServer.java From pulsar with Apache License 2.0 | 5 votes |
public void addRestResources(String basePath, String javaPackages, String attribute, Object attributeValue) { ResourceConfig config = new ResourceConfig(); config.packages("jersey.config.server.provider.packages", javaPackages); config.register(JsonMapperProvider.class); 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, attributeValue); handlers.add(context); }
Example 12
Source File: JavaxServletAsyncServerITest.java From hawkular-apm with Apache License 2.0 | 5 votes |
@BeforeClass public static void initClass() throws Exception { server = new Server(8180); ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); ServletHolder asyncHolder = context.addServlet(EmbeddedAsyncServlet.class, "/hello"); asyncHolder.setAsyncSupported(true); server.setHandler(context); server.start(); }
Example 13
Source File: Starter.java From jumbune with GNU Lesser General Public License v3.0 | 5 votes |
public void start() { Server server = new Server(9080); ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); servletContextHandler.setContextPath("/"); servletContextHandler.setResourceBase("src/main/webapp"); final String webAppDirectory = JumbuneInfo.getHome() + "modules/webapp"; final ResourceHandler resHandler = new ResourceHandler(); resHandler.setResourceBase(webAppDirectory); final ContextHandler ctx = new ContextHandler("/"); ctx.setHandler(resHandler); servletContextHandler.setSessionHandler(new SessionHandler()); ServletHolder servletHolder = servletContextHandler.addServlet(ServletContainer.class, "/apis/*"); servletHolder.setInitOrder(0); servletHolder.setAsyncSupported(true); servletHolder.setInitParameter("jersey.config.server.provider.packages", "org.jumbune.web.services"); servletHolder.setInitParameter("jersey.config.server.provider.classnames", "org.glassfish.jersey.media.multipart.MultiPartFeature"); try { server.insertHandler(servletContextHandler); server.insertHandler(resHandler); server.start(); server.join(); } catch (Exception e) { LOGGER.error("Error occurred while starting Jetty", e); System.exit(1); } }
Example 14
Source File: JettyServer.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public final void run() throws Exception { final org.eclipse.jetty.server.Server s = new org.eclipse.jetty.server.Server(new QueuedThreadPool(200, Runtime.getRuntime().availableProcessors())); final ServerConnector http = new ServerConnector(s); http.setReuseAddress(true); http.setAcceptQueueSize(100000); http.setPort(8080); s.addConnector(http); final ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); final ServletHolder holder1 = new ServletHolder(new PlaintextServlet()); context.addServlet(holder1, "/plaintext"); holder1.setAsyncSupported(true); final ServletHolder holder2 = new ServletHolder(new JsonServlet()); context.addServlet(holder2, "/json"); holder2.setAsyncSupported(true); s.setHandler(context); s.start(); System.err.println("Server is up."); AbstractEmbeddedServer.waitUrlAvailable("http://localhost:8080/plaintext"); AbstractEmbeddedServer.waitUrlAvailable("http://localhost:8080/json"); System.err.println("Server test cases are instrumented and bootstrapped."); s.join(); }
Example 15
Source File: ITTracingApplicationEventListener.java From brave with Apache License 2.0 | 5 votes |
@Override public void init(ServletContextHandler handler) { ResourceConfig config = new ResourceConfig(); config.register(new TestResource(httpTracing)); config.register(TracingApplicationEventListener.create(httpTracing)); ServletHolder servlet = new ServletHolder(new ServletContainer(config)); servlet.setAsyncSupported(true); handler.addServlet(servlet, "/*"); }
Example 16
Source File: Bootstrap.java From qmq with Apache License 2.0 | 4 votes |
private static void addServlet(final ServletContextHandler context, Servlet servlet, String pathSpec) { ServletHolder deadMessageServletHolder = new ServletHolder(servlet); deadMessageServletHolder.setAsyncSupported(true); context.addServlet(deadMessageServletHolder, pathSpec); }