Java Code Examples for org.eclipse.jetty.server.Server#setSessionIdManager()
The following examples show how to use
org.eclipse.jetty.server.Server#setSessionIdManager() .
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: TestServerUtil.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
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); }
Example 2
Source File: BaseJPARestTestCase.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
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); } }
Example 3
Source File: TestServerUtil.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
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); }
Example 4
Source File: ServerCmdlet.java From HongsCORE with MIT License | 6 votes |
@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 5
Source File: TestServerUtil.java From flowable-engine with Apache License 2.0 | 6 votes |
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); }
Example 6
Source File: TestServerUtil.java From flowable-engine with Apache License 2.0 | 6 votes |
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); }
Example 7
Source File: TestServerUtil.java From flowable-engine with Apache License 2.0 | 6 votes |
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); }
Example 8
Source File: TestServerUtil.java From flowable-engine with Apache License 2.0 | 6 votes |
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); }
Example 9
Source File: TestServerUtil.java From flowable-engine with Apache License 2.0 | 6 votes |
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); }
Example 10
Source File: TestServerUtil.java From flowable-engine with Apache License 2.0 | 6 votes |
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); }
Example 11
Source File: JettyWebappTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@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 12
Source File: JettyLauncher.java From GeoTriples with Apache License 2.0 | 5 votes |
/** * 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); } }
Example 13
Source File: JettyServiceBuilder.java From armeria with Apache License 2.0 | 4 votes |
/** * 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); }
Example 14
Source File: WebContainerStartup.java From consulo with Apache License 2.0 | 3 votes |
@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(); } }