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


Java HashSessionManager类代码示例

本文整理汇总了Java中org.eclipse.jetty.server.session.HashSessionManager的典型用法代码示例。如果您正苦于以下问题:Java HashSessionManager类的具体用法?Java HashSessionManager怎么用?Java HashSessionManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: run

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的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.setWelcomeFiles(new String[]{ "demo.html" });
       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);
       server.start();
       server.join();
}
 
开发者ID:punkbrwstr,项目名称:pinto,代码行数:20,代码来源:Demo.java

示例2: run

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的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

示例3: attachHandlers

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的package包/类
private ContextHandlerCollection attachHandlers(final File staticsFolder, final Module... overrides) {
    final MoodcatHandler moodcatHandler = new MoodcatHandler(this, staticsFolder, overrides);

    final ResourceHandler resources = new ResourceHandler();
    resources.setBaseResource(Resource.newResource(staticsFolder));
    resources.setDirectoriesListed(false);
    resources.setCacheControl("max-age=3600");

    final HashSessionManager hashSessionManager = new HashSessionManager();
    hashSessionManager.setMaxInactiveInterval(SESSION_KEEP_ALIVE);

    final ContextHandlerCollection handlers = new ContextHandlerCollection();
    // CHECKSTYLE:OFF
    handlers.addContext("/", "/").setHandler(resources);
    handlers.addContext("/", "/").setHandler(moodcatHandler);
    // CHECKSTYLE:ON

    return handlers;
}
 
开发者ID:MoodCat,项目名称:MoodCat.me-Core,代码行数:20,代码来源:App.java

示例4: build

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的package包/类
public SessionManager build() throws IOException {
	HashSessionManager manager = new HashSessionManager();
	manager.setSessionTrackingModes(ImmutableSet.of(SessionTrackingMode.COOKIE));
	manager.setHttpOnly(true);
	manager.getSessionCookieConfig().setHttpOnly(true);
	manager.setDeleteUnrestorableSessions(true);

	manager.setStoreDirectory(new File(getPath()));
	manager.getSessionCookieConfig().setMaxAge((int) cookieMaxAge.toSeconds());
	manager.setRefreshCookieAge((int) cookieRefreshAge.toSeconds());
	manager.setMaxInactiveInterval((int) maxInactiveInterval.toSeconds());
	manager.setIdleSavePeriod((int) idleSavePeriod.toSeconds());
	manager.setSavePeriod((int) savePeriod.toSeconds());
	manager.setScavengePeriod((int) scavengePeriod.toSeconds());
	return manager;
}
 
开发者ID:Athou,项目名称:commafeed,代码行数:17,代码来源:SessionManagerFactory.java

示例5: WebServer

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的package包/类
public WebServer(Config config, DataSource dataSource) {
    this.config = config;
    this.dataSource = dataSource;

    sessionManager = new HashSessionManager();
    int sessionTimeout = config.getInteger("web.sessionTimeout");
    if (sessionTimeout != 0) {
        sessionManager.setMaxInactiveInterval(sessionTimeout);
    }

    initServer();
    initApi();
    if (config.getBoolean("web.console")) {
        initConsole();
    }
    switch (config.getString("web.type", "new")) {
        case "old":
            initOldWebApp();
            break;
        default:
            initWebApp();
            break;
    }
    initClientProxy();
    server.setHandler(handlers);

    server.addBean(new ErrorHandler() {
        @Override
        protected void handleErrorPage(
                HttpServletRequest request, Writer writer, int code, String message) throws IOException {
            writer.write("<!DOCTYPE<html><head><title>Error</title></head><html><body>"
                    + code + " - " + HttpStatus.getMessage(code) + "</body></html>");
        }
    }, false);
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:36,代码来源:WebServer.java

示例6: configureSession

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的package包/类
private void configureSession(WebAppContext context) {
	SessionManager sessionManager = context.getSessionHandler().getSessionManager();
	int sessionTimeout = (getSessionTimeout() > 0 ? getSessionTimeout() : -1);
	sessionManager.setMaxInactiveInterval(sessionTimeout);
	if (isPersistSession()) {
		Assert.isInstanceOf(HashSessionManager.class, sessionManager,
				"Unable to use persistent sessions");
		configurePersistSession(sessionManager);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:JettyEmbeddedServletContainerFactory.java

示例7: configurePersistSession

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的package包/类
private void configurePersistSession(SessionManager sessionManager) {
	try {
		((HashSessionManager) sessionManager)
				.setStoreDirectory(getValidSessionStoreDir());
	}
	catch (IOException ex) {
		throw new IllegalStateException(ex);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:JettyEmbeddedServletContainerFactory.java

示例8: getServletContextHandler

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的package包/类
private static ServletContextHandler getServletContextHandler(AnnotationConfigWebApplicationContext context) throws IOException {
    ServletContextHandler contextHandler = new ServletContextHandler();
    WebConfigurer configurer = new WebConfigurer();
    configurer.setContext(context);
    contextHandler.addEventListener(configurer);

    // Create the SessionHandler (wrapper) to handle the sessions
    HashSessionManager manager = new HashSessionManager();
    SessionHandler sessions = new SessionHandler(manager);
    contextHandler.setHandler(sessions);

    return contextHandler;
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:14,代码来源:TestServerUtil.java

示例9: getServletContextHandler

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的package包/类
private static ServletContextHandler getServletContextHandler(AnnotationConfigWebApplicationContext context) throws IOException {
    ServletContextHandler contextHandler = new ServletContextHandler();
    JPAWebConfigurer configurer = new JPAWebConfigurer();
    configurer.setContext(context);
    contextHandler.addEventListener(configurer);

    // Create the SessionHandler (wrapper) to handle the sessions
    HashSessionManager manager = new HashSessionManager();
    SessionHandler sessions = new SessionHandler(manager);
    contextHandler.setHandler(sessions);

    return contextHandler;
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:14,代码来源:BaseJPARestTestCase.java

示例10: restoreSessions

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的package包/类
private void restoreSessions() {
  try {
    HashSessionManager hashSessionManager = (HashSessionManager) jettySessionManager;
    hashSessionManager.setStoreDirectory(FileUtils.createDirIfNotExists(sessionStoreDir,
        "Session persistence"));
    hashSessionManager.setSavePeriod(60);
    hashSessionManager.setMaxInactiveInterval(-1);
    hashSessionManager.restoreSessions();
  } catch (Exception e) {
    LOG.warning("Cannot restore sessions");
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:13,代码来源:ServerRpcProvider.java

示例11: provideSessionManager

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的package包/类
@Provides
@Singleton
public org.eclipse.jetty.server.SessionManager provideSessionManager(
    @Named(CoreSettings.SESSION_COOKIE_MAX_AGE) int sessionCookieMaxAge) {
  HashSessionManager sessionManager = new HashSessionManager();
  sessionManager.getSessionCookieConfig().setMaxAge(sessionCookieMaxAge);
  return sessionManager;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:9,代码来源:ServerModule.java

示例12: createStaticResourcesServer

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的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

示例13: run

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的package包/类
@Override
public void run(final Configuration configuration, final Environment environment) throws Exception {
    // FIXME: Doesn't scale to 1+ dynos
    final String githubHostname = optionalEnv("GITHUB_HOSTNAME").orElse("github.com");
    environment.servlets().setSessionHandler(new SessionHandler(new HashSessionManager()));
    environment.jersey().register(new Milestones(asList(env("REPOSITORIES").split(",")), githubHostname));
    environment.jersey().register(new OAuth(env("GITHUB_CLIENT_ID"), env("GITHUB_CLIENT_SECRET"), githubHostname));
    environment.jersey().register(new Github(githubHostname));
    environment.jersey().register(GithubExceptionMapper.class);
}
 
开发者ID:plan3,项目名称:stoneboard,代码行数:11,代码来源:Service.java

示例14: configure

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的package包/类
public static void configure(HashSessionManager sessionManager) {
    sessionManager.setHttpOnly(true);
    sessionManager.setSessionCookie("APPSESSIONID");
    try {
        Path dir = Files.createDirectories(Paths.get(System.getProperty("java.io.tmpdir"), "app-session-store"));
        sessionManager.setStoreDirectory(dir.toFile());
    } catch (IOException e) {
        logger.warn(e.getMessage(), e);
    }
}
 
开发者ID:wmluke,项目名称:pipes,代码行数:11,代码来源:SessionManagerConfig.java

示例15: configure

import org.eclipse.jetty.server.session.HashSessionManager; //导入依赖的package包/类
@Override
public void configure(ConfigurableApp<Pipes> app) {
    app.configure(SessionManager.class, HashSessionManager::new, SessionManagerConfig::configure);
    app.configure(ObjectMapper.class, JacksonJsonConfig::configure);
    app.configure((LoggerContext) LoggerFactory.getILoggerFactory(), LogbackConfig::configure);
    app.configure(org.hibernate.cfg.Configuration.class, HibernateConfig::configure);
}
 
开发者ID:wmluke,项目名称:pipes,代码行数:8,代码来源:ExampleApp.java


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