org.eclipse.jetty.server.session.DefaultSessionIdManager Java Examples

The following examples show how to use org.eclipse.jetty.server.session.DefaultSessionIdManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServerCmdlet.java    From HongsCORE with MIT License 6 votes vote down vote up
@Override
public void init(ServletContextHandler sc) {
    CoreConfig  cc = CoreConfig.getInstance("defines");
    String dh = cc.getProperty("jetty.session.manager.db", "default");

    Server                  sv = sc . getServer             (  );
    DefaultSessionIdManager im = new DefaultSessionIdManager(sv);
    im.setWorkerName       (Core.SERVER_ID);
    sv.setSessionIdManager (im);

    SessionHandler          sh = sc . getSessionHandler  (  );
    DefaultSessionCache     ch = new DefaultSessionCache (sh);
    JDBCSessionDataStore    sd = new JDBCSessionDataStore(  );
    sd.setDatabaseAdaptor  (getAdaptor(dh));
    ch.setSessionDataStore (sd);
    sh.setSessionCache     (ch);
    sc.setSessionHandler   (sh);
}
 
Example #2
Source File: JettyWebappTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception
{
  super.setUp();
  System.setProperty("solr.solr.home", SolrJettyTestBase.legacyExampleCollection1SolrHome());
  System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));
  System.setProperty("solr.tests.doContainerStreamCloseAssert", "false");

  File dataDir = createTempDir().toFile();
  dataDir.mkdirs();

  System.setProperty("solr.data.dir", dataDir.getCanonicalPath());
  String path = ExternalPaths.WEBAPP_HOME;

  server = new Server(port);
  // insecure: only use for tests!!!!
  server.setSessionIdManager(new DefaultSessionIdManager(server, new Random(random().nextLong())));
  new WebAppContext(server, path, context );

  ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory());
  connector.setIdleTimeout(1000 * 60 * 60);
  connector.setPort(0);
  server.setConnectors(new Connector[]{connector});
  server.setStopAtShutdown( true );

  server.start();
  port = connector.getLocalPort();
}
 
Example #3
Source File: PHttpServer.java    From jphp with Apache License 2.0 5 votes vote down vote up
private void initSessionManager() {
    idmanager = new DefaultSessionIdManager(server);
    server.setSessionIdManager(idmanager);

    SessionHandler sessions = new SessionHandler();
    sessions.setSessionIdManager(idmanager);
    filters.addHandler(sessions);
}
 
Example #4
Source File: WebContainerStartup.java    From consulo with Apache License 2.0 3 votes vote down vote up
@Override
public void run(@Nonnull Map<String, Object> map) {
  StatCollector stat = (StatCollector)map.get(ContainerStartup.STAT_COLLECTOR);
  String[] args = (String[])map.get(ContainerStartup.ARGS);

  StartupUtil.initializeLogger();

  ServletHandler handler = new ServletHandler();

  Server server = new Server(8080);

  DefaultSessionIdManager idmanager = new DefaultSessionIdManager(server);

  server.setSessionIdManager(idmanager);

  SessionHandler sessionHandler = new SessionHandler();
  sessionHandler.setSessionIdManager(idmanager);

  handler.setHandler(sessionHandler);
  
  server.setHandler(handler);

  registerServlets(handler);

  try {
    server.start();

    new Thread(() -> startApplication(stat, args), "Consulo App Start").start();
  }
  catch (Exception e) {
    e.printStackTrace();
  }
}