dev@glassfish.java.net

[how-to] Dynamic asadmin sub-commands - was: Custom asadmin sub-command questions

From: Ancoron Luciferis <ancoron.luciferis_at_googlemail.com>
Date: Thu, 28 Jun 2012 03:50:18 +0200

Hi Sahoo, hi devs,

just wanted to let you know that I've found some time again to finally
finish this little thing.

Now it's easier than ever to get an AdminCommand online and behaving
like some OSGi service:

https://github.com/ancoron/gf-samples/wiki/Dynamic-GlassFish-asadmin-sub-commands


Cheers,

        Ancoron


On 02/23/2012 09:52 AM, Sahoo wrote:
> On Thursday 23 February 2012 02:11 PM, Ancoron Luciferis wrote:
>> On 02/23/2012 09:18 AM, Sahoo wrote:
>>> On Thursday 23 February 2012 01:31 PM, Ancoron Luciferis wrote:
>>>> On 02/23/2012 02:39 AM, Sahoo wrote:
>>>>> No, HK2 does not handle bundle removal or updation very well. It can
>>>>> handle new bundles getting installed at runtime. So, don't update your
>>>>> hk2-jar at runtime; instead shutdown the system and restart. It's
>>>>> not a
>>>>> bug in HK2/OSGi bridge. I doubt we are going to address this - it
>>>>> requires deep changes in HK2 to refresh its internal objects when
>>>>> bundles get removed/updated.
>>>>>
>>>>> I don't know about the streaming to the console part. That seems
>>>>> like a
>>>>> question for admin folks.
>>>>>
>>>>> Sahoo
>>>>
>>>> Hi Sahoo,
>>>>
>>>> thank you for the insight.
>>>>
>>>> As a workaround, would it be possible to (un-)register HK2 services in
>>>> a programmatic way from OSGi bundles, e.g. using an activator or an
>>>> extender?
>>>>
>>> You have two choices:
>>> a) You can use Habitat object to unregister/register yourself HK2
>>> service.
>>> b) You could also expose your service as OSGi service with a
>>> component.name service property (set this to the name that you use while
>>> using looking up the HK2 service) and let it be automatically
>>> added/removed to/from the HK2 service registry as a named HK2 service.
>>>
>>> Sahoo
>>
>> Ah, thanx again. That's what I was hoping for. :)
>>
>> Btw. what's the best way to retrieve the habitat?
>>
> @Inject Habitat or look it up in OSGi Service registry.
>
> Sahoo