users@glassfish.java.net

Re: Inject Glassfish components in a lifecyle listener module

From: Tom Mueller <tom.mueller_at_oracle.com>
Date: Thu, 22 Dec 2011 09:23:05 -0600

Another option might be to use an EventListener with the @Service
annotation which implements the Startup interface rather than a
LifecycleModule. This would give you the server status change events
and the use of injection.

Tom


On 12/21/2011 8:12 PM, hong.hz.zhang_at_oracle.com wrote:
> 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
>>