<commit_before># Release Notes

Release contains many breaking changes due to:

* Dropwizard 2.0 (Jersey 2.26) breaking changes
* Change of guicey lifecycle

As dropwizard 2.0 already introduce many breaking changes (new jersey actually), so it was an ideal moment to fix 
all conceptual guicey mistakes. 

Please read [dropwizard 2.0 upgrade guide](https://github.com/dropwizard/dropwizard/blob/master/docs/source/manual/upgrade-notes/upgrade-notes-2_0_x.rst) first.
   
* [General changes](#general-changes)
* [New guicey lifecycle](#new-guicey-lifecycle)
* [Multiple bundles and modules of the same type support](#multiple-bundles-and-modules-of-the-same-type-support)
* [Dropwizard bundles direct support](#dropwizard-bundles-direct-support)
* [Configuration from guice bindings (jersey1-guice style)](#configuration-from-guice-bindings-jersey1-guice-style)
* [Multiple classloaders support](#multiple-classloaders-support)
* [Guicey listeners changes](#guicey-listeners-changes)
* [New shared configuration state](#new-shared-lifecycle-state)
* [Reporting changes](#reporting-changes)
* [Guicey hooks changes](#guicey-hooks-changes)
* [Guicey BOM includes guicey itself](#guicey-bom-includes-guicey-itself)
* [Java 11 compatibility](#java-11-compatibility)

**[Migration Guide](#migration-guide)**.

## General changes

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 (see [migration matrix](#dropwizard-related) below)

Note that `org.glassfish.hk2.api.ServiceLocator` must be replaced with `org.glassfish.jersey.internal.inject.InjectionManager`.
The later may be used to obtain locator, but be aware that HK2 supposed to be completely dropped in the next guicey version.

`@HK2Managed` guicey annotation was renamed to `@JerseyManaged` to point on possible absence of HK2.

`GuiceBundle.builder()#useWebInstallers()` was removed because `WebInstallersBundle` is 
activated by default and so you don't need to activate it manually anymore. 

## New guicey lifecycle

Before guicey perform all it's operations under dropwizard run phase. This makes guicey and dropwizard
bundles interoperability hard. But guicey should not limit dropwizard abilities and so now
almost all configuration is performed under dropwizard's configuration phase.

New guicey lifecycle:

* Dropwizard bundles are resolved and initialized under configuration phase
* Classpath scan and extensions resolution appears under configuration phase
* Guice injector, as before, created under run phase.

`GuiceyBundle` interface changed from 

```java 
public interface GuiceyBundle {
    // called on run phase
    void initialize(GuiceyBootstrap bootstrap);
}
```                     

into 

```java
public interface GuiceyBundle {
    // called on configuration phase
    default void initialize(GuiceyBootstrap bootstrap) {}
    // called on run phase
    default void run(GuiceyEnvironment environment) {}
}
``` 

Default methods were used by analogy with updated dropwizard `ConfiguredBundle` to avoid need to always
implement both methods.                      

All registrations, except modules must be performed under configuration phase. On run phase only guice modules could be
registered because guice modules often require configuration values (without this it would always
require to use root `DropwizardAwareModule` to perform some modules registrations).

Extensions might be disabled in run phase: assumed that this could be required for
optional features, driven by configuration (not needed extensions could be disabled, based on 
configuration object values).

!!! note
    Dropwizard and guicey bundles are completely equivalent now, but guicey bundles provide more 
    configuration options (aware of guicey). So prefer using `GuiceyBundle` instead of dropwizard bundles. 
    Note that guicey bundles now provide shortcut methods for easy dropwizard bundles registration.

Before, extensions registration was performed under guice injector creation, but now it was moved 
just after injector creation in order to differentiate pure injector creation errors from
extension installation errors.  

!!! tip 
    Statistics report (`.printDiagnosticReports()`) will also print time by phase:
    ```
    GUICEY started in 441.1 ms (104.8 ms config / 336.2 ms run / 0 jersey)
    ```
    (configuration phase / run phase / extensions installation during jersey startup)<commit_msg>mention new environment phase shortcuts in guicey bundle in release notes<commit_after># Release Notes

Release contains many breaking changes due to:

* Dropwizard 2.0 (Jersey 2.26) breaking changes
* Change of guicey lifecycle

As dropwizard 2.0 already introduce many breaking changes (new jersey actually), so it was an ideal moment to fix 
all conceptual guicey mistakes. 

Please read [dropwizard 2.0 upgrade guide](https://github.com/dropwizard/dropwizard/blob/master/docs/source/manual/upgrade-notes/upgrade-notes-2_0_x.rst) first.
   
* [General changes](#general-changes)
* [New guicey lifecycle](#new-guicey-lifecycle)
* [Multiple bundles and modules of the same type support](#multiple-bundles-and-modules-of-the-same-type-support)
* [Dropwizard bundles direct support](#dropwizard-bundles-direct-support)
* [Configuration from guice bindings (jersey1-guice style)](#configuration-from-guice-bindings-jersey1-guice-style)
* [Multiple classloaders support](#multiple-classloaders-support)
* [Guicey listeners changes](#guicey-listeners-changes)
* [New shared configuration state](#new-shared-lifecycle-state)
* [Reporting changes](#reporting-changes)
* [Guicey hooks changes](#guicey-hooks-changes)
* [Guicey BOM includes guicey itself](#guicey-bom-includes-guicey-itself)
* [Java 11 compatibility](#java-11-compatibility)

**[Migration Guide](#migration-guide)**.

## General changes

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 (see [migration matrix](#dropwizard-related) below)

Note that `org.glassfish.hk2.api.ServiceLocator` must be replaced with `org.glassfish.jersey.internal.inject.InjectionManager`.
The later may be used to obtain locator, but be aware that HK2 supposed to be completely dropped in the next guicey version.

`@HK2Managed` guicey annotation was renamed to `@JerseyManaged` to point on possible absence of HK2.

`GuiceBundle.builder()#useWebInstallers()` was removed because `WebInstallersBundle` is 
activated by default and so you don't need to activate it manually anymore. 

## New guicey lifecycle

Before guicey perform all it's operations under dropwizard run phase. This makes guicey and dropwizard
bundles interoperability hard. But guicey should not limit dropwizard abilities and so now
almost all configuration is performed under dropwizard's configuration phase.

New guicey lifecycle:

* Dropwizard bundles are resolved and initialized under configuration phase
* Classpath scan and extensions resolution appears under configuration phase
* Guice injector, as before, created under run phase.

`GuiceyBundle` interface changed from 

```java 
public interface GuiceyBundle {
    // called on run phase
    void initialize(GuiceyBootstrap bootstrap);
}
```                     

into 

```java
public interface GuiceyBundle {
    // called on configuration phase
    default void initialize(GuiceyBootstrap bootstrap) {}
    // called on run phase
    default void run(GuiceyEnvironment environment) {}
}
``` 

Default methods were used by analogy with updated dropwizard `ConfiguredBundle` to avoid need to always
implement both methods.                      

All registrations, except modules must be performed under configuration phase. On run phase only guice modules could be
registered because guice modules often require configuration values (without this it would always
require to use root `DropwizardAwareModule` to perform some modules registrations).

Extensions might be disabled in run phase: assumed that this could be required for
optional features, driven by configuration (not needed extensions could be disabled, based on 
configuration object values).

!!! note
    Dropwizard and guicey bundles are completely equivalent now, but guicey bundles provide more 
    configuration options (aware of guicey). So prefer using `GuiceyBundle` instead of dropwizard bundles. 
    Note that guicey bundles now provide shortcut methods for easy dropwizard bundles registration.

Before, extensions registration was performed under guice injector creation, but now it was moved 
just after injector creation in order to differentiate pure injector creation errors from
extension installation errors.  

!!! tip 
    Statistics report (`.printDiagnosticReports()`) will also print time by phase:
    ```
    GUICEY started in 441.1 ms (104.8 ms config / 336.2 ms run / 0 jersey)
    ```
    (configuration phase / run phase / extensions installation during jersey startup)

### Run phase shortcuts

GuiceyEnvironment almost not allow guicey items registrations (except modules), but 
provide many shortcuts:

* `register()` for `environment().jersey().register()`
* `manage()` for `environment().lifecycle().manage()` 
* `listen()` for `environment().lifecycle().addLifeCycleListener()` and `environment().lifecycle().addServerLifecycleListener()`
* `onGuiceyStartup()` - special callback called after guicey start to perform manual registrations in 
    dropwizard environment with provided injector
* `onApplicationStartup()` - special callback called after complete application startup (in guicey lightweight tests too)
    (with provided injector)     
{'fraction_non_alphanumeric': 0.07192058346839546, 'fraction_numerical': 0.008103727714748784, 'mean_word_length': 4.855871886120997, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1980849', 'n_tokens_mistral': 2708, 'n_tokens_neox': 2509, 'n_words': 1079}