dev@glassfish.java.net

Re: How to access Habitat from a Web Application?

From: Lloyd Chambers <Lloyd.Chambers_at_Sun.COM>
Date: Mon, 19 Oct 2009 15:19:29 -0700

I do it by having an @Service into which Habitat and other stuff is
injected.

Then I have getter methods on that service.


/**
Utility class that gets various useful values injected into it for use
by other AMX facilities which don't have injection available to
themselves. This is needed
because many AMX MBeans and support code don't have any access to
injection.
  */
@Service
@Async
public class InjectedValues
{
     @Inject
     Habitat mHabitat;
...
     public static InjectedValues getInstance()
     {
         return getDefaultHabitat().getByType(InjectedValues.class);
     }


     public Habitat getHabitat()
     {
         return mHabitat;
     }
...



On Oct 19, 2009, at 2:55 PM, Byron Nevins wrote:

> I want to use an object that is inside the Habitat in V3 -- from my
> web app. I don't need to @Inject -- I just want to get a reference
> to the Habitat.
> Has anyone done this? Any tips/ideas?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>

Lloyd Chambers
lloyd.chambers_at_sun.com
GlassFish Team