Class ServletModule

  • All Implemented Interfaces:
    com.google.inject.Module

    public class ServletModule
    extends Object
    implements com.google.inject.Module
    Servlet Guice Scopes, ContextTrackers and some helper methods. A single app-wide instance is created at app startup: GuiceServletContextListener.servletModule
    • Field Detail

      • httpSessionScope

        public final com.google.inject.Scope httpSessionScope
        Scopes bindings to a given HttpSession. Available both to servlets and websocket endpoints.

        NOTE: there's no way to create an HttpSession< from the websocket endpoint layer if it does not exist yet. To safely use this scope in websocket endpoints, other layers must ensure that a session exists (for example a Filter targeting URL patterns of websockets can be used).

      • websocketConnectionScope

        public final com.google.inject.Scope websocketConnectionScope
        Scopes bindings to a given WebsocketConnectionContext.
      • trackers

        public final pl.morgwai.base.guice.scopes.ContextTracker<?>[] trackers
    • Constructor Detail

      • ServletModule

        public ServletModule()
    • Method Detail

      • configure

        public void configure​(com.google.inject.Binder binder)
        Binds requestContextTracker and websocketConnectionContextTracker and corresponding contexts for injection. Binds ContextTracker<?>[] to instance containing all trackers for use with ContextTrackingExecutor.getActiveContexts(ContextTracker...).
        Specified by:
        configure in interface com.google.inject.Module
      • newContextTrackingExecutor

        public pl.morgwai.base.guice.scopes.ContextTrackingExecutor newContextTrackingExecutor​(String name,
                                                                                               int poolSize)
        Convenience "constructor" for ContextTrackingExecutor. (I really miss method extensions in Java)
      • newContextTrackingExecutor

        public pl.morgwai.base.guice.scopes.ContextTrackingExecutor newContextTrackingExecutor​(String name,
                                                                                               int poolSize,
                                                                                               BlockingQueue<Runnable> workQueue)
        Convenience "constructor" for ContextTrackingExecutor.
      • newContextTrackingExecutor

        public pl.morgwai.base.guice.scopes.ContextTrackingExecutor newContextTrackingExecutor​(String name,
                                                                                               int corePoolSize,
                                                                                               int maximumPoolSize,
                                                                                               long keepAliveTime,
                                                                                               TimeUnit unit,
                                                                                               BlockingQueue<Runnable> workQueue,
                                                                                               ThreadFactory threadFactory,
                                                                                               RejectedExecutionHandler handler,
                                                                                               pl.morgwai.base.guice.scopes.ContextTracker<?>... trackers)
        Convenience "constructor" for ContextTrackingExecutor.