Search in sources :

Example 61 with SessionHandler

use of org.eclipse.jetty.server.session.SessionHandler in project textdb by TextDB.

the class TexeraWebApplication method run.

@Override
public void run(TexeraWebConfiguration texeraWebConfiguration, Environment environment) throws Exception {
    // serve backend at /api
    environment.jersey().setUrlPattern("/api/*");
    // redirect all 404 to index page, according to Angular routing requirements
    ErrorPageErrorHandler eph = new ErrorPageErrorHandler();
    eph.addErrorPage(404, "/");
    environment.getApplicationContext().setErrorHandler(eph);
    final QueryPlanResource newQueryPlanResource = new QueryPlanResource();
    environment.jersey().register(newQueryPlanResource);
    // Creates an instance of the PlanStoreResource class to register with Jersey
    final PlanStoreResource planStoreResource = new PlanStoreResource();
    // Registers the PlanStoreResource with Jersey
    environment.jersey().register(planStoreResource);
    final DownloadFileResource downloadFileResource = new DownloadFileResource();
    environment.jersey().register(downloadFileResource);
    // Creates an instance of the HealthCheck and registers it with the environment
    final SampleHealthCheck sampleHealthCheck = new SampleHealthCheck();
    // Registering the SampleHealthCheck with the environment
    environment.healthChecks().register("sample", sampleHealthCheck);
    // Creates an instance of the InitSystemResource class to register with Jersey
    final SystemResource systemResource = new SystemResource();
    // Registers the systemResource with Jersey
    environment.jersey().register(systemResource);
    environment.jersey().register(SessionHandler.class);
    environment.servlets().setSessionHandler(new SessionHandler());
    final UserResource userResource = new UserResource();
    environment.jersey().register(userResource);
    final UserFileResource userFileResource = new UserFileResource();
    environment.jersey().register(userFileResource);
    final KeywordDictionaryResource keywordDictionaryResource = new KeywordDictionaryResource();
    environment.jersey().register(keywordDictionaryResource);
    final WorkflowResource workflowResource = new WorkflowResource();
    environment.jersey().register(workflowResource);
    // Registers MultiPartFeature to support file upload
    environment.jersey().register(MultiPartFeature.class);
    // Configuring the object mapper used by Dropwizard
    environment.getObjectMapper().configure(MapperFeature.USE_GETTERS_AS_SETTERS, false);
    environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) ErrorPageErrorHandler(org.eclipse.jetty.servlet.ErrorPageErrorHandler) SampleHealthCheck(edu.uci.ics.texera.web.healthcheck.SampleHealthCheck)

Example 62 with SessionHandler

use of org.eclipse.jetty.server.session.SessionHandler in project jphp by jphp-compiler.

the class PHttpServer method initSessionManager.

private void initSessionManager() {
    idmanager = new DefaultSessionIdManager(server);
    server.setSessionIdManager(idmanager);
    SessionHandler sessions = new SessionHandler();
    sessions.setSessionIdManager(idmanager);
    filters.addHandler(sessions);
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) DefaultSessionIdManager(org.eclipse.jetty.server.session.DefaultSessionIdManager)

Example 63 with SessionHandler

use of org.eclipse.jetty.server.session.SessionHandler in project NMEAParser by tvesalainen.

the class CommandLine method start.

private void start() throws IOException, InterruptedException, JAXBException, Exception {
    config("starting NMEA Server");
    Path configfile = getArgument("configuration file");
    Config config = new Config(configfile);
    String address = config.getNmeaMulticastAddress();
    int nmeaPort = config.getNmeaMulticastPort();
    int httpPort = config.getHttpPort();
    config("NMEA Multicast Address=%s", address);
    config("NMEA Multicast Port=%s", nmeaPort);
    config("HTTP Port=%s", httpPort);
    CachedScheduledThreadPool executor = new CachedScheduledThreadPool(64);
    config("ThreadPool started %s", executor);
    NMEAService nmeaService = new NMEAService(address, nmeaPort, executor);
    PropertyServer propertyServer = new PropertyServer(Clock.systemDefaultZone(), config, executor);
    nmeaService.addNMEAObserver(propertyServer);
    nmeaService.start();
    config("NMEA Service started");
    JavaUtilLog log = new JavaUtilLog();
    // make jetty use java.util.logger
    Log.setLog(log);
    Server server = new Server(httpPort);
    HandlerList handlers = new HandlerList();
    ServletContextHandler context = new ServletContextHandler();
    context.addServlet(ResourceServlet.class, "/");
    ServletHolder holder = new ServletHolder(SseServlet.class);
    holder.setAsyncSupported(true);
    context.addServlet(holder, "/sse");
    context.addServlet(ResourceServlet.class, "*.js");
    context.addServlet(ResourceServlet.class, "*.css");
    context.addServlet(ResourceServlet.class, "*.gif");
    context.addServlet(ResourceServlet.class, "*.png");
    context.addServlet(ResourceServlet.class, "*.ico");
    context.addServlet(PrefsServlet.class, "/prefs");
    context.addServlet(I18nServlet.class, "/i18n");
    SessionHandler sessionHandler = new SessionHandler();
    context.setSessionHandler(sessionHandler);
    handlers.addHandler(context);
    server.setHandler(handlers);
    server.setSessionIdManager(new DefaultSessionIdManager(server));
    ServletContext servletContext = context.getServletContext().getContext("/sse");
    servletContext.setAttribute(PropertyServer.class.getName(), propertyServer);
    server.start();
    executor.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
}
Also used : Path(java.nio.file.Path) HandlerList(org.eclipse.jetty.server.handler.HandlerList) SessionHandler(org.eclipse.jetty.server.session.SessionHandler) DefaultSessionIdManager(org.eclipse.jetty.server.session.DefaultSessionIdManager) Server(org.eclipse.jetty.server.Server) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) CachedScheduledThreadPool(org.vesalainen.util.concurrent.CachedScheduledThreadPool) JavaUtilLog(org.eclipse.jetty.util.log.JavaUtilLog) ServletContext(javax.servlet.ServletContext) NMEAService(org.vesalainen.parsers.nmea.NMEAService) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 64 with SessionHandler

use of org.eclipse.jetty.server.session.SessionHandler in project dropwizard-shiro by silb.

the class ApiApplication method run.

@Override
public void run(ApiConfiguration configuration, Environment environment) throws Exception {
    environment.jersey().register(new UserFactory());
    environment.jersey().register(new ShiroExceptionMapper());
    environment.getApplicationContext().setSessionHandler(new SessionHandler());
    for (Object resource : IntegrationTestApplication.createAllIntegrationTestResources()) {
        environment.jersey().register(resource);
    }
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) ShiroExceptionMapper(org.secnod.shiro.jaxrs.ShiroExceptionMapper) UserFactory(org.secnod.example.webapp.UserFactory)

Example 65 with SessionHandler

use of org.eclipse.jetty.server.session.SessionHandler in project dropwizard by dropwizard.

the class ServletEnvironmentTest method setsSessionHandlers.

@Test
void setsSessionHandlers() {
    final SessionHandler sessionHandler = new SessionHandler();
    environment.setSessionHandler(sessionHandler);
    assertThat(handler.getSessionHandler()).isEqualTo(sessionHandler);
    assertThat(handler.isSessionsEnabled()).isTrue();
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) Test(org.junit.jupiter.api.Test)

Aggregations

SessionHandler (org.eclipse.jetty.server.session.SessionHandler)70 Server (org.eclipse.jetty.server.Server)18 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)17 ContextHandler (org.eclipse.jetty.server.handler.ContextHandler)13 IOException (java.io.IOException)10 Test (org.junit.Test)9 ServletException (javax.servlet.ServletException)8 HttpSession (javax.servlet.http.HttpSession)8 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)8 HashSessionManager (org.eclipse.jetty.server.session.HashSessionManager)6 File (java.io.File)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 Handler (org.eclipse.jetty.server.Handler)5 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)5 ArrayList (java.util.ArrayList)4 SessionCookieConfig (javax.servlet.SessionCookieConfig)4 HttpSessionEvent (javax.servlet.http.HttpSessionEvent)4 HttpSessionListener (javax.servlet.http.HttpSessionListener)4 ConstraintSecurityHandler (org.eclipse.jetty.security.ConstraintSecurityHandler)4