Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple ServiceLocators #46

Open
jmif opened this issue Nov 18, 2018 · 0 comments
Open

Multiple ServiceLocators #46

jmif opened this issue Nov 18, 2018 · 0 comments

Comments

@jmif
Copy link

jmif commented Nov 18, 2018

I've just upgraded to dropwizard-guicier and have a question regarding the logic used in the ServiceLocatorGenerator installed here.

In previous versions of this repo and in dropwizard-guice the Guice Injector is is used to generate the ServiceLocator regardless of the __HK2_ index (it uses Guice as the source injector for 0 / 1 / 2 / etc). In 1.3.5.0 (and I believe a few of the previous versions as well) only one HK2 service locator is overridden.

My Jersey clients use some @Providers that need to be injected from the Guice injector and this injection worked because every HK2 ServiceLocator was sent to the Guice injector in dropwizard-guice. Now it seems only the Jersey server one is proxied and thus my Jersey Clients are broken. The other HK2 generated items get a new service locator.

Is this intentional / expected? If so is there a recommended work around? I'm new to this area of Jersey and am just beginning to understand the way HK2 works / the Jersey Guice binding works, so I can't tell what the expected / desirable behavior is.

For context, this is how I create the Jersey Client inside of Guice.

@Provides
public synchronized Client getJerseyClient(Environment environment, ApiApplication application,
                                               ApiConfiguration configuration) {

    if (this.jerseyHttpClient == null) {
        this.jerseyHttpClient = new JerseyClientBuilder(environment)
                .using(configuration.getJerseyClientConfiguration())
                .build(application.getName() + "-jersey-client")
                .register(MessageBodyReaderThatRequiresInjection.class);
    }

    return this.jerseyHttpClient;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant