users@jersey.java.net

[Jersey] [Jersey 2] Integrate HK2 with Picocontainer - lazy resolution of singletons

From: marianl <marianl_at_o2.pl>
Date: Tue, 19 Feb 2013 18:38:57 +0100

Hello,

I have DI container and I'd like to expose its singletons for Jersey.
I've seen that there are AbstractBuilder and Injections which might help with that.

Getting instances from picocontainer and binding them inside AbstractBuilder#configure method works, but I don't want to do eager binding. I'd like to create instances later, when they are needed.

How can I achieve that?

Issues I've encountered:
I don't how can I use class bindings because when I tried that then HK2 says it cannot resolve dependencies. Is there some contract I need to implement to get a chance of providing concrete instance of desired type?
I don't know if I'm missing something or there is other way to do it.

Possible solution:
Bind java.lang.reflect.Proxy which will do lazy resolution.

Kind regards,
Marek