glassfish-hk2 icon indicating copy to clipboard operation
glassfish-hk2 copied to clipboard

Custom ExecutorServiceProvider is not injected using hk2 >= 2.4.0 using ServiceLocator

Open glassfishrobot opened this issue 7 years ago • 1 comments

Hi. I've created linked issue for Jersey https://github.com/jersey/jersey/issues/3695.

I've used Jersey 2.13 and hk2 2.3.0-b** and everything works fine.

The following problem appears when i switch to Jersey 2.25.1 and hk2 >=2.4.0.

My custom CustomExecutorProviderannotated with @ManagedAsyncExecutor stopped being injected during runtime.

I register my custom provider through

d = new DescriptorImpl();
            d.setImplementation(CustomExecutorProvider.class.getName());
            d.addAdvertisedContract(ExecutorServiceProvider.class.getName());
            d.setScope(Singleton.class.getName());
            d.setName("CustomExecutorProvider");

            dc.bind(d);

But i dont get my CustomExecutorProvider when i have async request incoming (i get default jersey-executor-provider)

If i annotate my CustomExecutorProvider with org.glassfish.jersey.internal.inject.Custom internal annotation everything starts working.

Also do following snippet Injections also begins working:

Injections.addBinding(Injections.newBinder(CustomExecutorProvider.class).
                            to(ExecutorServiceProvider.class).
                            in(Singleton.class).
                            qualifiedBy(CustomAnnotationLiteral.INSTANCE).
                            named("CustomExecutorProvider"),
                    dc);

As i understand hk2 should internally annotate my ExecutorServiceProvider with @Custom annotation for further processing by Jersey.

I've also noticed that injection does not work when i switch from [Jersey 2.13, hk2 2.3.0-b**] to [Jersey 2.13, hk2 2.5.0-b**] (just update hk2).

Please check following https://github.com/hwasin/jettyJerseySandbox for bug reproduce

Thank you very much!

glassfishrobot avatar Oct 13 '17 11:10 glassfishrobot

  • Issue Imported From: https://github.com/javaee/hk2/issues/375
  • Original Issue Raised By:@hwasin
  • Original Issue Assigned To: Unassigned

glassfishrobot avatar Aug 30 '18 10:08 glassfishrobot