dev@glassfish.java.net

Re: WebSniffer and OSGi

From: Jerome Dochez <Jerome.Dochez_at_Sun.COM>
Date: Thu, 24 Apr 2008 21:22:15 -0700

On Apr 24, 2008, at 8:27 PM, Sahoo wrote:

> Roberto Chinnici wrote:
>> While implementing the Phobos container for V3, I saw this comment
>> in the code for the WebSniffer (in the org.glassfish.web:gf-web-
>> connector module):
>>
>> // Commented out by Sahoo, as in OSGi environment, we can't support
>> // Module.addImport. So, temporarily we add webtier to the dependency
>> // list of gf-web-sniffer.
>> // public Module[] setup(String containerHome, Logger logger)
>> throws IOException {
>> // Module[] modules = new Module[1];
>> // modules[0] =
>> modulesRegistry.makeModuleFor("org.glassfish.web:webtier", null);
>> // if (modules[0]==null) {
>> // throw new IOException("Webtier module not found, web
>> container is not installed or found");
>> // }
>> // return modules;
>> // }
>>
>> This means that the sniffer module depends on the main web tier
>> module, which defeats the purpose of sniffers. Also, this is an
>> obstacle to providing a small distribution, because inclusion of
>> the sniffer will trigger inclusion of the whole web container.
>>
>> I understand that this is a temporary measure, but going forward
>> what's going to be the mechanism to enable sniffers to dynamically
>> load the container they sniff for? Will the HK2 module registry
>> APIs call into the OSGi layer to install and start the dependent
>> bundle? Or is there going to be a new API?
>>
> The issue is not about downloading bundles or installing them. The
> real problem is addImport() tries to *add* a new dependency for a
> bundle after it is installed (e.g. in the above case, it was adding
> a dependency on gf-web-container after gf-web-connector was
> installed), which is not allowed in OSGi. I am still not convinced
> as to why we need that.

The code commented had nothing to do with adding a dependency after a
module is installed.

The code above is just about giving the main module id to the V3 so it
can be used to set the context class loader when doing request
dispatching.

Roberto, in general, you sniffer does not need to depend on your
container module. The sniffers responsibilities are just to install
the container (maybe downloading it) and return the container main
modules. After that the sniffer has the give the name of the container
class as a string which will be looked up in the modules returned by
setup().

does that clarify ?

jerome

>
>
> Thanks,
> Sahoo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>