Enum InstallersOptions
- java.lang.Object
-
- java.lang.Enum<InstallersOptions>
-
- ru.vyarus.dropwizard.guice.module.installer.InstallersOptions
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<InstallersOptions>
,Option
public enum InstallersOptions extends java.lang.Enum<InstallersOptions> implements Option
Bundled installers options. Applies for bothCoreInstallersBundle
andWebInstallersBundle
installers.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description DenyServletRegistrationWithClash
AffectsWebServletInstaller
.DenySessionListenersWithoutSession
AffectsWebListenerInstaller
.ForceSingletonForJerseyExtensions
Force singleton scope for jersey extensions (including resources).JerseyExtensionsManagedByGuice
Deprecated.in the next version HK2 support will be removedJerseyExtensionsRecognizedByType
By default, jersey extensions would be recognized by type (e.g.PrioritizeJerseyExtensions
By default, when extension registered withenvironment.jersey().register(...)
it's implicitly qualified withCustom
, so registered extensions could override default extensions, including default dropwizard extensions (seeProviders.getAllServiceHolders( org.glassfish.jersey.internal.inject.InjectionManager, java.lang.Class)
to see that custom qualified providers are prioritized).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getDefaultValue()
java.lang.Class<?>
getType()
static InstallersOptions
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static InstallersOptions[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
DenyServletRegistrationWithClash
public static final InstallersOptions DenyServletRegistrationWithClash
AffectsWebServletInstaller
. During servlet registration, url patterns may clash with already installed servlets. By default, only warning will be printed in log. Set option totrue
to throw exception on registration if clash detected.Note: clash resolution depends on servlets registration order. Moreover, clash may appear on some 3rd party servlet registration (not managed by installer) and so be not affected by this option.
-
DenySessionListenersWithoutSession
public static final InstallersOptions DenySessionListenersWithoutSession
AffectsWebListenerInstaller
. By default, dropwizard does not have configured sessions support (to be stateless), so session listeners can't be installed. Because session listeners may be defined as part of 3rd party bundles and most likely will complement bundle functionality (aka optional part), listener installer will only log warning about not installed listeners. Set option totrue
to throw error instead (when session listeners can't be installed because of no sessions support enabled).
-
JerseyExtensionsManagedByGuice
@Deprecated public static final InstallersOptions JerseyExtensionsManagedByGuice
Deprecated.in the next version HK2 support will be removedBy default, HK2 related extensions like resources or other jersey specific extensions are managed by guice (guice-managed instance is registered in HK2). This makes some HK2-specific features not possible (like context injection with @Context annotation).JerseyManaged
annotation could switch annotated beans to be managed by HK2. But in some cases, it is more convenient to always use HK2 and this option is supposed to be used exactly for such cases.When false value set, all beans, managed by jersey installers (
JerseyInstaller
) should register beans for HK2 management.JerseyManaged
become useless in this case, insteadGuiceManaged
annotation could be used.Note that even managed by HK2 beans will be singletons. Still this will not block you from using
@Context
annotation injections, because HK2 will proxy such injections and properly handle multi-threaded access (implicit provider).NOTE: guice aop is not applicable for beans managed by HK2 (because guice aop use class proxies and not instance proxies).
Startup will fail if HK2 bridge is not enabled (see
GuiceyOptions.UseHkBridge
) because without it you can't inject any guice beans into HK2 managed instances (and if you don't need to then you don't need guice support at all).
-
ForceSingletonForJerseyExtensions
public static final InstallersOptions ForceSingletonForJerseyExtensions
Force singleton scope for jersey extensions (including resources). It is highly recommended using singletons to avoid redundant objects creation. Enabled by default.Note that forced singleton is not applied to beans with explicit scoping annotation set.
Prototype
annotation may be used to force default (prototype) scope instead of singleton.When switched off, extension scope will be driven only by scope annotation. Note that by default guice and HK2 use prototype scope (for example, for resources it means new instance for each request).
-
PrioritizeJerseyExtensions
public static final InstallersOptions PrioritizeJerseyExtensions
By default, when extension registered withenvironment.jersey().register(...)
it's implicitly qualified withCustom
, so registered extensions could override default extensions, including default dropwizard extensions (seeProviders.getAllServiceHolders( org.glassfish.jersey.internal.inject.InjectionManager, java.lang.Class)
to see that custom qualified providers are prioritized). For example, registeredExceptionMapper<Throwable>
would override default dropwizard's one.When option disabled, qualifier could still be applied manually with
Custom
annotation on provider class. OrPriority
might be used instead (seePriorities
for default priority constants).Option is enabled by default to mimic default dropwizard behaviour (when extensions registered manually). But it MAY change application behaviour comparing to previous guicey versoins and so it might be desirable to revert previous guicey behavior (and this is the main reason for option to exist).
-
JerseyExtensionsRecognizedByType
public static final InstallersOptions JerseyExtensionsRecognizedByType
By default, jersey extensions would be recognized by type (e.g.ExceptionMapper
) (not only annotated as prvider). But, if you have complex extension hierarchies with non-abstract classes in the middle, classpath scan could recognize "middle" extensions and install them. Or there might be other situation when you need to avoid installation by type.When disabled, only extensions annotated with
Provider
would be recognized (legacy guicey behaviour).
-
-
Method Detail
-
values
public static InstallersOptions[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (InstallersOptions c : InstallersOptions.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static InstallersOptions valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
getType
public java.lang.Class<?> getType()
-
getDefaultValue
public java.lang.Object getDefaultValue()
- Specified by:
getDefaultValue
in interfaceOption
- Returns:
- option default value or null
-
-