org.eclipse.jetty.server.Server#setSessionIdManager ( )源码实例Demo

下面列出了org.eclipse.jetty.server.Server#setSessionIdManager ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: activiti6-boot2   文件: TestServerUtil.java
public static TestServer createAndStartServer(Class<?>... configClasses) {
  int port = NEXT_PORT.incrementAndGet();
  Server server = new Server(port);

  HashSessionIdManager idmanager = new HashSessionIdManager();
  server.setSessionIdManager(idmanager);

  AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
  applicationContext.register(configClasses);
  applicationContext.refresh();

  try {
    server.setHandler(getServletContextHandler(applicationContext));
    server.start();
  } catch (Exception e) {
    log.error("Error starting server", e);
  }

  return new TestServer(server, applicationContext, port);
}
 
源代码2 项目: activiti6-boot2   文件: BaseJPARestTestCase.java
public static void createAndStartServer() {
  server = new Server(HTTP_SERVER_PORT);

  HashSessionIdManager idmanager = new HashSessionIdManager();
  server.setSessionIdManager(idmanager);

  AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
  applicationContext.register(JPAApplicationConfiguration.class);
  applicationContext.refresh();

  appContext = applicationContext;

  try {
    server.setHandler(getServletContextHandler(applicationContext));
    server.start();
  } catch (Exception e) {
    log.error("Error starting server", e);
  }
}
 
源代码3 项目: activiti6-boot2   文件: TestServerUtil.java
public static TestServer createAndStartServer(Class<?> ... configClasses) {
	int port= NEXT_PORT.incrementAndGet();
  Server server = new Server(port);

  HashSessionIdManager idmanager = new HashSessionIdManager();
  server.setSessionIdManager(idmanager);
  
  AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
  applicationContext.register(configClasses);
  applicationContext.refresh();
    
  try {
    server.setHandler(getServletContextHandler(applicationContext));
    server.start();
  } catch (Exception e) {
    log.error("Error starting server", e);
  }
  
  return new TestServer(server, applicationContext, port);
}
 
源代码4 项目: HongsCORE   文件: ServerCmdlet.java
@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);
}
 
源代码5 项目: flowable-engine   文件: TestServerUtil.java
public static TestServer createAndStartServer(Class<?>... configClasses) {
    int port = NEXT_PORT.incrementAndGet();
    Server server = new Server(port);

    HashSessionIdManager idmanager = new HashSessionIdManager();
    server.setSessionIdManager(idmanager);

    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.register(configClasses);
    applicationContext.refresh();

    try {
        server.setHandler(getServletContextHandler(applicationContext));
        server.start();
    } catch (Exception e) {
        LOGGER.error("Error starting server", e);
    }

    return new TestServer(server, applicationContext, port);
}
 
源代码6 项目: flowable-engine   文件: TestServerUtil.java
public static TestServer createAndStartServer(Class<?>... configClasses) {
    int port = NEXT_PORT.incrementAndGet();
    Server server = new Server(port);

    HashSessionIdManager idmanager = new HashSessionIdManager();
    server.setSessionIdManager(idmanager);

    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.register(configClasses);
    applicationContext.refresh();

    try {
        server.setHandler(getServletContextHandler(applicationContext));
        server.start();
    } catch (Exception e) {
        LOGGER.error("Error starting server", e);
    }

    return new TestServer(server, applicationContext, port);
}
 
源代码7 项目: flowable-engine   文件: TestServerUtil.java
public static TestServer createAndStartServer(Class<?>... configClasses) {
    int port = NEXT_PORT.incrementAndGet();
    Server server = new Server(port);

    HashSessionIdManager idmanager = new HashSessionIdManager();
    server.setSessionIdManager(idmanager);

    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.register(configClasses);
    applicationContext.refresh();

    try {
        server.setHandler(getServletContextHandler(applicationContext));
        server.start();
    } catch (Exception e) {
        LOGGER.error("Error starting server", e);
    }

    return new TestServer(server, applicationContext, port);
}
 
源代码8 项目: flowable-engine   文件: TestServerUtil.java
public static TestServer createAndStartServer(Class<?>... configClasses) {
    int port = NEXT_PORT.incrementAndGet();
    Server server = new Server(port);

    HashSessionIdManager idmanager = new HashSessionIdManager();
    server.setSessionIdManager(idmanager);

    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.register(configClasses);
    applicationContext.refresh();

    try {
        server.setHandler(getServletContextHandler(applicationContext));
        server.start();
    } catch (Exception e) {
        LOGGER.error("Error starting server", e);
    }

    return new TestServer(server, applicationContext, port);
}
 
源代码9 项目: flowable-engine   文件: TestServerUtil.java
public static TestServer createAndStartServer(Class<?>... configClasses) {
    int port = NEXT_PORT.incrementAndGet();
    Server server = new Server(port);

    HashSessionIdManager idmanager = new HashSessionIdManager();
    server.setSessionIdManager(idmanager);

    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.register(configClasses);
    applicationContext.refresh();

    try {
        server.setHandler(getServletContextHandler(applicationContext));
        server.start();
    } catch (Exception e) {
        LOGGER.error("Error starting server", e);
    }

    return new TestServer(server, applicationContext, port);
}
 
源代码10 项目: flowable-engine   文件: TestServerUtil.java
public static TestServer createAndStartServer(Class<?>... configClasses) {
    int port = NEXT_PORT.incrementAndGet();
    Server server = new Server(port);

    HashSessionIdManager idmanager = new HashSessionIdManager();
    server.setSessionIdManager(idmanager);

    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.register(configClasses);
    applicationContext.refresh();

    try {
        server.setHandler(getServletContextHandler(applicationContext));
        server.start();
    } catch (Exception e) {
        LOGGER.error("Error starting server", e);
    }

    return new TestServer(server, applicationContext, port);
}
 
源代码11 项目: lucene-solr   文件: JettyWebappTest.java
@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();
}
 
源代码12 项目: GeoTriples   文件: JettyLauncher.java
/**
 * Starts a Jetty server with D2R Server as root webapp.
 * 
 * @return <code>true</code> on success, <code>false</code> if webapp init failed 
 */
public boolean start() {
	Server jetty = new Server(port);

	// use Random (/dev/urandom) instead of SecureRandom to generate session keys - otherwise Jetty may hang during startup waiting for enough entropy
	// see http://jira.codehaus.org/browse/JETTY-331 and http://docs.codehaus.org/display/JETTY/Connectors+slow+to+startup
	jetty.setSessionIdManager(new HashSessionIdManager(new Random()));
	WebAppContext context = new WebAppContext(jetty, "webapp", "");

	// Wave a chicken at Jetty to make some annoying System.err.println noise go away
	context.getSecurityHandler().setIdentityService(new DefaultIdentityService());
	context.getSecurityHandler().setAuthenticator(null);
	context.getSecurityHandler().setAuthenticatorFactory(null);
	
	// Place the system loader into the servlet context. The webapp init
	// listener will find it there and create the D2RServer instance.
	D2RServer.storeSystemLoader(loader, context.getServletContext());
	try {
		jetty.start();
		D2RServer server = D2RServer.fromServletContext(context.getServletContext());
		if (server == null || server.errorOnStartup()) {
			jetty.stop();
			log.warn("[[[ Server startup failed, see messages above ]]]");
			return false;
		}
		log.info("[[[ Server started at " + loader.getSystemBaseURI() + " ]]]");
		return true;
	} catch (Exception ex) {
		throw new RuntimeException(ex);
	}
}
 
源代码13 项目: armeria   文件: JettyServiceBuilder.java
/**
 * Returns a newly-created {@link JettyService} based on the properties of this builder.
 */
public JettyService build() {
    final JettyServiceConfig config = new JettyServiceConfig(
            hostname, dumpAfterStart, dumpBeforeStop, stopTimeoutMillis, handler, requestLog,
            sessionIdManagerFactory, attrs, beans, handlerWrappers, eventListeners, lifeCycleListeners,
            configurators);

    final Function<ScheduledExecutorService, Server> serverFactory = blockingTaskExecutor -> {
        final Server server = new Server(new ArmeriaThreadPool(blockingTaskExecutor));

        if (config.dumpAfterStart() != null) {
            server.setDumpAfterStart(config.dumpAfterStart());
        }
        if (config.dumpBeforeStop() != null) {
            server.setDumpBeforeStop(config.dumpBeforeStop());
        }
        if (config.stopTimeoutMillis() != null) {
            server.setStopTimeout(config.stopTimeoutMillis());
        }

        if (config.handler() != null) {
            server.setHandler(config.handler());
        }
        if (config.requestLog() != null) {
            server.setRequestLog(requestLog);
        }
        if (config.sessionIdManagerFactory() != null) {
            server.setSessionIdManager(config.sessionIdManagerFactory().apply(server));
        }

        config.handlerWrappers().forEach(server::insertHandler);
        config.attrs().forEach(server::setAttribute);
        config.beans().forEach(bean -> {
            final Boolean managed = bean.isManaged();
            if (managed == null) {
                server.addBean(bean.bean());
            } else {
                server.addBean(bean.bean(), managed);
            }
        });

        config.eventListeners().forEach(server::addEventListener);
        config.lifeCycleListeners().forEach(server::addLifeCycleListener);

        config.configurators().forEach(c -> c.accept(server));

        return server;
    };

    final Consumer<Server> postStopTask = server -> {
        try {
            JettyService.logger.info("Destroying an embedded Jetty: {}", server);
            server.destroy();
        } catch (Exception e) {
            JettyService.logger.warn("Failed to destroy an embedded Jetty: {}", server, e);
        }
    };

    return new JettyService(config.hostname(), serverFactory, postStopTask);
}
 
源代码14 项目: consulo   文件: WebContainerStartup.java
@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();
  }
}