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


Java ServletContextHandler.setContextPath方法代码示例

本文整理汇总了Java中org.eclipse.jetty.servlet.ServletContextHandler.setContextPath方法的典型用法代码示例。如果您正苦于以下问题:Java ServletContextHandler.setContextPath方法的具体用法?Java ServletContextHandler.setContextPath怎么用?Java ServletContextHandler.setContextPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.servlet.ServletContextHandler的用法示例。


在下文中一共展示了ServletContextHandler.setContextPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public static void main(String[] args) {
    int port = Configuration.INSTANCE.getInt("port", 8080);
    Server server = new Server(port);
    ServletContextHandler contextHandler
            = new ServletContextHandler(ServletContextHandler.SESSIONS);
    contextHandler.setContextPath("/");
    ServletHolder sh = new ServletHolder(new VaadinServlet());
    contextHandler.addServlet(sh, "/*");
    contextHandler.setInitParameter("ui", AnalysisUI.class.getCanonicalName());
    contextHandler.setInitParameter("productionMode", String.valueOf(PRODUCTION_MODE));
    server.setHandler(contextHandler);
    try {
        server.start();
        server.join();
    } catch (Exception e) {
        LOG.error("Failed to start application", e);
    }
}
 
开发者ID:tokenmill,项目名称:crawling-framework,代码行数:19,代码来源:Application.java

示例2: initApi

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private void initApi() {
    ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
    servletHandler.setContextPath("/api");
    servletHandler.getSessionHandler().setSessionManager(sessionManager);

    servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()), "/socket");

    ResourceConfig resourceConfig = new ResourceConfig();
    resourceConfig.registerClasses(JacksonFeature.class, ObjectMapperProvider.class, ResourceErrorHandler.class);
    resourceConfig.registerClasses(SecurityRequestFilter.class, CorsResponseFilter.class);
    resourceConfig.packages(ServerResource.class.getPackage().getName());

    servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*");

    handlers.addHandler(servletHandler);
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:17,代码来源:WebServer.java

示例3: main

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    NettyServerBuilder.forAddress(LocalAddress.ANY).forPort(19876)
        .maxConcurrentCallsPerConnection(12).maxMessageSize(16777216)
        .addService(new MockApplicationRegisterService())
        .addService(new MockInstanceDiscoveryService())
        .addService(new MockJVMMetricsService())
        .addService(new MockServiceNameDiscoveryService())
        .addService(new MockTraceSegmentService()).build().start();

    Server jettyServer = new Server(new InetSocketAddress("0.0.0.0",
        Integer.valueOf(12800)));
    String contextPath = "/";
    ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
    servletContextHandler.setContextPath(contextPath);
    servletContextHandler.addServlet(GrpcAddressHttpService.class, GrpcAddressHttpService.SERVLET_PATH);
    servletContextHandler.addServlet(ReceiveDataService.class, ReceiveDataService.SERVLET_PATH);
    servletContextHandler.addServlet(ClearReceiveDataService.class, ClearReceiveDataService.SERVLET_PATH);
    jettyServer.setHandler(servletContextHandler);
    jettyServer.start();
}
 
开发者ID:SkywalkingTest,项目名称:skywalking-mock-collector,代码行数:21,代码来源:Main.java

示例4: run

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public void run(final int port) {
    try {
        final Server server = createServer();

        final ServletContextHandler context = new ServletContextHandler();
        context.setContextPath("/");
        server.setHandler(context);

        for (final MinijaxApplication application : applications) {
            addApplication(context, application);
        }

        final ServerConnector connector = createConnector(server);
        connector.setPort(port);
        server.setConnectors(new Connector[] { connector });
        server.start();
        server.join();

    } catch (final Exception ex) {
        throw new MinijaxException(ex);
    }
}
 
开发者ID:minijax,项目名称:minijax,代码行数:23,代码来源:Minijax.java

示例5: main

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	Runtime.getRuntime().addShutdownHook(new ShutdownHook());

	Initiator.init();

	Server server = new Server(PORT);
	ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
	context.setContextPath(CONTEXT_PATH);
	server.setHandler(context);
	server.setStopAtShutdown(true);

	context.addServlet(new ServletHolder(new GetAllLang()), "/get_all_lang");
	context.addServlet(new ServletHolder(new Compile()), "/compile");
	context.addServlet(new ServletHolder(new Run()), "/run");
	server.join();
	server.start();

	LOGGER.info("Avalon-Executive server is now running at http://127.0.0.1:" + PORT + CONTEXT_PATH);
}
 
开发者ID:ProgramLeague,项目名称:Avalon-Executive,代码行数:20,代码来源:MainServer.java

示例6: createRestService

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private Handler createRestService() {
    ResourceConfig rc = new ResourceConfig();
    localRestResources.forEach(rc::register);
    rc.register(JacksonFeature.class);
    rc.register(CORSFilter.class);
    rc.addProperties(new HashMap<String,Object>() {{
        // Turn off buffering so results can be streamed
        put(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 0);
    }});

    ServletHolder holder = new ServletHolder(new ServletContainer(rc));

    ServletContextHandler sch = new ServletContextHandler();
    sch.setContextPath("/api/v1");
    sch.addServlet(holder, "/*");

    return sch;
}
 
开发者ID:danielflower,项目名称:app-runner-router,代码行数:19,代码来源:WebServer.java

示例7: run

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public void run() throws Exception {

		org.eclipse.jetty.util.log.Log.setLog(new Slf4jLog());
		Server server = new Server(port);
        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
        context.setContextPath("/");
        context.setResourceBase(httpPath);
        HashSessionIdManager idmanager = new HashSessionIdManager();
        server.setSessionIdManager(idmanager);
        HashSessionManager manager = new HashSessionManager();
        SessionHandler sessions = new SessionHandler(manager);
        sessions.setHandler(context);
        context.addServlet(new ServletHolder(new Servlet(this::getPinto)),"/pinto/*");
        ServletHolder holderPwd = new ServletHolder("default", DefaultServlet.class);
        context.addServlet(holderPwd,"/*");
        server.setHandler(sessions);
		new Thread(new Console(getPinto(),port,build, () -> {
			try {
				server.stop();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}), "console_thread").start();
        server.start();
        server.join();
	}
 
开发者ID:punkbrwstr,项目名称:pinto,代码行数:27,代码来源:Main.java

示例8: JSMServer

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public JSMServer(int port) {
    this.statsBroadcaster = new StatsBroadcaster();

    this.server = new Server(port);
    try {
        ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS);
        handler.setContextPath("/");

        handler.addServlet(new ServletHolder(new StatsServlet()), "/stats");
        handler.addServlet(new ServletHolder(new SinkServlet()), "/sinks");

        this.server.setHandler(handler);
    } catch (Exception e) {
        logger.error("Exception in configuring servlet handlers", e);
    }
}
 
开发者ID:adohe,项目名称:jsm,代码行数:17,代码来源:JSMServer.java

示例9: createRestService

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private Handler createRestService() {
    ResourceConfig rc = new ResourceConfig();
    rc.register(systemResource);
    rc.register(appResource);
    rc.register(JacksonFeature.class);
    rc.register(CORSFilter.class);
    SwaggerDocs.registerSwaggerJsonResource(rc);
    rc.addProperties(new HashMap<String,Object>() {{
        // Turn off buffering so results can be streamed
        put(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 0);
    }});

    ServletHolder holder = new ServletHolder(new ServletContainer(rc));

    ServletContextHandler sch = new ServletContextHandler();
    sch.setContextPath("/api/v1");
    sch.addServlet(holder, "/*");

    GzipHandler gzipHandler = new GzipHandler();
    gzipHandler.setHandler(sch);
    return gzipHandler;
}
 
开发者ID:danielflower,项目名称:app-runner,代码行数:23,代码来源:WebServer.java

示例10: start

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public void start(Controller controller) throws Exception {
    this.controller = controller;

    Server server = new Server(REST_SERVICE_PORT);

    ServletContextHandler servletContextHandler = new ServletContextHandler();
    servletContextHandler.setContextPath("");
    servletContextHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig(controller))), "/*");
    server.setHandler(servletContextHandler);

    try {
        server.start();
        server.join();
    } finally {
        server.destroy();
    }
}
 
开发者ID:k0105,项目名称:ensemble,代码行数:18,代码来源:RestServer.java

示例11: createComputeRealtimeServer

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
/**
 * Creates a new {@link ComputeRealtimeServer}
 *
 * @param config
 *            The chatalytics config
 * @return A newly created {@link ComputeRealtimeServer}
 */
public ComputeRealtimeServer createComputeRealtimeServer() {
    Server server = new Server(config.computeConfig.rtComputePort);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");

    ServletHolder jerseyServlet = context.addServlet(ServletContainer.class, "/*");
    jerseyServlet.setInitParameter(PackagesResourceConfig.PROPERTY_PACKAGES,
                                   StatusResource.class.getPackage().toString());
    server.setHandler(context);
    ServerContainer wscontainer;
    try {
        wscontainer = WebSocketServerContainerInitializer.configureContext(context);
        wscontainer.addEndpoint(RealtimeResource.class);
    } catch (ServletException | DeploymentException e) {
        throw new RuntimeException("Can't instantiate websocket. Reason: " + e.getMessage());
    }

    return new ComputeRealtimeServer(server);
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:27,代码来源:ComputeRealtimeServerFactory.java

示例12: main

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public static void main( String[] args ) throws Exception {
    Server server = new Server(1234);
    ServletContextHandler context = new ServletContextHandler();
    context.setContextPath("/");
    server.setHandler(context);
    // Expose our example servlet.
    context.addServlet(new ServletHolder(new ExampleServlet()), "/");
    // Expose Promtheus metrics.
    context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics");
    // Add metrics about CPU, JVM memory etc.
    DefaultExports.initialize();


    // Start the webserver.
    server.start();
    server.join();
}
 
开发者ID:RobustPerception,项目名称:java_examples,代码行数:18,代码来源:JavaSimple.java

示例13: setUp

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    server = new Server(PORT);

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    server.setHandler(context);

    servletHolder = new ServletHolder(new CamelWebSocketServlet());
    servletHolder.setName("CamelWsServlet");
    context.addServlet(servletHolder, "/*");
    
    server.start();
    
    if (startCamelContext) {        
        super.setUp();
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:WebsocketCamelRouterTestSupport.java

示例14: startServer

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public void startServer() {
    server = new Server(PORT);
    port = PORT;

    ServletContextHandler servletContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
    servletContext.setSecurityHandler(basicAuth("camel", "camelPass", "Private!"));
    servletContext.setContextPath("/");
    server.setHandler(servletContext);
    servletContext.addServlet(new ServletHolder(new MyHttpServlet()), "/*");
    try {
        server.start();
    } catch (Exception ex) {
        LOG.error("Could not start Server!", ex);
        fail(ex.getLocalizedMessage());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:JettyTestServer.java

示例15: initContext

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private ServletContextHandler initContext(final String contextPath, final Set<Class<?>> classes) {
    final ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath(contextPath);
    context.setAttribute(ATTR_CLASSES, classes);
    context.setAttribute(ATTR_DI, dependencyInjection);
    return context;
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:8,代码来源:RestServerImpl.java


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