users@glassfish.java.net

Re: Inject Glassfish components in a lifecyle listener module

From: <hong.hz.zhang_at_oracle.com>
Date: Wed, 21 Dec 2011 21:12:35 -0500

You can try to use Globals to get the components from HK2 habitat in
this case:

import org.jvnet.hk2.component.Habitat;
import org.glassfish.internal.api.Globals;
...

     Habitat habitat = Globals.getDefaultHabitat();
     RecoveryResourceRegistry registry =
habitat.getComponent(RecoveryResourceRegistry .class);

- Hong


On 12/20/2011 11:54 AM, BRASSELY David wrote:
>
> Hi,
>
> I'm trying to develop a Lifecycle Listener module
> <http://glassfish.java.net/nonav/docs/v3/api/com/sun/appserv/server/LifecycleListener.html>
> for which I need to get access to the
> com.sun.enterprise.transaction.api.RecoveryResourceRegistry singleton
> and many other things like Config (http-listener, https-listener,
> ...). But I encounter a problem because I don't know what is the best
> way to inject these components into my lifecyle listener class.
>
> For now, my lifecycle is declared in the domain.xml file with the help
> of the corresponding asadmin command and is correctly loaded during
> the glassfish startup. I tried to add a simple @Inject in my class but
> it didn't work...
>
> Please note that it's my first development under Glassfish v3...
>
> Any suggestion ?
>
> Thanks,
>
> David BRASSELY
>