Package pl.morgwai.base.servlet.scopes
Class ServletModule
- java.lang.Object
-
- pl.morgwai.base.servlet.scopes.ServletModule
-
- All Implemented Interfaces:
com.google.inject.Module
public class ServletModule extends Object implements com.google.inject.Module
Servlet GuiceScope
s,ContextTracker
s and some helper methods. A single app-wide instance is created at app startup:GuiceServletContextListener.servletModule
-
-
Field Summary
Fields Modifier and Type Field Description com.google.inject.Scope
httpSessionScope
Scopes bindings to a givenHttpSession
.pl.morgwai.base.guice.scopes.ContextTracker<RequestContext>
requestContextTracker
Allows tracking ofServletRequestContext
s andWebsocketEventContext
s.com.google.inject.Scope
requestScope
Scopes bindings to either aServletRequestContext
or aWebsocketEventContext
(Objects bound to this scope can be obtained both in servlets and endpoints).pl.morgwai.base.guice.scopes.ContextTracker<?>[]
trackers
pl.morgwai.base.guice.scopes.ContextTracker<WebsocketConnectionContext>
websocketConnectionContextTracker
Allows tracking of thecontext of a given websocket connection (
.Session
)com.google.inject.Scope
websocketConnectionScope
Scopes bindings to a givenWebsocketConnectionContext
.
-
Constructor Summary
Constructors Constructor Description ServletModule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configure(com.google.inject.Binder binder)
BindsrequestContextTracker
andwebsocketConnectionContextTracker
and corresponding contexts for injection.pl.morgwai.base.guice.scopes.ContextTrackingExecutor
newContextTrackingExecutor(String name, int poolSize)
Convenience "constructor" forContextTrackingExecutor
.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" forContextTrackingExecutor
.pl.morgwai.base.guice.scopes.ContextTrackingExecutor
newContextTrackingExecutor(String name, int poolSize, BlockingQueue<Runnable> workQueue)
Convenience "constructor" forContextTrackingExecutor
.
-
-
-
Field Detail
-
requestContextTracker
public final pl.morgwai.base.guice.scopes.ContextTracker<RequestContext> requestContextTracker
Allows tracking ofServletRequestContext
s andWebsocketEventContext
s.
-
requestScope
public final com.google.inject.Scope requestScope
Scopes bindings to either aServletRequestContext
or aWebsocketEventContext
(Objects bound to this scope can be obtained both in servlets and endpoints).- See Also:
RequestContext
-
httpSessionScope
public final com.google.inject.Scope httpSessionScope
Scopes bindings to a givenHttpSession
. 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 aFilter
targeting URL patterns of websockets can be used).
-
websocketConnectionContextTracker
public final pl.morgwai.base.guice.scopes.ContextTracker<WebsocketConnectionContext> websocketConnectionContextTracker
Allows tracking of thecontext of a given websocket connection (
.Session
)
-
websocketConnectionScope
public final com.google.inject.Scope websocketConnectionScope
Scopes bindings to a givenWebsocketConnectionContext
.
-
trackers
public final pl.morgwai.base.guice.scopes.ContextTracker<?>[] trackers
-
-
Method Detail
-
configure
public void configure(com.google.inject.Binder binder)
BindsrequestContextTracker
andwebsocketConnectionContextTracker
and corresponding contexts for injection. BindsContextTracker<?>[]
to instance containing all trackers for use withContextTrackingExecutor.getActiveContexts(ContextTracker...)
.- Specified by:
configure
in interfacecom.google.inject.Module
-
newContextTrackingExecutor
public pl.morgwai.base.guice.scopes.ContextTrackingExecutor newContextTrackingExecutor(String name, int poolSize)
Convenience "constructor" forContextTrackingExecutor
. (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" forContextTrackingExecutor
.
-
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" forContextTrackingExecutor
.
-
-