Class WebServletInstaller
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.module.installer.option.InstallerOptionsSupport
-
- ru.vyarus.dropwizard.guice.module.installer.feature.web.WebServletInstaller
-
- All Implemented Interfaces:
FeatureInstaller
,InstanceInstaller<javax.servlet.http.HttpServlet>
,WithOptions
,Ordered
public class WebServletInstaller extends InstallerOptionsSupport implements FeatureInstaller, InstanceInstaller<javax.servlet.http.HttpServlet>, Ordered
Search for http servlets annotated withWebServlet
(servlet api annotation). Such servlets will not be installed by jetty because dropwizard didn't depend on jetty-annotations.Only the following
WebServlet
annotation properties are supported: name, urlPatterns ( or value), initParams, asyncSupported.When servlet name not defined, then name will be generated as: . (dot) at the beginning to indicate generated name, followed by lower-cased class name. If class ends with "servlet" then it will be cut off. For example, for class "MyCoolServlet" generated name will be ".mycool".
If servlet mapping clash (partially or completely) with some other servlet then warning log will be printed, but overall process will not fail. Use
InstallersOptions.DenyServletRegistrationWithClash
to throw exception instead of warning.By default, everything is installed for main context. Special annotation
AdminContext
must be used to install into admin or both contexts.Reporting format:
[urls] [context markers: M - main, A - admin] (class) [servlet name]
. If servlet registered only in main context, then context marker (M) is not shown.- Since:
- 06.08.2016
-
-
Constructor Summary
Constructors Constructor Description WebServletInstaller()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.String>
getRecognizableSigns()
Method used by extensions help report (GuiceBundle.Builder.printExtensionsHelp()
) to show what signs this exact installer recognize so user could better understand extensions support specifics.void
install(io.dropwizard.core.setup.Environment environment, javax.servlet.http.HttpServlet instance)
UseFeatureUtils.getInstanceClass(instance)
to overcome proxies and get correct type.boolean
matches(java.lang.Class<?> type)
NOTE: consider usingru.vyarus.dropwizard.guice.module.installer.util.FeatureUtils
to simplify checks (for example, types most likely must be checks to be not abstract).void
report()
Called to log registered endpoints in dropwizard log fashion.-
Methods inherited from class ru.vyarus.dropwizard.guice.module.installer.option.InstallerOptionsSupport
option, setOptions
-
-
-
-
Method Detail
-
matches
public boolean matches(java.lang.Class<?> type)
Description copied from interface:FeatureInstaller
NOTE: consider usingru.vyarus.dropwizard.guice.module.installer.util.FeatureUtils
to simplify checks (for example, types most likely must be checks to be not abstract).When type accepted by any extension it's registered in guice module.
- Specified by:
matches
in interfaceFeatureInstaller
- Parameters:
type
- type to check- Returns:
- true if extension recognized, false otherwise
-
install
public void install(io.dropwizard.core.setup.Environment environment, javax.servlet.http.HttpServlet instance)
Description copied from interface:InstanceInstaller
UseFeatureUtils.getInstanceClass(instance)
to overcome proxies and get correct type.Full
Injector
could be obtained withInjectorLookup.getInjector(Environment)
.Shared state could be obtained with
SharedConfigurationState.get(Environment)
- Specified by:
install
in interfaceInstanceInstaller<javax.servlet.http.HttpServlet>
- Parameters:
environment
- environment objectinstance
- extension instance
-
report
public void report()
Description copied from interface:FeatureInstaller
Called to log registered endpoints in dropwizard log fashion. It's important to naturally show all dynamically resolved classes to easily catch errors. UseReporter
to simplify reporting.Method may do nothing if reporting not required
- Specified by:
report
in interfaceFeatureInstaller
-
getRecognizableSigns
public java.util.List<java.lang.String> getRecognizableSigns()
Description copied from interface:FeatureInstaller
Method used by extensions help report (GuiceBundle.Builder.printExtensionsHelp()
) to show what signs this exact installer recognize so user could better understand extensions support specifics.- Specified by:
getRecognizableSigns
in interfaceFeatureInstaller
- Returns:
- list of extension signs installer recognize
-
-