Java Code Examples for org.eclipse.jetty.servlet.ServletHolder#setForcedPath()
The following examples show how to use
org.eclipse.jetty.servlet.ServletHolder#setForcedPath() .
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: ZeppelinServer.java From zeppelin with Apache License 2.0 | 6 votes |
private static void setupRestApiContextHandler(WebAppContext webapp, ZeppelinConfiguration conf) { final ServletHolder servletHolder = new ServletHolder(new org.glassfish.jersey.servlet.ServletContainer()); servletHolder.setInitParameter("javax.ws.rs.Application", ZeppelinServer.class.getName()); servletHolder.setName("rest"); servletHolder.setForcedPath("rest"); webapp.setSessionHandler(new SessionHandler()); webapp.addServlet(servletHolder, "/api/*"); String shiroIniPath = conf.getShiroPath(); if (!StringUtils.isBlank(shiroIniPath)) { webapp.setInitParameter("shiroConfigLocations", new File(shiroIniPath).toURI().toString()); webapp .addFilter(ShiroFilter.class, "/api/*", EnumSet.allOf(DispatcherType.class)) .setInitParameter("staticSecurityManagerEnabled", "true"); webapp.addEventListener(new EnvironmentLoaderListener()); } }
Example 2
Source File: SubmarineServer.java From submarine with Apache License 2.0 | 5 votes |
private static void setupRestApiContextHandler(WebAppContext webapp, SubmarineConfiguration conf) { final ServletHolder servletHolder = new ServletHolder(new org.glassfish.jersey.servlet.ServletContainer()); servletHolder.setInitParameter("javax.ws.rs.Application", SubmarineServer.class.getName()); servletHolder.setName("rest"); servletHolder.setForcedPath("rest"); webapp.setSessionHandler(new SessionHandler()); webapp.addServlet(servletHolder, "/api/*"); }
Example 3
Source File: VarOneServer.java From varOne with MIT License | 5 votes |
private static ServletContextHandler setupResourcesContextHandler( VarOneConfiguration conf) { final ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet()); cxfServletHolder.setInitParameter("javax.ws.rs.Application", VarOneServer.class.getName()); cxfServletHolder.setName("rest"); cxfServletHolder.setForcedPath("rest"); final ServletContextHandler cxfContext = new ServletContextHandler(); cxfContext.setSessionHandler(new SessionHandler()); cxfContext.setContextPath(conf.getServerContextPath()); cxfContext.addServlet(cxfServletHolder, "/rest/*"); return cxfContext; }
Example 4
Source File: ExplorerServer.java From Explorer with Apache License 2.0 | 5 votes |
private static ServletContextHandler setupRestApiContextHandler() { final ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet()); cxfServletHolder.setInitParameter("javax.ws.rs.Application", ExplorerServer.class.getName()); cxfServletHolder.setName("rest"); cxfServletHolder.setForcedPath("rest"); final ServletContextHandler cxfContext = new ServletContextHandler(); cxfContext.setSessionHandler(new SessionHandler()); cxfContext.setContextPath("/api"); cxfContext.addServlet(cxfServletHolder, "/*"); cxfContext.addFilter(new FilterHolder(CorsFilter.class), "/*", EnumSet.allOf(DispatcherType.class)); return cxfContext; }
Example 5
Source File: RestOrderServer.java From camelinaction2 with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { // create dummy backend DummyOrderService dummy = new DummyOrderService(); dummy.setupDummyOrders(); // create rider order service with dummy backend RestOrderService orderService = new RestOrderService(); orderService.setOrderService(dummy); // create JAX-RS application with our rider order serivce RestOrderApplication app = new RestOrderApplication(orderService); // setup servlet holder with a CXF jax-rs servlet to handle the app Servlet servlet = new CXFNonSpringJaxrsServlet(app); ServletHolder holder = new ServletHolder(servlet); holder.setName("rider"); holder.setForcedPath("/"); ServletContextHandler context = new ServletContextHandler(); context.addServlet(holder, "/*"); // create and start the jetty server (non blocking) Server server = new Server(9000); server.setHandler(context); server.start(); // keep the JVM running Console console = System.console(); System.out.println("Server started on http://localhost:9000/"); System.out.println(""); // If you run the main class from IDEA/Eclipse then you may not have a console, which is null) if (console != null) { System.out.println(" Press ENTER to stop server"); console.readLine(); } else { System.out.println(" Stopping after 5 minutes or press ctrl + C to stop"); Thread.sleep(5 * 60 * 1000); } // stop jetty server server.stop(); System.exit(0); }
Example 6
Source File: NoSpringServletServer.java From cxf with Apache License 2.0 | 4 votes |
@Override protected void run() { // setup the system properties String busFactory = System.getProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME); System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, "org.apache.cxf.bus.CXFBusFactory"); try { httpServer = new Server(Integer.parseInt(PORT)); ContextHandlerCollection contexts = new ContextHandlerCollection(); httpServer.setHandler(contexts); ServletContextHandler root = new ServletContextHandler(contexts, "/", ServletContextHandler.SESSIONS); bus = BusFactory.getDefaultBus(true); CXFServlet cxf = new CXFServlet(); cxf.setBus(bus); ServletHolder servlet = new ServletHolder(cxf); servlet.setName("soap"); servlet.setForcedPath("soap"); root.addServlet(servlet, "/soap/*"); httpServer.start(); setBus(bus); BusFactory.setDefaultBus(bus); GreeterImpl impl = new GreeterImpl(); Endpoint.publish("/Greeter", impl); HelloImpl helloImpl = new HelloImpl(); Endpoint.publish("/Hello", helloImpl); ((EndpointImpl)Endpoint.create(helloImpl)).publish("/"); } catch (Exception e) { throw new RuntimeException(e); } finally { // clean up the system properties if (busFactory != null) { System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, busFactory); } else { System.clearProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME); } } }