dev@glassfish.java.net

Custom asadmin sub-command questions

From: Ancoron Luciferis <ancoron.luciferis_at_googlemail.com>
Date: Wed, 22 Feb 2012 20:09:53 +0100

Hi devs,

I'm currently implementing some asadmin sub-commands and need some help
with issues that I face:

1.) I the add-on developer guide I read that I should put the HK2 jar
under .../glassfish/modules/. Well, I violated this and instead put it
under .../autodeploy/bundles/ and it still works. Nice so far. Now comes
the issue: my commands need some OSGi services that I provide
dynamically (or not) and depending on availability the commands do
different things or just don't. What I started with was the HK2 @Inject
annotation as it seemed to inject my OSGi services just fine. However,
if I update one of those other services I get something like this:

ClassCastException: $Proxy489 cannot be cast to <interface>

As far as I understand the use of HK2 in GlassFish I though that it
would build on top of OSGi or am I wrong here?

Anyway, is there a way to fix this (my implementations are always marked
as @PerLookup - assuming it does injection also at every instance
creation). Also I assumed that the habitat would get updated with new
OSGi services.


2.) I also observed that I cannot "update" such an HK2-jar. The OSGi
part seems to get updated but not the HK2 part. How can I trigger this?


3.) One of my sub-commands trigger something on another OSGi service
asynchronously and I implemented a callbackhandler-like infrastructure
(using OSGi-events) to get notified of the work being done. Now this
might take quite some time and I wanted to output those notifications
back to the console. This part, however doesn't seem to work as I always
get all output at the very end in one big batch. Also, I sometimes run
into the timeout that grizzly seems to apply for the internal HTTP
requests. So, is it possible to "stream" the output?

That's what I did back in the good old Servlet days.


Thanx for any pointers and help,

        Ancoron