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


Java ServletContextHandler.setSessionHandler方法代码示例

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


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

示例1: main

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public static void main(String[] args) {
    log.info("Server starting...");

    Server embeddedServer = new Server(8080);

    ServletContextHandler contextHandler = new ServletContextHandler(null, "/", true, false);
    embeddedServer.setHandler(contextHandler);

    SessionHandler sessions = new SessionHandler();
    contextHandler.setSessionHandler(sessions);

    ServletHolder servletHolder = new ServletHolder(AppServlet.class);
    contextHandler.addServlet(servletHolder, "/*");

    try {
        embeddedServer.start();
        embeddedServer.join();
    } catch (Exception e) {
        log.error("Server error:\n", e);
    }

    log.info("Server stopped");
}
 
开发者ID:jreznot,项目名称:electron-java-app,代码行数:24,代码来源:Launcher.java

示例2: enableSessionSupport

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private void enableSessionSupport(Server server, String connectorKey) throws Exception {
    ServletContextHandler context = server.getChildHandlerByClass(ServletContextHandler.class);
    if (context.getSessionHandler() == null) {
        SessionHandler sessionHandler = new SessionHandler();
        if (context.isStarted()) {
            throw new IllegalStateException("Server has already been started. Cannot enabled sessionSupport on " + connectorKey);
        } else {
            context.setSessionHandler(sessionHandler);
        }
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:12,代码来源:JettyHttpComponent.java

示例3: setupNotebookServer

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private static ServletContextHandler setupNotebookServer(ZeppelinConfiguration conf) {
  notebookWsServer = new NotebookServer();
  final ServletHolder servletHolder = new ServletHolder(notebookWsServer);
  servletHolder.setInitParameter("maxTextMessageSize", "1024000");

  final ServletContextHandler cxfContext = new ServletContextHandler(
      ServletContextHandler.SESSIONS);

  cxfContext.setSessionHandler(new SessionHandler());
  cxfContext.setContextPath(conf.getServerContextPath());
  cxfContext.addServlet(servletHolder, "/ws/*");
  cxfContext.addFilter(new FilterHolder(CorsFilter.class), "/*",
      EnumSet.allOf(DispatcherType.class));
  return cxfContext;
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:16,代码来源:ZeppelinServer.java

示例4: setupRestApiContextHandler

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private static ServletContextHandler setupRestApiContextHandler(ZeppelinConfiguration conf) {
  final ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
  cxfServletHolder.setInitParameter("javax.ws.rs.Application", ZeppelinServer.class.getName());
  cxfServletHolder.setName("rest");
  cxfServletHolder.setForcedPath("rest");

  final ServletContextHandler cxfContext = new ServletContextHandler();
  cxfContext.setSessionHandler(new SessionHandler());
  cxfContext.setContextPath(conf.getServerContextPath());
  cxfContext.addServlet(cxfServletHolder, "/api/*");

  cxfContext.addFilter(new FilterHolder(CorsFilter.class), "/*",
      EnumSet.allOf(DispatcherType.class));
  return cxfContext;
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:16,代码来源:ZeppelinServer.java

示例5: createStaticResourcesServer

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
protected Server createStaticResourcesServer(Server server, ServletContextHandler context, String home) throws Exception {

        context.setContextPath("/");

        SessionManager sm = new HashSessionManager();
        SessionHandler sh = new SessionHandler(sm);
        context.setSessionHandler(sh);

        if (home != null) {
            String[] resources = home.split(":");
            if (LOG.isDebugEnabled()) {
                LOG.debug(">>> Protocol found: " + resources[0] + ", and resource: " + resources[1]);
            }

            if (resources[0].equals("classpath")) {
                // Does not work when deployed as a bundle
                // context.setBaseResource(new JettyClassPathResource(getCamelContext().getClassResolver(), resources[1]));
                URL url = this.getCamelContext().getClassResolver().loadResourceAsURL(resources[1]);
                context.setBaseResource(Resource.newResource(url));
            } else if (resources[0].equals("file")) {
                context.setBaseResource(Resource.newResource(resources[1]));
            }
            DefaultServlet defaultServlet = new DefaultServlet();
            ServletHolder holder = new ServletHolder(defaultServlet);

            // avoid file locking on windows
            // http://stackoverflow.com/questions/184312/how-to-make-jetty-dynamically-load-static-pages
            holder.setInitParameter("useFileMappedBuffer", "false");
            context.addServlet(holder, "/");
        }

        server.setHandler(context);

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

示例6: start

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public void start() {
        System.setProperty("java.net.preferIPv4Stack", "true");//TODO optional?

        server = new org.eclipse.jetty.server.Server();
//        HashSessionIdManager sessionIdManager = new HashSessionIdManager();
//        server.setSessionIdManager(sessionIdManager);

        connector = new NetworkTrafficServerConnector(server);
        connector.setPort(httpPort);
        connector.setHost(host);
        server.addConnector(connector);


        ServletContextHandler contextHandler = new ServletContextHandler();
        SessionHandler sessionHandler = new SessionHandler();
//        HashSessionManager sessionManager = new HashSessionManager();
//        sessionManager.setMaxInactiveInterval(sessionTimeoutS);
//        sessionManager.setSessionCookie(sessionManager.getSessionCookie()+httpPort); //avoid session mix up for 2 server running as localhost
//        sessionHandler.setSessionManager(sessionManager);


        contextHandler.setSessionHandler(sessionHandler);
        contextHandler.addServlet(new ServletHolder(new ServletContainer(jerseySetup(restResource))), "/applicationServer/*");

        ErrorHandler errorHandler = new ErrorHandler();
        errorHandler.setShowStacks(true);
        contextHandler.setErrorHandler(errorHandler);

        GzipHandler gzipHandler = new GzipHandler();
//            HashSet<String> mimeTypes = new HashSet<>();
//            mimeTypes.add("text/html");
//            mimeTypes.add("text/plain");
//            mimeTypes.add("text/css");
//            mimeTypes.add("application/x-javascript");
//            mimeTypes.add("application/json");
        gzipHandler.setMinGzipSize(0);
//            gzipHandler.setMimeTypes(mimeTypes);

        HandlerCollection handlers = new HandlerCollection();
        handlers.setHandlers(new Handler[]{resourceHandler, contextHandler});
        gzipHandler.setHandler(handlers);
        server.setHandler(gzipHandler);

        try {
            server.start();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:50,代码来源:HttpServer.java

示例7: createServletForConnector

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
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,代码行数:42,代码来源:CometdComponent.java


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