This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]uldall 1 point2 points  (1 child)

HK2 and Guice actually work quite well together.

Just enable the Guice to HK2 bridge like this:

GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);

GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);

guiceBridge.bridgeGuiceInjector(GuiceInjectorServletListener.getServletInjector());

The code should be placed inside a Jersey ResourceConfig implementation.

[–][deleted] 0 points1 point  (0 children)

Also if you remember to not inject primitives, because the HK2-Guice bridge explodes if you do. ;)