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


Java SessionManager类代码示例

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


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

示例1: invalidateAll

import org.eclipse.jetty.server.SessionManager; //导入依赖的package包/类
public void invalidateAll(String sessionId) {
    synchronized (sessionsIds) {
        sessionsIds.remove(sessionId);

        //tell all contexts that may have a session object with this id to
        //get rid of them
        Handler[] contexts = server.getChildHandlersByClass(ContextHandler.class);
        for (int i = 0; contexts != null && i < contexts.length; i++) {
            SessionHandler sessionHandler = ((ContextHandler) contexts[i]).getChildHandlerByClass(SessionHandler.class);
            if (sessionHandler != null) {
                SessionManager manager = sessionHandler.getSessionManager();
                if (manager != null && manager instanceof HazelcastSessionManager) {
                    ((HazelcastSessionManager) manager).invalidateSession(sessionId);
                }
            }
        }
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-jetty-sessionmanager,代码行数:19,代码来源:HazelcastSessionIdManager.java

示例2: renewSessionId

import org.eclipse.jetty.server.SessionManager; //导入依赖的package包/类
@Override
public void renewSessionId(String oldClusterId, String oldNodeId, HttpServletRequest request) {
    //generate a new id
    String newClusterId = newSessionId(request.hashCode());

    synchronized (sessionsIds) {
        //remove the old one from the list
        sessionsIds.remove(oldClusterId);
        //add in the new session id to the list
        sessionsIds.add(newClusterId);

        //tell all contexts to update the id
        Handler[] contexts = server.getChildHandlersByClass(ContextHandler.class);
        for (int i = 0; contexts != null && i < contexts.length; i++) {
            SessionHandler sessionHandler = ((ContextHandler) contexts[i]).getChildHandlerByClass(SessionHandler.class);
            if (sessionHandler != null) {
                SessionManager manager = sessionHandler.getSessionManager();

                if (manager != null && manager instanceof HazelcastSessionManager) {
                    ((HazelcastSessionManager) manager).
                            renewSessionId(oldClusterId, oldNodeId, newClusterId, getNodeId(newClusterId, request));
                }
            }
        }
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-jetty-sessionmanager,代码行数:27,代码来源:HazelcastSessionIdManager.java

示例3: invalidateAll

import org.eclipse.jetty.server.SessionManager; //导入依赖的package包/类
@Override
public void invalidateAll(String sessionId) {
    synchronized (sessionsIds) {
        sessionsIds.remove(sessionId);

        //tell all contexts that may have a session object with this id to
        //get rid of them
        Handler[] contexts = server.getChildHandlersByClass(ContextHandler.class);
        for (int i = 0; contexts != null && i < contexts.length; i++) {
            SessionHandler sessionHandler = ((ContextHandler) contexts[i]).getChildHandlerByClass(SessionHandler.class);
            if (sessionHandler != null) {
                SessionManager manager = sessionHandler.getSessionManager();
                if (manager != null && manager instanceof HazelcastSessionManager) {
                    ((HazelcastSessionManager) manager).invalidateSession(sessionId);
                }
            }
        }
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-jetty-sessionmanager,代码行数:20,代码来源:HazelcastSessionIdManager.java

示例4: listen

import org.eclipse.jetty.server.SessionManager; //导入依赖的package包/类
@Override
public HttpServer listen(int port) throws Exception {

    SessionHandler sessionHandler = new SessionHandler(app.configuration(SessionManager.class));
    sessionHandler.setHandler(new MiddlewareHandler(app));

    ContextHandler context = new ContextHandler();
    context.setContextPath("/");
    context.setResourceBase(".");
    context.setClassLoader(Thread.currentThread().getContextClassLoader());
    context.setHandler(sessionHandler);

    Server server = new Server(port);

    server.setSessionIdManager(new HashSessionIdManager());
    server.setHandler(context);

    server.start();
    server.join();

    return this;
}
 
开发者ID:wmluke,项目名称:pipes,代码行数:23,代码来源:JettyHttpServer.java

示例5: build

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

示例6: configureSession

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

import org.eclipse.jetty.server.SessionManager; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	new Thread(new Crawler()).start();// hourly
	JodelWebConfiguration conf;
	
	
	if (args.length != 1) {
		InputStream ins;
		File confFile = new File("conf/jodel.properties");
		if (confFile.exists()) {
			ins = new FileInputStream(confFile);
		} else {
			ins = Launcher.class.getResourceAsStream("jodel.properties");
		}
		conf = new JodelWebConfiguration(ins);
	} else {
		conf = new JodelWebConfiguration(new FileInputStream(new File(
				args[0])));
	}
	DatabaseConnection.init(conf);
	Server s = new Server(new InetSocketAddress(conf.getHostName(),
			conf.getPort()));
	((QueuedThreadPool) s.getThreadPool()).setMaxThreads(20);
	ServletContextHandler h = new ServletContextHandler(
			ServletContextHandler.SESSIONS);
	h.setInitParameter(SessionManager.__SessionCookieProperty, "Jodel-Session");
	h.addServlet(JodelWeb.class, "/*");
	HandlerList hl = new HandlerList();
	hl.setHandlers(new Handler[] { generateStaticContext(), h });
	s.setHandler(hl);
	s.start();
}
 
开发者ID:JodelTwitterBot,项目名称:JodelWeb,代码行数:32,代码来源:Launcher.java

示例9: createStaticResourcesServer

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

示例10: forEachSessionManager

import org.eclipse.jetty.server.SessionManager; //导入依赖的package包/类
private void forEachSessionManager(final SessionManagerCallback callback) {
    Handler[] contexts = server.getChildHandlersByClass(ContextHandler.class);
    for (int i = 0; contexts != null && i < contexts.length; i++) {
        final SessionHandler sessionHandler = ((ContextHandler) contexts[i]).getChildHandlerByClass(SessionHandler.class);
        if (sessionHandler != null) {
            final SessionManager manager = sessionHandler.getSessionManager();
            if (manager != null && manager instanceof AbstractSessionManager) {
                callback.execute((AbstractSessionManager) manager);
            }
        }
    }
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:13,代码来源:AbstractSessionIdManager.java

示例11: setSecureCookies

import org.eclipse.jetty.server.SessionManager; //导入依赖的package包/类
/**
 * Set the secure cookies setting on the jetty session manager.
 */
protected void setSecureCookies() {

  SessionManager sessionManager = webapp.getSessionHandler().getSessionManager();
  if (!(sessionManager instanceof AbstractSessionManager)) {
    throw new RuntimeException("Cannot set secure cookies on session manager.");
  }

  AbstractSessionManager abstractSessionManager = (AbstractSessionManager) sessionManager;

  abstractSessionManager.getSessionCookieConfig().setSecure(isSecureCookies());
  abstractSessionManager.setHttpOnly(true);
}
 
开发者ID:avaje-common,项目名称:avaje-jetty-runner,代码行数:16,代码来源:BaseRunner.java

示例12: configure

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

示例13: setSessionConfig

import org.eclipse.jetty.server.SessionManager; //导入依赖的package包/类
@Override
public void setSessionConfig() {
    SessionManager sessionManager = webAppContext.getSessionHandler().getSessionManager();
    SessionCookieConfig sessionCookieConfig = sessionManager.getSessionCookieConfig();
    sessionCookieConfig.setHttpOnly(true);
    sessionCookieConfig.setSecure(systemEnvironment.isSessionCookieSecure());
    sessionCookieConfig.setMaxAge(systemEnvironment.sessionCookieMaxAgeInSeconds());
    sessionManager.setMaxInactiveInterval(systemEnvironment.sessionTimeoutInSeconds());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:10,代码来源:Jetty9Server.java

示例14: main

import org.eclipse.jetty.server.SessionManager; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	
	LiteWaveWebConfigurator conf;
	if (args.length != 1) {
		InputStream ins;
		File confFile = new File("conf/litewave.properties");

		ins = new FileInputStream(confFile);
		conf = new LiteWaveWebConfigurator(ins);
	} else {
		conf = new LiteWaveWebConfigurator(new FileInputStream(new File(
				args[0])));
	}
	

	DatabaseConnection.init(conf);
	
	Server s = new Server(new InetSocketAddress(conf.getHostName(),
			conf.getPort()));
	System.out.println("start Server");
	((QueuedThreadPool) s.getThreadPool()).setMaxThreads(20);
	ServletContextHandler h = new ServletContextHandler(
			ServletContextHandler.SESSIONS);
	h.setInitParameter(SessionManager.__SessionCookieProperty, "DB-Session");
	h.addServlet(LiteWaveMain.class, "/*");
	HandlerList hl = new HandlerList();
	hl.setHandlers(new Handler[] { generateStaticContext(), h });
	s.setHandler(hl);
	s.start();
	
	//For intel systems (OmniDriver Initialization
	/*
	
	ExecutorService executor = Executors.newSingleThreadExecutor();
	try {
		executor.submit(new InitSpectrometer()).get(1800, TimeUnit.SECONDS);
	} catch (InterruptedException | ExecutionException | TimeoutException e1) {
		System.out.println("Timeout: USB driver not Initialized");
		e1.printStackTrace();
	} // Timeout of 10 minutes.
	executor.shutdown(); */
	
}
 
开发者ID:LiteWaveLabs,项目名称:LiteWaveWeb,代码行数:44,代码来源:Launcher.java

示例15: AbstractApp

import org.eclipse.jetty.server.SessionManager; //导入依赖的package包/类
public AbstractApp() {
    configs.put(getKey(SessionManager.class, null), new HashSessionManager());
    configs.put(getKey(ObjectMapper.class, null), configureObjectMapper(new ObjectMapper()));
    configs.put(getKey(ObjectMapper.class, XML_MAPPER_NAME), configureObjectMapper(new ObjectMapper()));
}
 
开发者ID:wmluke,项目名称:pipes,代码行数:6,代码来源:AbstractApp.java


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