users@hk2.java.net

InstanceLifeCycleListener examples?

From: buko <buko_at_chiubarobot.com>
Date: Wed, 7 Aug 2013 08:43:54 -0400

Are there any examples of custom InstanceLifeCycleListeners out there?

I'm looking to do some basic post-processing of managed objects. In the
normal injection phase a resource is passed to the ctor. In the next phase
I'd like to go back and use the injected resource to further customize the
object.

I've taken a look at ConfigInstanceListener and don't quite get it.

Does the lifecycle object (post-processing target?) need to implement a
specific interface in order for the Filter to match? Ideally I'd like to
just slap an annotation on them. But it's not clear how to construct a
Filter that matches an annotation.

If I need to actually initialize/wrap/set fields on the lifecycle object
does hk2 offer any facilities for that? Should normal java reflection be
used? I'm worried this won't work if the post-processing object is proxied
by hk2. Do InstanceLifeCycleListeners get called for the creation of
proxies if the underlying object hasn't been created yet?

What does InstanceLifeCycleEvent#knownInjectees return? Are these the same
injectees that are passed to a custom InjectionResolver?

Thanks for any help.