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


Java ServletContextHandler.NO_SESSIONS属性代码示例

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


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

示例1: start

public void start() throws Exception {
    server = new Server(port);

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
    context.addFilter(AuthenticationFilter.class, "/*", null);
    context.setServer(server);

    // Add static files handler
    context.setBaseResource(Resource.newResource(JettyServer.class.getResource("/webapp")));
    context.addServlet(DefaultServlet.class,"/");
    context.setWelcomeFiles(new String[]{"index.html"});

    ServerContainer wsContainer = WebSocketServerContainerInitializer.configureContext(context);
    wsContainer.addEndpoint(createEndpointConfig(EchoEndpoint.class));

    server.setHandler(context);
    server.start();
}
 
开发者ID:asafalima,项目名称:guice-websocket,代码行数:18,代码来源:JettyServer.java

示例2: main

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,代码行数:20,代码来源:Main.java

示例3: main

/**
 * 
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
	ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
	context.setContextPath("/");
	Logger mainLogger = Logger.getInstance();
	mainLogger.out(Level.INFORMATIVE, "Main", "Starting server");
	Server server = new Server(8080);
	mainLogger.out(Level.INFORMATIVE, "Main", "Set handler");
	server.setHandler(context);

	ServletHolder jerseyServlet = context.addServlet(ServletContainer.class, "/*");
	jerseyServlet.setInitOrder(0);

	jerseyServlet.setInitParameter("com.sun.jersey.api.json.POJOMappingFeature", "true");
	jerseyServlet.setInitParameter("jersey.config.server.provider.packages", "view");

	server.start();
	server.join();
	mainLogger.out(Level.INFORMATIVE, "Main", "Server started");
}
 
开发者ID:MartijnDevNull,项目名称:storytime-backend,代码行数:24,代码来源:StartServer.java

示例4: run

public void run() {
    jettyServer = new Server(port);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
    context.getServletContext().setAttribute(STOP_ENTRY, stopKeyWord);
    context.getServletContext().setAttribute(CONTEXT_ENTRY, execCtx);
    context.getServletContext().setAttribute(LISTENER, this);
    context.setContextPath("");
    context.addServlet(new ServletHolder(ListenerServlet.class), "/*");
    
    
    jettyServer.setHandler(context);
    try {
        jettyServer.start();
        jettyServer.join();
    } catch(Exception ex) {
        LOGGER.error("While starting", ex);
        try {
            jettyServer.stop();
        } catch(Exception ex2) {
        } finally {
            jettyServer.destroy();
        }
    }
}
 
开发者ID:cmarchand,项目名称:gaulois-pipe,代码行数:24,代码来源:HttpListener.java

示例5: createServletForConnector

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,代码行数:22,代码来源:JettyHttpComponent.java

示例6: createContext

protected ServletContextHandler createContext(Server server, Connector connector, List<Handler> handlers) throws Exception {
    ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);
    server.addConnector(connector);

    if (handlers != null && !handlers.isEmpty()) {
        for (Handler handler : handlers) {
            if (handler instanceof HandlerWrapper) {
                ((HandlerWrapper) handler).setHandler(server.getHandler());
                server.setHandler(handler);
            } else {
                HandlerCollection handlerCollection = new HandlerCollection();
                handlerCollection.addHandler(server.getHandler());
                handlerCollection.addHandler(handler);
                server.setHandler(handlerCollection);
            }
        }
    }

    return context;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:WebsocketComponent.java

示例7: get

public Handler get() {
  ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
  handler.setContextPath("/");
  handler.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class));
  handler.addServlet(servletHolder, "/*");

  return handler;
}
 
开发者ID:sorskod,项目名称:webserver,代码行数:8,代码来源:ServletContextHandlerProvider.java

示例8: startHttpEngine

public static Proxy startHttpEngine() throws Exception {

        int port = startPort;

        while (true) {
            try {
                ServerSocket ss = new ServerSocket(port);
                ss.setReuseAddress(true);
                //ok no exception so the port must be free
                ss.close();
                break;
            } catch (IOException e) {
                port++;
            }
        }

        httpServer = new Server(port);
        /*ResourceHandler resourceHandler = new ResourceHandler();
        resourceHandler.setDirectoriesListed(true);
        resourceHandler.setResourceBase(".");
        httpServer.setHandler(resourceHandler);*/

        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
        context.setContextPath("/");
        httpServer.setHandler(context);
        context.addServlet(new ServletHolder(new TestingHttpProxyServlet()), "/*");
        httpServer.start();

        return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(InetAddress.getByName("127.0.0.1"), port));
    }
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:30,代码来源:HttpRequestRedirectorProxy.java

示例9: startup

public void startup() throws Exception {
  server = new Server(PORT);
  ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
  context.setContextPath("/");
  if (!Config.RPCUsername.equals("") && !Config.RPCPassword.equals("")) {
    context.setSecurityHandler(basicAuth(Config.RPCUsername, Config.RPCPassword, Config.appName));
  }
  server.setHandler(context);
  context.addServlet(JsonRpcServlet.class, "/"+Config.appName.toLowerCase());
  server.start();
}
 
开发者ID:ppkpub,项目名称:javatool,代码行数:11,代码来源:JsonRpcServletEngine.java

示例10: start

/**
 * Start the web server including setup.
 * @throws Exception
 */
public void start() throws Exception {
  if (embeddedJetty == null) {
    return;
  }

  final ServerConnector serverConnector;
  if (config.getBoolean(ExecConstants.HTTP_ENABLE_SSL)) {
    serverConnector = createHttpsConnector();
  } else {
    serverConnector = createHttpConnector();
  }
  embeddedJetty.addConnector(serverConnector);

  // Add resources
  final ErrorHandler errorHandler = new ErrorHandler();
  errorHandler.setShowStacks(true);
  errorHandler.setShowMessageInTitle(true);

  final ServletContextHandler servletContextHandler =
      new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
  servletContextHandler.setErrorHandler(errorHandler);
  servletContextHandler.setContextPath("/");
  embeddedJetty.setHandler(servletContextHandler);

  final ServletHolder servletHolder = new ServletHolder(new ServletContainer(new DrillRestServer(workManager)));
  servletHolder.setInitOrder(1);
  servletContextHandler.addServlet(servletHolder, "/*");

  servletContextHandler.addServlet(
      new ServletHolder(new MetricsServlet(metrics)), "/status/metrics");
  servletContextHandler.addServlet(new ServletHolder(new ThreadDumpServlet()), "/status/threads");

  final ServletHolder staticHolder = new ServletHolder("static", DefaultServlet.class);
  staticHolder.setInitParameter("resourceBase", Resource.newClassPathResource("/rest/static").toString());
  staticHolder.setInitParameter("dirAllowed","false");
  staticHolder.setInitParameter("pathInfoOnly","true");
  servletContextHandler.addServlet(staticHolder,"/static/*");

  embeddedJetty.start();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:44,代码来源:WebServer.java

示例11: createServletForConnector

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;
    boolean jetty = endpoint.getUseContinuation() != null ? endpoint.getUseContinuation() : isUseContinuation();
    if (jetty) {
        // use Jetty continuations
        CamelContinuationServlet jettyServlet = new CamelContinuationServlet();
        // configure timeout and log it so end user know what we are using
        Long timeout = endpoint.getContinuationTimeout() != null ? endpoint.getContinuationTimeout() : getContinuationTimeout();
        if (timeout != null) {
            LOG.info("Using Jetty continuation timeout: " + timeout + " millis for: " + endpoint);
            jettyServlet.setContinuationTimeout(timeout);
        } else {
            LOG.info("Using default Jetty continuation timeout for: " + endpoint);
        }

        // use the jetty servlet
        camelServlet = jettyServlet;
    } else {
        // do not use jetty so use a plain servlet
        camelServlet = new CamelServlet();
        LOG.info("Jetty continuation is disabled for: " + endpoint);
    }

    ServletHolder holder = new ServletHolder();
    holder.setServlet(camelServlet);
    context.addServlet(holder, "/*");

    // use rest enabled resolver in case we use rest
    camelServlet.setServletResolveConsumerStrategy(new JettyRestServletResolveConsumerStrategy());

    return camelServlet;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:41,代码来源:JettyHttpComponent.java

示例12: createServletContextHandler

private ServletContextHandler createServletContextHandler() {
    ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);
    servletContextHandler.setContextPath("/");
    servletContextHandler.setDisplayName(getDisplayName(listenedPorts));
    return servletContextHandler;
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:6,代码来源:JettyHttpServer.java

示例13: main

/**
 * Run the Wikipedia application.
 *
 * @param args  command line arguments
 * @throws Exception if the server fails to start or crashes
 */
public static void main(String[] args) throws Exception {
    int port = 9998;

    Server server = new Server(port);
    ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);

    servletContextHandler.addEventListener(new MetricServletContextListener());
    servletContextHandler.addEventListener(new HealthCheckServletContextListener());

    servletContextHandler.setContextPath("/");
    servletContextHandler.setResourceBase("src/main/webapp");

    //Activate codahale metrics
    FilterHolder instrumentedFilterHolder = new FilterHolder(InstrumentedFilter.class);
    instrumentedFilterHolder.setName("instrumentedFilter");
    instrumentedFilterHolder.setAsyncSupported(true);
    servletContextHandler.addFilter(instrumentedFilterHolder, "/*", EnumSet.noneOf(DispatcherType.class));

    // Static resource handler
    ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setDirectoriesListed(true);
    resourceHandler.setResourceBase("src/main/webapp");

    // Add the handlers to the server
    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] { resourceHandler, servletContextHandler });
    server.setHandler(handlers);

    ServletHolder servletHolder = servletContextHandler.addServlet(ServletContainer.class, "/v1/*");
    servletHolder.setInitOrder(1);
    servletHolder.setInitParameter(
            "javax.ws.rs.Application",
            "com.yahoo.bard.webservice.application.ResourceConfig");
    servletHolder.setInitParameter(
            "jersey.config.server.provider.packages",
            "com.yahoo.bard.webservice.web.endpoints");

    servletContextHandler.addServlet(AdminServlet.class, "/*");

    server.start();

    markDimensionCacheHealthy(port);
}
 
开发者ID:yahoo,项目名称:fili,代码行数:49,代码来源:WikiMain.java

示例14: main

/**
 * Run a generic setup which mirrors all information from druid into fili configuration.
 *
 * @param args  Command line arguments.
 *
 * @throws Exception if the server fails to start or crashes.
 */
public static void main(String[] args) throws Exception {
    int port = SYSTEM_CONFIG.getIntProperty(FILI_PORT);

    Server server = new Server(port);
    ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);

    servletContextHandler.addEventListener(new MetricServletContextListener());
    servletContextHandler.addEventListener(new HealthCheckServletContextListener());

    servletContextHandler.setContextPath("/");
    servletContextHandler.setResourceBase("src/main/webapp");

    //Activate codahale metrics
    FilterHolder instrumentedFilterHolder = new FilterHolder(InstrumentedFilter.class);
    instrumentedFilterHolder.setName("instrumentedFilter");
    instrumentedFilterHolder.setAsyncSupported(true);
    servletContextHandler.addFilter(instrumentedFilterHolder, "/*", EnumSet.noneOf(DispatcherType.class));

    // Static resource handler
    ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setDirectoriesListed(true);
    resourceHandler.setResourceBase("src/main/webapp");

    // Add the handlers to the server
    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] {resourceHandler, servletContextHandler});
    server.setHandler(handlers);

    ServletHolder servletHolder = servletContextHandler.addServlet(ServletContainer.class, "/v1/*");
    servletHolder.setInitOrder(1);
    servletHolder.setInitParameter(
            "javax.ws.rs.Application",
            "com.yahoo.bard.webservice.application.ResourceConfig"
    );
    servletHolder.setInitParameter(
            "jersey.config.server.provider.packages",
            "com.yahoo.bard.webservice.web.endpoints"
    );

    servletContextHandler.addServlet(AdminServlet.class, "/*");

    server.start();
}
 
开发者ID:yahoo,项目名称:fili,代码行数:50,代码来源:GenericMain.java

示例15: createServletForConnector

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,代码行数:41,代码来源:CometdComponent.java


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