org.eclipse.jetty.server.handler.ContextHandler Java Examples
The following examples show how to use
org.eclipse.jetty.server.handler.ContextHandler.
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: CampServer.java From brooklyn-server with Apache License 2.0 | 6 votes |
public static Server startServer(ContextHandler context, String summary) { // FIXME port hardcoded int port = Networking.nextAvailablePort(8080); // use a nice name in the thread pool (otherwise this is exactly the same as Server defaults) QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setName("camp-jetty-server-"+port+"-"+threadPool.getName()); Server server = new Server(threadPool); ServerConnector httpConnector = new ServerConnector(server); httpConnector.setPort(port); server.addConnector(httpConnector); server.setHandler(context); try { server.start(); } catch (Exception e) { throw Exceptions.propagate(e); } log.info("CAMP REST server started ("+summary+") on"); log.info(" http://localhost:"+httpConnector.getLocalPort()+"/"); return server; }
Example #2
Source File: ConnectionDroppedTest.java From knox with Apache License 2.0 | 6 votes |
private static void startProxy() throws Exception { GatewayConfig gatewayConfig = EasyMock.createNiceMock(GatewayConfig.class); proxy = new Server(); proxyConnector = new ServerConnector(proxy); proxy.addConnector(proxyConnector); /* start Knox with WebsocketAdapter to test */ final BigEchoSocketHandler wsHandler = new BigEchoSocketHandler( new ProxyWebSocketAdapter(serverUri, Executors.newFixedThreadPool(10), gatewayConfig)); ContextHandler context = new ContextHandler(); context.setContextPath("/"); context.setHandler(wsHandler); proxy.setHandler(context); // Start Server proxy.start(); String host = proxyConnector.getHost(); if (host == null) { host = "localhost"; } int port = proxyConnector.getLocalPort(); proxyUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/", host, port)); }
Example #3
Source File: MessageFailureTest.java From knox with Apache License 2.0 | 6 votes |
private static void startProxy() throws Exception { GatewayConfig gatewayConfig = EasyMock.createNiceMock(GatewayConfig.class); proxy = new Server(); proxyConnector = new ServerConnector(proxy); proxy.addConnector(proxyConnector); /* start Knox with WebsocketAdapter to test */ final BigEchoSocketHandler wsHandler = new BigEchoSocketHandler( new ProxyWebSocketAdapter(serverUri, Executors.newFixedThreadPool(10), gatewayConfig)); ContextHandler context = new ContextHandler(); context.setContextPath("/"); context.setHandler(wsHandler); proxy.setHandler(context); // Start Server proxy.start(); String host = proxyConnector.getHost(); if (host == null) { host = "localhost"; } int port = proxyConnector.getLocalPort(); proxyUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/", host, port)); }
Example #4
Source File: MessageFailureTest.java From knox with Apache License 2.0 | 6 votes |
private static void startBackend() throws Exception { backend = new Server(); connector = new ServerConnector(backend); backend.addConnector(connector); /* start backend with Echo socket */ final BigEchoSocketHandler wsHandler = new BigEchoSocketHandler( new EchoSocket()); ContextHandler context = new ContextHandler(); context.setContextPath("/"); context.setHandler(wsHandler); backend.setHandler(context); // Start Server backend.start(); String host = connector.getHost(); if (host == null) { host = "localhost"; } int port = connector.getLocalPort(); serverUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/", host, port)); }
Example #5
Source File: BadBackendTest.java From knox with Apache License 2.0 | 6 votes |
private static void startProxy() throws Exception { GatewayConfig gatewayConfig = EasyMock.createNiceMock(GatewayConfig.class); proxy = new Server(); proxyConnector = new ServerConnector(proxy); proxy.addConnector(proxyConnector); /* start Knox with WebsocketAdapter to test */ final BigEchoSocketHandler wsHandler = new BigEchoSocketHandler( new ProxyWebSocketAdapter(new URI(BAD_BACKEND), Executors.newFixedThreadPool(10), gatewayConfig)); ContextHandler context = new ContextHandler(); context.setContextPath("/"); context.setHandler(wsHandler); proxy.setHandler(context); // Start Server proxy.start(); String host = proxyConnector.getHost(); if (host == null) { host = "localhost"; } int port = proxyConnector.getLocalPort(); proxyUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/", host, port)); }
Example #6
Source File: ProxyInboundClientTest.java From knox with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpBeforeClass() throws Exception { server = new Server(); ServerConnector connector = new ServerConnector(server); server.addConnector(connector); Handler handler = new WebsocketEchoHandler(); ContextHandler context = new ContextHandler(); context.setContextPath("/"); context.setHandler(handler); server.setHandler(context); server.start(); String host = connector.getHost(); if (host == null) { host = "localhost"; } int port = connector.getLocalPort(); serverUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/",host,port)); }
Example #7
Source File: PrometheusServer.java From monsoon with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void main(String[] args) throws Exception { final ApiServer api = new ApiServer(new InetSocketAddress(9998)); PrometheusConfig cfg = createPrometheusConfig(args); final Optional<File> _cfg = cfg.getConfiguration(); if (_cfg.isPresent()) registry_ = new PipelineBuilder(_cfg.get()).build(); else registry_ = new PipelineBuilder(Configuration.DEFAULT).build(); api.start(); Runtime.getRuntime().addShutdownHook(new Thread(api::close)); Server server = new Server(cfg.getPort()); ContextHandler context = new ContextHandler(); context.setClassLoader(Thread.currentThread().getContextClassLoader()); context.setContextPath(cfg.getPath()); context.setHandler(new DisplayMetrics(registry_)); server.setHandler(context); server.start(); server.join(); }
Example #8
Source File: DeploymentCheck.java From jetty-runtime with Apache License 2.0 | 6 votes |
@Override public void lifeCycleStarted(LifeCycle bean) { if (bean instanceof Server) { Server server = (Server)bean; Connector[] connectors = server.getConnectors(); if (connectors == null || connectors.length == 0) { server.dumpStdErr(); throw new IllegalStateException("No Connector"); } else if (!Arrays.stream(connectors).allMatch(Connector::isStarted)) { server.dumpStdErr(); throw new IllegalStateException("Connector not started"); } ContextHandler context = server.getChildHandlerByClass(ContextHandler.class); if (context == null || !context.isAvailable()) { server.dumpStdErr(); throw new IllegalStateException("No Available Context"); } } }
Example #9
Source File: JettyServer.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
private static void logStartupBanner(Server server) { Object banner = null; ContextHandler contextHandler = server.getChildHandlerByClass(ContextHandler.class); if (contextHandler != null) { Context context = contextHandler.getServletContext(); if (context != null) { banner = context.getAttribute("nexus-banner"); } } StringBuilder buf = new StringBuilder(); buf.append("\n-------------------------------------------------\n\n"); buf.append("Started ").append(banner instanceof String ? banner : "Nexus Repository Manager"); buf.append("\n\n-------------------------------------------------"); log.info(buf.toString()); }
Example #10
Source File: ConnectionDroppedTest.java From knox with Apache License 2.0 | 6 votes |
private static void startBackend() throws Exception { backend = new Server(); connector = new ServerConnector(backend); backend.addConnector(connector); /* start backend with Echo socket */ final BigEchoSocketHandler wsHandler = new BigEchoSocketHandler( new BadSocket()); ContextHandler context = new ContextHandler(); context.setContextPath("/"); context.setHandler(wsHandler); backend.setHandler(context); // Start Server backend.start(); String host = connector.getHost(); if (host == null) { host = "localhost"; } int port = connector.getLocalPort(); serverUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/", host, port)); }
Example #11
Source File: WebsocketMultipleConnectionTest.java From knox with Apache License 2.0 | 6 votes |
/** * Start Mock Websocket server that acts as backend. * @throws Exception exception on websocket server start */ private static void startWebsocketServer() throws Exception { backendServer = new Server(new QueuedThreadPool(254)); ServerConnector connector = new ServerConnector(backendServer); backendServer.addConnector(connector); final WebsocketEchoHandler handler = new WebsocketEchoHandler(); ContextHandler context = new ContextHandler(); context.setContextPath("/"); context.setHandler(handler); backendServer.setHandler(context); // Start Server backendServer.start(); String host = connector.getHost(); if (host == null) { host = "localhost"; } int port = connector.getLocalPort(); backendServerUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/ws", host, port)); }
Example #12
Source File: WebServer.java From sparkler with Apache License 2.0 | 6 votes |
public WebServer(int port, String resRoot){ super(port); LOG.info("Port:{}, Resources Root:{}", port, resRoot); ResourceHandler rh0 = new ResourceHandler(); ContextHandler context0 = new ContextHandler(); context0.setContextPath("/res/*"); context0.setResourceBase(resRoot); context0.setHandler(rh0); //ServletHandler context1 = new ServletHandler(); //this.setHandler(context1); ServletContextHandler context1 = new ServletContextHandler(); context1.addServlet(TestSlaveServlet.class, "/slavesite/*"); // Create a ContextHandlerCollection and set the context handlers to it. // This will let jetty process urls against the declared contexts in // order to match up content. ContextHandlerCollection contexts = new ContextHandlerCollection(); contexts.setHandlers(new Handler[] { context1, context0}); this.setHandler(contexts); }
Example #13
Source File: GatewayPortMappingConfigTest.java From knox with Apache License 2.0 | 6 votes |
private static void startGatewayServer() throws Exception { // use default Max threads gatewayServer = new Server(defaultPort); final ServerConnector connector = new ServerConnector(gatewayServer); gatewayServer.addConnector(connector); // workaround so we can add our handler later at runtime HandlerCollection handlers = new HandlerCollection(true); // add some initial handlers ContextHandler context = new ContextHandler(); context.setContextPath("/"); handlers.addHandler(context); gatewayServer.setHandler(handlers); // Start Server gatewayServer.start(); }
Example #14
Source File: ConfigIntegrationTest.java From apollo with Apache License 2.0 | 6 votes |
private ContextHandler mockConfigServerHandler(final int statusCode, final ApolloConfig result, final boolean failedAtFirstTime) { ContextHandler context = new ContextHandler("/configs/*"); context.setHandler(new AbstractHandler() { AtomicInteger counter = new AtomicInteger(0); @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (failedAtFirstTime && counter.incrementAndGet() == 1) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); baseRequest.setHandled(true); return; } response.setContentType("application/json;charset=UTF-8"); response.setStatus(statusCode); response.getWriter().println(gson.toJson(result)); baseRequest.setHandled(true); } }); return context; }
Example #15
Source File: EmbeddedServer.java From jaxrs with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { URI baseUri = UriBuilder.fromUri("http://localhost").port(SERVER_PORT) .build(); ResourceConfig config = new ResourceConfig(Calculator.class); Server server = JettyHttpContainerFactory.createServer(baseUri, config, false); ContextHandler contextHandler = new ContextHandler("/rest"); contextHandler.setHandler(server.getHandler()); ProtectionDomain protectionDomain = EmbeddedServer.class .getProtectionDomain(); URL location = protectionDomain.getCodeSource().getLocation(); ResourceHandler resourceHandler = new ResourceHandler(); resourceHandler.setWelcomeFiles(new String[] { "index.html" }); resourceHandler.setResourceBase(location.toExternalForm()); System.out.println(location.toExternalForm()); HandlerCollection handlerCollection = new HandlerCollection(); handlerCollection.setHandlers(new Handler[] { resourceHandler, contextHandler, new DefaultHandler() }); server.setHandler(handlerCollection); server.start(); server.join(); }
Example #16
Source File: BrooklynRestApiLauncher.java From brooklyn-server with Apache License 2.0 | 6 votes |
private static Server startServer(ManagementContext mgmt, ContextHandler context, String summary, boolean disableHighAvailability) { // TODO this repeats code in BrooklynLauncher / WebServer. should merge the two paths. boolean secure = mgmt != null && !BrooklynWebConfig.hasNoSecurityOptions(mgmt.getConfig()); if (secure) { log.debug("Detected security configured, launching server on all network interfaces"); } else { log.debug("Detected no security configured, launching server on loopback (localhost) network interface only"); if (mgmt!=null) { log.debug("Detected no security configured, running on loopback; disabling authentication"); ((BrooklynProperties)mgmt.getConfig()).put(BrooklynWebConfig.SECURITY_PROVIDER_CLASSNAME, AnyoneSecurityProvider.class.getName()); } } if (mgmt != null && disableHighAvailability) { mgmt.getHighAvailabilityManager().disabled(false); } InetSocketAddress bindLocation = new InetSocketAddress( secure ? Networking.ANY_NIC : Networking.LOOPBACK, Networking.nextAvailablePort(FAVOURITE_PORT)); return startServer(mgmt, context, summary, bindLocation); }
Example #17
Source File: ConfigIntegrationTest.java From apollo with Apache License 2.0 | 6 votes |
@Test public void testGetConfigWithLocalFileAndWithRemoteConfig() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String anotherValue = "anotherValue"; Properties properties = new Properties(); properties.put(someKey, someValue); createLocalCachePropertyFile(properties); ApolloConfig apolloConfig = assembleApolloConfig(ImmutableMap.of(someKey, anotherValue)); ContextHandler handler = mockConfigServerHandler(HttpServletResponse.SC_OK, apolloConfig); startServerWithHandlers(handler); Config config = ConfigService.getAppConfig(); assertEquals(anotherValue, config.getProperty(someKey, null)); }
Example #18
Source File: ConfigIntegrationTest.java From apollo with Apache License 2.0 | 6 votes |
@Test public void testOrderGetConfigWithNoLocalFileButWithRemoteConfig() throws Exception { setPropertiesOrderEnabled(true); String someKey1 = "someKey1"; String someValue1 = "someValue1"; String someKey2 = "someKey2"; String someValue2 = "someValue2"; Map<String, String> configurations = new LinkedHashMap<>(); configurations.put(someKey1, someValue1); configurations.put(someKey2, someValue2); ApolloConfig apolloConfig = assembleApolloConfig(ImmutableMap.copyOf(configurations)); ContextHandler handler = mockConfigServerHandler(HttpServletResponse.SC_OK, apolloConfig); startServerWithHandlers(handler); Config config = ConfigService.getAppConfig(); Set<String> propertyNames = config.getPropertyNames(); Iterator<String> it = propertyNames.iterator(); assertEquals(someKey1, it.next()); assertEquals(someKey2, it.next()); }
Example #19
Source File: BrooklynRestApiLauncher.java From brooklyn-server with Apache License 2.0 | 6 votes |
private static Server startServer(ManagementContext mgmt, ContextHandler context, String summary, InetSocketAddress bindLocation) { Server server = new Server(bindLocation); initAuth(mgmt, server); server.setHandler(context); try { server.start(); } catch (Exception e) { throw Exceptions.propagate(e); } log.info("Brooklyn REST server started ("+summary+") on"); log.info(" http://localhost:"+((NetworkConnector)server.getConnectors()[0]).getLocalPort()+"/"); return server; }
Example #20
Source File: WebServerTest.java From buck with Apache License 2.0 | 6 votes |
@Test public void testCreateHandlersCoversExpectedContextPaths() { ProjectFilesystem projectFilesystem = new FakeProjectFilesystem(); WebServer webServer = new WebServer(/* port */ 9999, projectFilesystem, FakeClock.doNotCare()); ImmutableList<ContextHandler> handlers = webServer.createHandlers(); Map<String, ContextHandler> contextPathToHandler = new HashMap<>(); for (ContextHandler handler : handlers) { contextPathToHandler.put(handler.getContextPath(), handler); } Function<String, TemplateHandlerDelegate> getDelegate = contextPath -> ((TemplateHandler) contextPathToHandler.get(contextPath).getHandler()).getDelegate(); assertTrue(getDelegate.apply("/") instanceof IndexHandlerDelegate); assertTrue(contextPathToHandler.get("/static").getHandler() instanceof StaticResourcesHandler); assertTrue(getDelegate.apply("/trace") instanceof TraceHandlerDelegate); assertTrue(getDelegate.apply("/traces") instanceof TracesHandlerDelegate); assertTrue(contextPathToHandler.get("/tracedata").getHandler() instanceof TraceDataHandler); }
Example #21
Source File: VRaptorServer.java From mamute with Apache License 2.0 | 6 votes |
private ContextHandler systemRestart() { AbstractHandler system = new AbstractHandler() { @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { restartContexts(); response.setContentType("text/html;charset=utf-8"); response.setStatus(HttpServletResponse.SC_OK); baseRequest.setHandled(true); response.getWriter().println("<h1>Done</h1>"); } }; ContextHandler context = new ContextHandler(); context.setContextPath("/vraptor/restart"); context.setResourceBase("."); context.setClassLoader(Thread.currentThread().getContextClassLoader()); context.setHandler(system); return context; }
Example #22
Source File: DocumentStorage.java From JVoiceXML with GNU Lesser General Public License v2.1 | 6 votes |
/** * Starts the document storage. Afterwards it will be ready to serve * documents. * * @throws Exception * error starting the web server * * @since 0.7.8 */ public void start() throws Exception { if (storagePort < 0) { return; } server = new Server(storagePort); ContextHandler rootContext = new ContextHandler(); rootContext.setHandler(internalGrammarHandler); ContextHandler internalGrammarContext = new ContextHandler( InternalGrammarDocumentHandler.CONTEXT_PATH); internalGrammarContext.setHandler(internalGrammarHandler); ContextHandler builtinGrammarContext = new ContextHandler( BuiltinGrammarHandler.CONTEXT_PATH); ContextHandlerCollection contexts = new ContextHandlerCollection(); builtinGrammarContext.setHandler(builtinGrammarHandler); ContextHandler[] handlers = new ContextHandler[] { rootContext, internalGrammarContext, builtinGrammarContext }; contexts.setHandlers(handlers); server.setHandler(contexts); server.start(); LOGGER.info("document storage started on port " + storagePort); }
Example #23
Source File: JettyHTTPServerEngine.java From cxf with Apache License 2.0 | 5 votes |
private String getHandlerName(URL url, ContextHandler context) { String contextPath = context.getContextPath(); String path = url.getPath(); if (path.startsWith(contextPath)) { if ("/".equals(contextPath)) { return path; } return path.substring(contextPath.length()); } else { return HttpUriMapper.getResourceBase(url.getPath()); } }
Example #24
Source File: ServerManager.java From raccoon4 with Apache License 2.0 | 5 votes |
/** * Start the webserver. * * @param lm * the {@link Lifecycle} to notify when a client initiates a transfer * the user should know about. */ public void startup(LifecycleManager lm) { this.appListHandler = new AppListHandler(layout, lm); this.focusedAppHandler = new AppListHandler(layout, lm); this.fileHandler = new FileHandler(lm); this.resourceHandler = new ResourceHandler(); ContextHandler list = new ContextHandler(APPCOLLECTIONPATH); list.setHandler(appListHandler); ContextHandler focused = new ContextHandler(APPSINGLEPATH); focused.setHandler(focusedAppHandler); ContextHandler files = new ContextHandler(FILEPATH); files.setHandler(fileHandler); ContextHandler rsrc = new ContextHandler(RSRCPATH); rsrc.setHandler(resourceHandler); AbstractHandler[] tmp = { list, focused, files, rsrc }; ContextHandlerCollection handlers = new ContextHandlerCollection(); handlers.setHandlers(tmp); server = new Server(0); server.setHandler(handlers); try { server.start(); } catch (Exception e) { e.printStackTrace(); } synchronized (lock) { lock.notifyAll(); } }
Example #25
Source File: Main.java From selenium with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { Flags flags = new Flags(); JCommander.newBuilder().addObject(flags).build().parse(args); Server server = new Server(); ServerConnector connector = new ServerConnector(server); connector.setPort(flags.port); server.setConnectors(new Connector[] {connector }); HandlerList handlers = new HandlerList(); ContextHandler context = new ContextHandler(); context.setContextPath("/tests"); ResourceHandler testHandler = new ResourceHandler(); testHandler.setBaseResource(Resource.newClassPathResource("/tests")); testHandler.setDirectoriesListed(true); context.setHandler(testHandler); handlers.addHandler(context); ContextHandler coreContext = new ContextHandler(); coreContext.setContextPath("/core"); ResourceHandler coreHandler = new ResourceHandler(); coreHandler.setBaseResource(Resource.newClassPathResource("/core")); coreContext.setHandler(coreHandler); handlers.addHandler(coreContext); ServletContextHandler driverContext = new ServletContextHandler(); driverContext.setContextPath("/"); driverContext.addServlet(WebDriverServlet.class, "/wd/hub/*"); handlers.addHandler(driverContext); server.setHandler(handlers); server.start(); }
Example #26
Source File: StreamingReceiver.java From kylin with Apache License 2.0 | 5 votes |
private void startHttpServer() throws Exception { KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv(); createAndConfigHttpServer(kylinConfig); ContextHandlerCollection contexts = new ContextHandlerCollection(); ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/kylin"); XmlWebApplicationContext ctx = new XmlWebApplicationContext(); ctx.setConfigLocation("classpath:applicationContext.xml"); ctx.refresh(); DispatcherServlet dispatcher = new DispatcherServlet(ctx); context.addServlet(new ServletHolder(dispatcher), "/api/*"); ContextHandler logContext = new ContextHandler("/kylin/logs"); String logDir = getLogDir(kylinConfig); ResourceHandler logHandler = new ResourceHandler(); logHandler.setResourceBase(logDir); logHandler.setDirectoriesListed(true); logContext.setHandler(logHandler); contexts.setHandlers(new Handler[] { context, logContext }); httpServer.setHandler(contexts); httpServer.start(); httpServer.join(); }
Example #27
Source File: HttpConductorImpl.java From sql-layer with GNU Affero General Public License v3.0 | 5 votes |
private void addCsrfFilter(ContextHandler handler) throws ServletException { CsrfProtectionType type = safeParseCsrfType(CONFIG_CSRF_TYPE); switch (type) { case NONE: break; case REFERER: FilterRegistration reg = handler.getServletContext().addFilter("CSRFFilter", CsrfProtectionRefererFilter.class); reg.addMappingForServletNames(null, false, "*"); reg.setInitParameter(CsrfProtectionRefererFilter.ALLOWED_REFERERS_PARAM, configurationService.getProperty(CONFIG_CSRF_ALLOWED_REFERERS)); break; default: throw new IllegalArgumentException("Invalid " + CONFIG_CSRF_TYPE + " property: " + type); } }
Example #28
Source File: BaleenWebApi.java From baleen with Apache License 2.0 | 5 votes |
private void installSwagger(HandlerList handlers) { LOGGER.debug("Adding Swagger documentation"); final ResourceHandler resourceHandler = new ResourceHandler(); resourceHandler.setDirectoriesListed(true); // resourceHandler.setResourceBase(getClass().getResource("/swagger").toExternalForm()); ContextHandler swaggerHandler = new ContextHandler("/swagger/*"); swaggerHandler.setHandler(resourceHandler); handlers.addHandler(swaggerHandler); }
Example #29
Source File: HttpConductorImpl.java From sql-layer with GNU Affero General Public License v3.0 | 5 votes |
private void addCrossOriginFilter(ContextHandler handler) throws ServletException { FilterRegistration reg = handler.getServletContext().addFilter("CrossOriginFilter", CrossOriginFilter.class); reg.addMappingForServletNames(null, false, "*"); reg.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, configurationService.getProperty(CONFIG_XORIGIN_ORIGINS)); reg.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, configurationService.getProperty(CONFIG_XORIGIN_METHODS)); reg.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, configurationService.getProperty(CONFIG_XORIGIN_HEADERS)); reg.setInitParameter(CrossOriginFilter.PREFLIGHT_MAX_AGE_PARAM, configurationService.getProperty(CONFIG_XORIGIN_MAX_AGE)); reg.setInitParameter(CrossOriginFilter.ALLOW_CREDENTIALS_PARAM, configurationService.getProperty(CONFIG_XORIGIN_CREDENTIALS)); }
Example #30
Source File: WebService.java From pulsar with Apache License 2.0 | 5 votes |
public void addStaticResources(String basePath, String resourcePath) { ContextHandler capHandler = new ContextHandler(); capHandler.setContextPath(basePath); ResourceHandler resHandler = new ResourceHandler(); resHandler.setBaseResource(Resource.newClassPathResource(resourcePath)); resHandler.setEtags(true); resHandler.setCacheControl(WebService.HANDLER_CACHE_CONTROL); capHandler.setHandler(resHandler); handlers.add(capHandler); }