Releases: xvik/dropwizard-guicey
5.3.0
- Update to guice 5.0.1
(java15 support, removes cglib, fixes "illegal reflective access" warnings, update Guava to LATEST 30.1-jre) - Update to dropwizard 2.0.20
- Unify GuiceyAppRule (junit4) behaviour with DropwizardAppRule: config overrides should initialize just
before test and not in the constructor. The issue was causing early evaluation of lazy (deferred) overrides (#151) - Add custom ConfigOverride objects support for junit 5 extensions (registered with @RegisterExtension)
NOTE: it would not be possible to downgrade guice dependency (to 4.x) due to renamed (internal) guice class, used by guicey
5.2.0
- Update to dropwizard 2.0.16
- Remove direct usages of logback-classic classes to unlock logger switching (#127)
- Fix stackoverflow on config introspection caused by EnumMap fields (#87)
- Prioritize registered jersey provider extensions and add support for
@Priority
annotation (#97)
Unifies raw dropwizard and guicey behavior. Possibly breaking, see note below. - Add lifecycle event: ApplicationStoppedEvent (triggered on jersey lifecycle stop)
NOTE:
In raw dropwizard registered jersey extension (with environment.jersey().register(MyExceptionMapper.class))
is implicitly qualified as @Custom
and always used in priority comparing to default dropwizard providers.
Before, guicey was registering provider extensions without this qualifier and so the default
dropwizard providers were used in priority (as registered earlier).
For example, it was impossible to register ExceptionMapper<Throwable>
because dropwizard already registered one.
Now your custom mapper will be used in priority and so it is possible to override the default ExceptionMapper<Throwable>
(for example).
This COULD (unlikely, but still) change application behavior: your custom provider could be called in more cases.
But, as this behavior is the default for raw dropwizard, the change considered as a bugfix.
In case of problems, you could revert to legacy guicey behaviour with:
.option(InstallerOptions.PrioritizeJerseyExtensions, false)
5.1.0
- Update guice to 4.2.3 (java 14 support)
- Update to dropwizard 2.0.10
- Add junit 5 extensions (#74). Works much like existing spock extensions:
- @TestGuiceyApp for replacement of GuiceyAppRule
- @TestDropwizardApp for using instead of DropwizardAppRule (or current dropwizard extension)
- Spock extensions updates:
- Internally, use DropwizardTestSupport instead of deprecated junit 4 rules
- New features (port features from junit 5 extensions):
- @UseDropwizardApp got new configurations: randomPorts and restMapping
- @UseGuiceyHooks deprecated: instead additional hooks may be declared in static test field
- ClientSupport test field will be injected with client support object instance
- Junit 4 rules deprecated GuiceyAppRule, StartupErrorRules
- Fix parallel tests support: guice logs interception wasn't thread safe (#103)
- Fix invalid Automatic-Module-Name to 'ru.vyarus.dropwizard.guicey' (#106)
5.0.1
5.0.0
- Update to dropwizard 2.0.0
- (breaking in jersey 2.26)
- Jersey 2.26 introduces an abstraction for injection layer in order to get rid of hk2 direct usage.
This allows complete hk2 avoidance in the future. Right now it means that all direct hk2 classes must be replaced
by jersey abstractions (but still hk2 is the only production ready integration)- Jersey
InjectionManager
now bound to guice context instead of hk2ServiceLocator
(locator still can be retrieved from manager) - Rename HK2 mentions into jersey (because now jersey is not tied to hk2)
@HK2Managed
renamed to@JerseyManaged
- JerseyProviderInstaller (installs classes annotated with
@Provider
) changes:ValueParamProvider
detected instead ofValueFactoryProvider
Supplier
detected insteadFactory
(Factory implementations are not recognized anymore!)org.glassfish.jersey.internal.inject.InjectionResolver
detected instead oforg.glassfish.hk2.api.InjectionResolver
- Jersey installers use
org.glassfish.jersey.internal.inject.AbstractBinder
instead of hk specificorg.glassfish.hk2.utilities.binding.AbstractBinder
- Mark all hk2-related methods and options as deprecated (to be removed in the next version)
- Jersey
- Jersey 2.26 implements jax-rs 2.1 which forced it to change some of it's apis.
org.glassfish.jersey.server.AsyncContext
binding used instead of
org.glassfish.jersey.server.internal.process.AsyncContext
- Jersey 2.26 introduces an abstraction for injection layer in order to get rid of hk2 direct usage.
- (breaking dw 2.0)
- Deprecated
Bundle
usages replaced withConfigurableBundle
(in new dropwizard versionBundle extends ConfigurableBundle
)- Guicey configuration scope
ConfigSope.DropwizardBundle
now useConfigurableBundle
class for marking guice
bundle scope instead ofBundle
- Guicey configuration scope
dropwizard-bom
now includes only dropwizard modules. All 3rd party dependencies are moved to
dropwizard-dependencies
package. So you'll have to update two boms now in order to update dropwizard version.
- Deprecated
- Update hk2 guice-bridge to 2.6.1
- (breaking in jersey 2.26)
- (breaking) Guicey configuration and lifecycle changes:
GuiceyBundle
contract and behaviour changed to match dropwizard lifecycle:- GuiceyBundle now contains two methods
initialize
andrun
and called according to dropwizard lifecycle.
Now guicey bundles are complete replacement for dropwizard bundles, but with good interoperability
with pure dropwizard bundles - The following guicey initializations were moved into dropwizard configuration phase:
- Guicey bundles lookup and initialization (to be able to install dropwizard bundles inside guicey bundles)
- Installers classpath search and instantiation
- Extensions classpath search and validation (but on run phase it is still possible to disable extensions)
- Extensions initialization moved outside injector creation scope. It will affect time report and, in case of
extension installation error, exception will be thrown directly instead of Guice's CreationException. - A lot of guicey lifecycle events obviously changed (and new added)
- Add special
ApplicationStarted
event: always fired after complete dropwizard startup.
Supposed to be used to simplify diagnostic reporting. - Support lifecycle listeners deduplication for correct report behaviour in case of multiple registrations.
LinkedHashSet
used as listeners holder, so only proper equals and hashcode methods implementation is required for deduplication
- Add special
- Removed
GuiceyOptions.ConfigureFromDropwizardBundles
option because it's useless with new bundles lifecycle.
(if required, the same behaviour may be implemented with custom bundles lookup)
- GuiceyBundle now contains two methods
- Removed
GuiceyOptions.BindConfigurationInterfaces
option (interfaces are already bound with@Config
qualifier) - Guicey web installers (
WebInstallersBundle
) enabled by default.
GuiceBundle.builder()#useWebInstallers()
option removed - Direct dropwizard bundles support: bundles could be registered directly in main bundle (
GuiceBundle.dropwizardBundles()
)
or inside guicey bundle (GuiceyBundle.dropwizardBundles()
). These bundles could be disabled (same as guicey bundles - with
.disableDropwizardBundles()
methods) and are show in reporting.- Transitive dropwizard bundles tracking: all dropwizard bundles registered through guicey api are tracked for
transitive registration with bootstrap proxy. That means that all transitive bundles are shown in reports and
any transitive bundle could be disabled (with.disableDropwizardBundle
or custom predicate). Also, deduplication checks
will work (same as for guicey bundles and guice modules).
Tracking may be disabled withGuieyOptions.TrackDropwizardBundles
option.
- Transitive dropwizard bundles tracking: all dropwizard bundles registered through guicey api are tracked for
- Allow registration of multiple instances for guice modules and guicey bundles
(multiple instances of the same class)- By default, equal instances of the same type considered duplicate (only one registered).
So, to grant uniqueness of bundle or module, implement correct equals method.
For custom cases (when custom equals method is impossible),DuplicateConfigDetector
may be implemented
and registered withGuiceBundle.Builder#duplicateConfigDetector()
- Legacy behaviour (1 instance per type) could be simulated with:
.duplicateConfigDetector(new LegacyModeDuplicatesDetector())
OR methodGuiceBundle.Builder#uniqueItems(Class...)
may be used to specify
exact items to grant uniqueness for ItemId
is now used as identity instead of pureClass
. ItemId compute object hash string
and preserve it for instance identification. Class types does not contain hash in id.
Required because even scopes, represented previously as classes now could be duplicated
as multiple instances of the same bundle class could be registered. For simplicity,
ItemId equals method consider class-only id's equal to any type instance id.- Add bundle loops detection: as multiple bundle instances allowed loops are highly possible
Entire bundle chain is provided in exception to simplify fixing loops. - Add base classes for unique bundles and modules (with correct equals and hash code implementations):
UniqueGuiceyBundle
andUniqueModule
orUniqueDropwizardAwareModule
(use class name strings for
comparison to correctly detect even instances of classes from different class loaders).
Note: no such class for dropwizard bundle because it's useless (if you use guicey - use GuiceyBundle instead
and if you need dropwizard bundle - it shouldn't be dependent on guicey classes)
- By default, equal instances of the same type considered duplicate (only one registered).
- Support extensions recognition from guice modules (jersey1-guice style):
- extensions are detected from declaration in specified guice modules
(essentially same as classpath scan, but from bindings) - extensions declared in:
- direct type bindings (all generified or qualified declarations ignored)
- linked bindings (right part) bind(Something).to(Extension) are also recognized
(which must also be non qualified)
- like in classpath scan
@InvisibleForScanner
prevents recognition
(or bean may be simply qualified) - all extension registration types may work together (classpath scan, manual declaration and binding declaration)
- extensions registered directly (or found by classpath scan) and also bound manually in guice module
will not conflict anymore (as manual declaration would be detected) and so @lazybinding workaround is not needed - extensions declared in guice module may be also disabled (guicey will remove binding declaration in this case
and all chains leading to this declartion to prevent possible context failures) - Transitive gucie modules (installed by other modules) may be disabled with usual
disableModules()
(but only if guice bindings analysis is not disabled). - enabled by default, but can be disabled with
GuiceyOptions.AnalyzeModules
option BindingInstaller
interface changed (because of direct guice bindings):
it now contains 3 methods for class binding, manual binding validation and reporting
- extensions are detected from declaration in specified guice modules
- Extension classes loaded by different class loaders now detected as duplicate extension registration
- Guicey hooks, initially supposed to be used for testing only, now considered to be also used for
diagnostic tools- Add guicey hooks lookup from system property
guicey.hooks
as comma-separated list of classes. - Add hook aliases support: alias name assumed to be used instead of full class name in system property (
-Dguicey.hooks
).
Alias registered withGuiceBundle.builder()#hookAlias()
. All registered aliases are logged at startup. - Add diagnostic hook, which enables diagnostic reports and lifecycle logs.
Could be enabled with system property:-Dguicey.hooks=diagnostic
(where diagnostic is pre-registered hook alias)
Useful to enable diagnostic logs on compiled (deployed) application. - (breaking) Removed hooks recognition on registered GuiceyLifecycleLister (as it was very confusing feature)
- Add guicey hooks lookup from system property
- Add...
4.2.2
4.2.1
4.2.0
- Update to guice 4.2.0
- remove guice-multibindings dependency as it's moved to guice core
- Update to dropwizard 1.3.5
- Add more disable items (mostly for tests): guicey bundles, guice modules (directly registered) and extensions:
- Guicey bundles disabled through main builder only: .disableBundles()
- Other disable methods available in both main bundle and guicey bundles bootstrap:
- .disableModules(Class...) - disable guice modules
- .disableExtensions(Class...) - extensions disabling (for possible replacement)
- generic disable method by predicate: .disable(Predicate) (for example, disable all extensions in package or all installed by some bundle etc.)
- Add direct support for guice bindings override (using Modules.override() internally) to main bundle and guicey bundle bootstrap:
.modulesOverride(Module...)- Add BindingsOverrideInjectorFactory to override already overridden bindings (with modulesOverride) in test (edge case)
- Add hooks for configuration override in integration tests (#23):
- New GuiceyConfigurationHook interface: hook receive bundle builder instance after application configuration and so could modify configuration (with new disable* methods)
- Junit:
- New rule GuiceyConfigurationRule for hook registration
- Spock:
- New @UseGuiceyConfiguration extension allows base hook definition (in base class)
- New attribute hooks in @UseGuiceyApp and @UseDropwizardApp extensions to declare test-specific hooks
- Add guicey lifecycle events (16 events): provide access to all possible internal state, available at this moment.
It may be used to write instance specific features (post processing) or just advanced logging- Add new method in main bundle or guicey bundle bootstrap: .listen(GuiceyLifecycleListener...)
- Add guicey lifecycle phases reporting methods in main bundle (useful for debugging startup logic):
- .printLifecyclePhases() - identify configuration stages in console logs
- .printLifecyclePhasesDetailed() - identify lifecycle phases with detailed configuration report (in console logs)
- Improve options support:
- Add OptionsAwareModule interface to let guice modules access options
- Add OptionsMapper helper to simplify mapping of system properties and environment variables in builder.options()
- Add ability to manage jersey extensions with HK2 by default (#41).
It's like using @HK2Managed on all jersey-related beans (resources, filters etc).
This is useful, for example, if you get common to jersey resources features like @context injection.- Add option InstallersOptions.JerseyExtensionsManagedByGuice set to false enable HK2 management by default.
HK2 bridge must be enabled (GuiceyOptions.UseHkBridge) for HK2-first mode (exception thrown if not). - Add @GuiceManaged annotation to mark exceptions in HK2-first mode (when @HK2Managed become useless).
In guice-first mode this annotation is useless. - Builder shortcut: .useHK2ForJerseyExtensions() to simplify HK2-first mode enabling.
- Add option InstallersOptions.JerseyExtensionsManagedByGuice set to false enable HK2 management by default.
- Guice beans scope-related improvements:
- Singleton scope is not forced for jersey extensions with explicit scoping annotation
- Add option for disabling forced singletons for jersey extensions: InstallerOptions.ForceSingletonForJerseyExtensions
- Add annotation for guice prototype scope: @prototype. Useful to declare some jersey extensions as default-scoped even when forced singletons enabled
- Fix guice request scope delegation support (ServletScopes.transferRequest) for jersey-manager request objects (#49)
- Add Bootstrap object accessible in GuiceyBundle: bootstrap() (return dropwizard bootstrap object)
- Add ConfigScope enum for special scopes description (to not remember special classes).
- Add shortcut methods in config related apis (Filters, Disables, GuiceyConfigurationInfo)
- (breaking) Config reporting api changes:
- Diagnostic report configuration method rename: DiagnosticConfig.printDisabledInstallers renamed to printDisabledItems and affects now all disabled items
- Diagnostic tree report could hide application scope in ContextTreeConfig.hideScopes(ConfigItems.Application)
- New configuration bindings:
- Configuration object could be bound as:
- any class from configuration class hierarchy (as before)
- any class from hierarchy with @config qualifier: @Inject @config Configuration conf
- interface, implemented by any class in hierarchy with qualifier: @Inject @config ConfInterface config
- (Deprecated) GuiceyOptions.BindConfigurationInterfaces: when enabled it would bind configuration with interface (as before),
but prefer binding interfaces with qualifier (@config), which is always available.
Option will be removed in the future versions - (Deprecated) bundle's builder.bindConfigurationInterfaces()
- Configuration value (property value) could be bound by path: @Inject @config("server.serverPush.enabled") Boolean enabledPush
Or entire sub configuration object: @Inject @config("server") ServerFactory serverCfg - Sub configuration objects could be bound without path if object type appear only once in configuration:
@Inject @config ServerFactory serverCfg - ConfigurationTree - configuration introspection object is available for direct binding
- and from GuiceyConfigurationInfo bean: getConfigurationTree()
- Alternative configuration access:
- New configuration access methods available inside GuiceyBundle and module (DropwizardAwareModule):
- configuration(String) - configuration value by path
- configuration(Class) - unique sub configuration object
- configurations(Class) - all sub configuration objects with assignable type (on any depth)
- configurationTree() - access raw introspection data for more complex searches
- New configuration access methods available inside GuiceyBundle and module (DropwizardAwareModule):
- Reports to see available config bindings (before injector creation for potential problems solving) in main bundle:
- .printConfigurationBindings() - log all bindings (including dropwizard Configuration)
- .printCustomConfigurationBindings() - log only custom bindings (from custom configuration classes)
- Configuration object could be bound as:
Also, release includes much improved generics-resolver
4.1.0
- Update to dropwizard 1.1.0
- Add StartupErrorRule to simplify dropwizard startup error testing
- (breaking) HK guice-bridge dependency become optional. New option GuiceyOptions.UseHkBridge could be used
to enable bridge (#28) - Fix NPE when used with JRebel (#29)
- Add binding for jersey javax.ws.rs.container.ResourceInfo (#26)
- Fix loggers for GuiceyAppRule (junit) and @UseGuiceyApp (spock) (#32)
- Fix guava conflict in guicey pom. Make guicey pom usable as BOM.