public enum GuiceyOptions extends java.lang.Enum<GuiceyOptions> implements Option
GuiceBundle.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.
for details,
for usage in guice services,
for reporting| Enum Constant and 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 guice
ServletModule 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
Enables guice bridge for HK2 to allow HK2 services to see guice beans.
|
| Modifier and Type | Method and 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.
|
public static final GuiceyOptions ScanPackages
public static final GuiceyOptions SearchCommands
GuiceBundle.Builder.searchCommands()public static final GuiceyOptions UseCoreInstallers
public static final GuiceyOptions BindConfigurationByPath
@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.
ConfigTreeBuilder,
ConfigurationTree,
ConfigBindingModulepublic static final GuiceyOptions TrackDropwizardBundles
GuiceBundle.Builder.dropwizardBundles(ConfiguredBundle[]) (direct registration) and
GuiceyBootstrap.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 into ConfiguredBundle.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.
public static final GuiceyOptions AnalyzeGuiceModules
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.
public static final GuiceyOptions InjectorStage
GuiceBundle.Builder.build(Stage)public static final GuiceyOptions GuiceFilterRegistration
ServletModule 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).
public static final GuiceyOptions UseHkBridge
JerseyManaged 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.5.0'
public static GuiceyOptions[] values()
for (GuiceyOptions c : GuiceyOptions.values()) System.out.println(c);
public static GuiceyOptions valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullpublic java.lang.Class<?> getType()
public java.lang.Object getDefaultValue()
getDefaultValue in interface Option