dev@glassfish.java.net

Re: Handle to Container from within AdminCommand

From: Tom Mueller <tom.mueller_at_oracle.com>
Date: Tue, 04 Jan 2011 10:47:30 -0600

You should be able to inject your own container in a generic way using:

@Inject(name="containername")
Container mycontainer;

if the container declaration has

@Service(name="containername")

The @TargetType annotation is part of the command replication framework
for clustering. Details are described here:
http://wikis.sun.com/display/GlassFish/CLIDeveloperGuide


The habitat can be injected with:

@Inject
Habitat habitat;


Tom


On 1/3/2011 8:48 PM, Lee Chuk Munn wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi
>
> I'm trying to get a reference to my container (implements
> org.glassfish.api.container.Container) from with my asadmin subcommand.
> Is there a way to get this? I was looking through the source for
> list-commands and in particular ListComponentsCommand.java. I saw the
> annotation @TargetType but I could not find the javadoc for this. Is
> this the annotation that I should use?
>
> A second related question is that if I have my own Java object, is there
> a way to get HK2/GF to programatically inject objects like ConfigParser,
> Habitat, etc into it?
>
> Thanks
>
> Regards
> Chuk
>
> - --
> If we're supposed to work in Hex, why have we only got A fingers?
> -- johnwm
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQEcBAEBAgAGBQJNIop8AAoJEAnxPH9ZReNja5QIAKNL6M/vK93AgQo4TAmuNdFY
> Z0nv+x1j18CCbgRip9ATkO9ScBMzc2Wl0Ck8ZPtmukgKZjdbBoO3KUKCH8FCGf59
> F/U0AIhp7AKhMRJcHo/nxmGGrq9oWFNj+gYaemuk8vxlL59kp13cSnUQtdJy1AJO
> JdV12r6RANntqM+GME06xjX6Skyp27LBQdRbxL3CR1zOhcA6NrvjYH1Ch1jyKkUa
> PVo3I0NpHO/+m113B3lI0+K7uZ5whDLWtYqHf+/g8RyXImZPAHKRp1Vz6qDuHUze
> M+utTTimKJcugXxeugcqmXhOlK86KVMZwx5Owdlb1U2pnYiFM9eUUy79rJ/BdCE=
> =Jkd/
> -----END PGP SIGNATURE-----