Class WebFilterInstaller
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.module.installer.feature.web.WebFilterInstaller
-
- All Implemented Interfaces:
FeatureInstaller,InstanceInstaller<jakarta.servlet.Filter>,Ordered
public class WebFilterInstaller extends java.lang.Object implements FeatureInstaller, InstanceInstaller<jakarta.servlet.Filter>, Ordered
Search for http filters annotated withWebFilter(servlet api annotation). Such filters will not be installed by jetty because dropwizard didn't depend on jetty-annotations.Only the following
WebFilterannotation properties are supported: filterName, urlPatterns ( or value), servletNames, dispatcherTypes, initParams, asyncSupported. Url patterns and servlet names can't be used at the same time.When filter 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 "filter" then it will be cut off. For example, for class "MyCoolFilter" generated name will be ".mycool".
By default, everything is installed for main context. Special annotation
AdminContextmust be used to install into admin or both contexts.Reporting format:
[urls or servlets mapping] [context markers: M - main, A - admin] (class) [filter name]
. If filter registered only in main context, then context marker (M) is not shown.- Since:
- 06.08.2016
-
-
Constructor Summary
Constructors Constructor Description WebFilterInstaller()
-
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.voidinstall(io.dropwizard.core.setup.Environment environment, jakarta.servlet.Filter instance)UseFeatureUtils.getInstanceClass(instance)to overcome proxies and get correct type.booleanmatches(java.lang.Class<?> type)NOTE: consider usingru.vyarus.dropwizard.guice.module.installer.util.FeatureUtilsto simplify checks (for example, types most likely must be checks to be not abstract).voidreport()Called to log registered endpoints in dropwizard log fashion.
-
-
-
Method Detail
-
matches
public boolean matches(java.lang.Class<?> type)
Description copied from interface:FeatureInstallerNOTE: consider usingru.vyarus.dropwizard.guice.module.installer.util.FeatureUtilsto 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:
matchesin interfaceFeatureInstaller- Parameters:
type- type to check- Returns:
- true if extension recognized, false otherwise
-
install
public void install(io.dropwizard.core.setup.Environment environment, jakarta.servlet.Filter instance)Description copied from interface:InstanceInstallerUseFeatureUtils.getInstanceClass(instance)to overcome proxies and get correct type.Full
Injectorcould be obtained withInjectorLookup.getInjector(Environment).Shared state could be obtained with
SharedConfigurationState.get(Environment)- Specified by:
installin interfaceInstanceInstaller<jakarta.servlet.Filter>- Parameters:
environment- environment objectinstance- extension instance
-
report
public void report()
Description copied from interface:FeatureInstallerCalled to log registered endpoints in dropwizard log fashion. It's important to naturally show all dynamically resolved classes to easily catch errors. UseReporterto simplify reporting.Method may do nothing if reporting not required
- Specified by:
reportin interfaceFeatureInstaller
-
getRecognizableSigns
public java.util.List<java.lang.String> getRecognizableSigns()
Description copied from interface:FeatureInstallerMethod 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:
getRecognizableSignsin interfaceFeatureInstaller- Returns:
- list of extension signs installer recognize
-
-