OSGi bundles in web app [message #65258] |
Sat, 22 April 2006 01:41  |
Eclipse User |
|
|
|
Hi,
What is the best way to include some OSGi plugins in a web application, to
be used as a library for the web-application code (the web app code is not
organized in OSGi bundles, it is just any regular web-app java code). If the
plugins jar are not in WEB-INF/lib, the web-app code can't access it
directly. If all the code is in WEB-INF/lib, it breaks the eclipse extension
mechanism between the bundles.
Is there any example of this configuration available?
Thanks,
David
|
|
|
|
Re: OSGi bundles in web app [message #65300 is a reply to message #65279] |
Sun, 23 April 2006 12:09   |
Eclipse User |
|
|
|
Hi Simon,
Thank you for your answer. However I don't think we can register a call-back
method in the webapp code. The reason is that we provide the OSGi
bundles/Eclipse plugins as a library, so that anybody can use them in his
own web-application without restriction. There is a lot of API code you
might to access from the web-app, and we can't use an invasive approach
where the web-app has to declare some call-back functions for each API class
or use the OSGi framework for its servlets/JSP code.
Is there anyway to inform the web-app to use the OSGi classloader when
starting the OSGi framework? What do exactly the settings
osgi.parentClassloader=fwk and org.osgi.framework.bootdelegation=* do?
Otherwise if we move all plugins/bundles under WEB-INF/lib, what causes the
OSGi framework to fail loading the plugin/bundle extensions?
Thanks,
David
"Simon Kaegi" <skaegi@sympatico.ca> wrote in message
news:e2fpdv$dl7$1@utils.eclipse.org...
> Hi David,
>
>> What is the best way to include some OSGi plugins in a web application,
>> to
>> be used as a library for the web-application code (the web app code is
>> not
>> organized in OSGi bundles, it is just any regular web-app java code). If
> the
>> plugins jar are not in WEB-INF/lib, the web-app code can't access it
>> directly. If all the code is in WEB-INF/lib, it breaks the eclipse
> extension
>> mechanism between the bundles.
>
> You're right in that this is a bit tricky.
> The problem here is that without the servlet container providing direct
> OSGi
> support, the webapp classloader is going to "parent" (in the classloader
> sense) the OSGi framework. As a result the OSGi framework "can" see the
> jars
> in WEB-INF/lib but but not vice-versa (at least directly).
> To expose functionality what you're left with is an approach where a
> bundle
> will register a "call-back" function against a singleton or static in the
> webapps code.
>
>> Is there any example of this configuration available?
> Take a look at the server-side incubator and specifically
> http://www.eclipse.org/equinox/incubator/server/embedding_in _a_servlet_container.php
> The call-back approach is how the Servlet Bridge exposes a callable
> servlet
> interface back to the servlet container.
>
> -Simon
>
>
|
|
|
Re: OSGi bundles in web app [message #65321 is a reply to message #65300] |
Mon, 24 April 2006 10:12  |
Eclipse User |
|
|
|
Originally posted by: skaegi.sympatico.ca
> Is there anyway to inform the web-app to use the OSGi classloader when
> starting the OSGi framework? What do exactly the settings
> osgi.parentClassloader=fwk and org.osgi.framework.bootdelegation=* do?
What happens is that the webapp classloader parent's the framework's
classloader (e.g. the org.eclipse.osgi).
Every other bundle is parented by the classloader according to the
osgi.parentClassloader setting.
osgi.framework.bootdelegation filters what classes are visible for parent
delegation for these bundles (everything except org.eclipse.osgi).
> Otherwise if we move all plugins/bundles under WEB-INF/lib, what causes
the
> OSGi framework to fail loading the plugin/bundle extensions?
This should work with servlet containers that unpack the WAR to the file
system.
If you use ths approach you'll probably also need to set up
"osgi.configuration.area" as some bundles need to use disk.
--
Rather than using "osgi.parentClassloader=fwk" you might consider using
"extension bundles" {3.15 of the spec}
Also see https://bugs.eclipse.org/bugs/show_bug.cgi?id=131253
The advantage here is that you can be more selective over what is exported
from the webapp classloader.
-Simon
|
|
|
Powered by
FUDForum. Page generated in 0.03118 seconds