Class WebInstallersBundle
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.module.context.unique.item.UniqueGuiceyBundle
-
- ru.vyarus.dropwizard.guice.module.installer.WebInstallersBundle
-
- All Implemented Interfaces:
GuiceyBundle
public class WebInstallersBundle extends UniqueGuiceyBundle
Bundle adds servlet installers for filters, servlets and listeners installation. Standard java.servlet.annotation annotations (WebFilter
,WebServlet
,WebListener
) are used. Note that these annotations are not recognized by jetty automatically, because dropwizard doesn't include jetty-annotations modules.By default, everything is installed for main context. Special annotation
AdminContext
must be used to install into admin or both contexts.Also bundle assigns application (
Environment.getApplicationContext()
) and admin (Environment.getAdminContext()
) contexts display names (ContextHandler.setDisplayName(String)
). Does not override already assigned name.If only annotations used for filters and servlets definitions consider disabling support for guice
ServletModule
usingGuiceyOptions.GuiceFilterRegistration
.- Since:
- 06.08.2016
-
-
Constructor Summary
Constructors Constructor Description WebInstallersBundle()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
initialize(GuiceyBootstrap bootstrap)
Called in initialization phase.void
run(GuiceyEnvironment environment)
Called on run phase.-
Methods inherited from class ru.vyarus.dropwizard.guice.module.context.unique.item.UniqueGuiceyBundle
equals, hashCode
-
-
-
-
Method Detail
-
initialize
public void initialize(GuiceyBootstrap bootstrap)
Description copied from interface:GuiceyBundle
Called in initialization phase.GuiceyBootstrap
contains almost the same methods asGuiceBundle.Builder
, which allows to register installers, extensions and guice modules. Existing installer could be replaced by disabling old one and registering new.Dropwizard bundles could be also registered with
GuiceyBootstrap.dropwizardBundles(io.dropwizard.core.ConfiguredBundle[])
shortcut (or by directly accessing dropwizard bootstrap object:GuiceyBootstrap.bootstrap()
.As bundles could be registered only during initialization phase, it is not possible to avoid bundle registration based on configuration (not a good practice). But, it is possible to use guicey options instead: for example, map option from environment variable and use to to decide if some bundles should be activated.
Guicey lifecycle listeners (
GuiceyLifecycleListener
could be registered only on initialization phase (GuiceyBootstrap.listen(ru.vyarus.dropwizard.guice.module.lifecycle.GuiceyLifecycleListener...)
).- Parameters:
bootstrap
- guicey bootstrap object
-
run
public void run(GuiceyEnvironment environment)
Description copied from interface:GuiceyBundle
Called on run phase.GuiceyEnvironment
contains almost the same methods asGuiceBundle.Builder
, which allows to register extensions and guice modules.Direct jersey specific registrations are possible through shortcuts
GuiceyEnvironment.register(Object...)
andGuiceyEnvironment.register(Class[])
. Complete dropwizard environment object is accessible withGuiceyEnvironment.environment()
(assumed that it would not be directly required in most cases).Dropwizard configuration is accessible directly with
GuiceyEnvironment.configuration()
and with advanced methodsGuiceyEnvironment.configuration(Class)
,GuiceyEnvironment.configuration(String)
,GuiceyEnvironment.configurations(Class)
andGuiceyEnvironment.configurationTree()
.- Parameters:
environment
- guicey environment object
-
-