Enum GuiceyOptions
- java.lang.Object
-
- java.lang.Enum<GuiceyOptions>
-
- ru.vyarus.dropwizard.guice.GuiceyOptions
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<GuiceyOptions>
,Option
public enum GuiceyOptions extends java.lang.Enum<GuiceyOptions> implements Option
Guicey core options. In most cases, direct option definition is not required because all options are covered with shortcut method inGuiceBundle.Builder
. Direct option definition may be useful when option is dynamically resolved and so shortcut methods can't be used (will require builder flow interruption and additional if statements).Normally options are mostly useful for runtime configuration values access (e.g. check in some 3rd party bundle what packages are configured for classpath scan).
Generally options are not limited to this enum and custom option enums may be used by 3rd party bundles.
- Since:
- 09.08.2016
- See Also:
for details
,for usage in guice services
,for reporting
-
-
Enum Constant Summary
Enum Constants Enum Constant Description AnalyzeGuiceModules
Search for extensions in supplied guice modules (registration from guice module).BindConfigurationByPath
Introspect configuration object (using jackson serialization) and bind all internal values by path (@Inject @Config("path.to.value") Integer value
).GuiceFilterRegistration
GuiceFilter registered for both contexts (application and admin) to provide guiceServletModule
support and allow using request and session scopes.InjectorStage
Guice injector stage used for injector creation.ScanPackages
Packages for classpath scan.SearchCommands
Enables commands search in classpath and dynamic installation.TrackDropwizardBundles
Track transitive dropwizard bundles registration.UseCoreInstallers
Automatic core installers installation.UseHkBridge
Deprecated.in the next version HK2 support will be removed
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getDefaultValue()
java.lang.Class<?>
getType()
static GuiceyOptions
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static GuiceyOptions[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
ScanPackages
public static final GuiceyOptions ScanPackages
Packages for classpath scan. Not empty value indicates auto scan mode enabled. Empty by default.Special value
GuiceyInitializer.APP_PKG
might be used to configure application package (replaced into real package during initialization).
-
SearchCommands
public static final GuiceyOptions SearchCommands
Enables commands search in classpath and dynamic installation. Requires auto scan mode. Disabled by default.- See Also:
GuiceBundle.Builder.searchCommands()
-
UseCoreInstallers
public static final GuiceyOptions UseCoreInstallers
Automatic core installers installation. Enabled by default.
-
BindConfigurationByPath
public static final GuiceyOptions BindConfigurationByPath
Introspect configuration object (using jackson serialization) and bind all internal values by path (@Inject @Config("path.to.value") Integer value
). Recognize unique sub configuration objects for direct binding (@Inject @Config SubConfig conf
). Enabled by default.Note that path could be hidden using
JsonIgnore
on property getter.Option exists only for edge cases when introspection fails and prevents application startup (should be impossible) or due to project specific reasons (when internal bindings are not desirable). When disabled, only configuration object itself would be bound (by all classes in hierarchy and interfaces). Note that
ConfigurationTree
will also not contain paths - option disables entire introspection process.- See Also:
ConfigTreeBuilder
,ConfigurationTree
,ConfigBindingModule
-
TrackDropwizardBundles
public static final GuiceyOptions TrackDropwizardBundles
Track transitive dropwizard bundles registration. Affects only dropwizard bundles registered through guicey api (GuiceBundle.Builder.dropwizardBundles(ConfiguredBundle[])
(direct registration) andGuiceyBootstrap.dropwizardBundles(ConfiguredBundle[])
(registration within guicey bundle)). When enabled, registered dropwizard bundles would be registered in dropwizard with decorated (to track execution) object and receive proxied bootstrap object instead of raw bootstrap intoConfiguredBundle.initialize(Bootstrap)
. This should not cause any problems with normal bundles usage.When disabled, guicey will be able to "see" only directly registered bundles (and so will be able to disable and deduplicate only them).
NOTE: dropwizard bundles registered directly into bootstrap object (in application or in guicey bundle) are not tracked in any case. It is assumed that guicey api would be used for bundles registration when you want to track them.
Bootstrap
object proxy creation results in ~200ms overhead, clearly visible on diagnostics report (stats). But it's the only way to track transitive dropwizard bundles (not so big price). Proxy object is not created if no dropwizard bundles registered through guicey api.
-
AnalyzeGuiceModules
public static final GuiceyOptions AnalyzeGuiceModules
Search for extensions in supplied guice modules (registration from guice module). Overriding modules are not taken into account. Also, removes disabled modules from inner module registrations (transitive modules).Normally extension class is registered directly (or found by classpath scan), recognized by installer, bound to guice context (with a default binding) and installed in dropwizard. When option is enabled, the same is done with guice bindings (declared in modules): binding classes analyzed by installers to detect extensions and then extensions are installed. Overall it's the same, except no default bindings applied by framework.
It is ok if the same extension would be registered manually or detected by classpath scan and be declared in guice module manually - guicey will gust avoid default binding.
Extensions, detected from guice modules may be disabled the same way as usual extensions (bindings will be removed).
When modules analysis is enabled, guicey performs modules configuration (using SPI api) before actual injector creation and, to avoid duplicate work by injector, parsed modules are repackaged (to preserve parsed information). You can see on stats report that modules analysis time is cut off from injector creation time (creation time grows if option disabled). Also repackaging is the only way to properly handle disables for existing bindings.
-
InjectorStage
public static final GuiceyOptions InjectorStage
Guice injector stage used for injector creation. Production by default.- See Also:
GuiceBundle.Builder.build(Stage)
-
GuiceFilterRegistration
public static final GuiceyOptions GuiceFilterRegistration
GuiceFilter registered for both contexts (application and admin) to provide guiceServletModule
support and allow using request and session scopes. By default, filter is registered only for direct requests. Declare other types if required (but note that GuiceFilter does not support ASYNC!).To disable guice filter installation use empty set:
EnumSet.noneOf(DispatcherType.class)
. This will completely disable guice servlet modules support because without guice filter, guice web support is useless (all filters and servlets registered in servlet module are dispatched by guice filter).Note that even without guice servlet modules support HttpServletRequest and HttpServletResponse objects will be still available for injection in resources (through HK2 bridging). Also, note that guice servlets initialization took some time and application starts faster without it (~50ms). Use
WebInstallersBundle
to register guice manged servlets and filters. IMPORTANT: after disabling guice filter, servlet and request scopes will no longer be available and installation of guice ServletModule will be impossible (will fail on duplicate binding). Also it will not be possible to use http request and response injections under filter and servlets (it will work only with resources).
-
UseHkBridge
@Deprecated public static final GuiceyOptions UseHkBridge
Deprecated.in the next version HK2 support will be removedEnables guice bridge for HK2 to allow HK2 services to see guice beans. This is not often required and so disabled by default. For example, it could be required ifJerseyManaged
used to properly instantiate service by HK2 when it also depends on guice services.IMPORTANT: requires extra dependency on HK2 guice-bridge: 'org.glassfish.hk2:guice-bridge:2.6.1'
-
-
Method Detail
-
values
public static GuiceyOptions[] 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 (GuiceyOptions c : GuiceyOptions.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static GuiceyOptions 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
-
-