dev@glassfish.java.net

Habitat.getComponent default

From: Bill Shannon <bill.shannon_at_sun.com>
Date: Fri, 14 Aug 2009 14:42:13 -0700

I'm fixing:
https://glassfish.dev.java.net/issues/show_bug.cgi?id=9015

The core problem is that AdminAdapter tries to map various strings
to a corresponding ActionReport class. The strings it tries to
map are:

User Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.3)
Gecko/2008092414 Firefox/3.0.3
Accept: text/html
Accept: application/xhtml+xml
Accept: application/xml;q=0.9
Accept: */*;q=0.8

In each case it calls habitat.getComponent with ActionReport.class
and a name that's the string above *after* the '/'.

(Really this is pretty lame and it ought to be doing a better parse
of the string and using the text before the '/' and less text after
the '/'.)

The various ActionReport subclasses have @Service(name = "XXX"),
where XXX is expected to match the string.

That is, except for the HTMLActionReport, which has no name.

If all the above lookups fail, AdminAdapter calls
habitat.getComponent(ActionReport.class).

It looks like it's assuming that it's going to get the one with no name.
It doesn't. It gets the new XMLContentActionReport that I added to support
getting command metadata. And that surprising match causes failures
later on, which results in no output for the request.

The simple fix seems to be to change HTMLActionReport to have
@Service(name = "html")
Any idea if that will break anything else?

Is it possible that Habitat.getComponent is actually what's broken in
this case? *Should* it be returning the component with no name?