myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leonardo Uribe (JIRA)" <>
Subject [jira] Commented: (MYFACES-2290) Add OSGi bundle information and bundle classloader / activator
Date Wed, 28 Oct 2009 17:01:59 GMT


Leonardo Uribe commented on MYFACES-2290:

It seems spring dm has already solved the problem with Thread.currentThread().getContextClassLoader().
Look this blog:

the important part is below:

"......Thread context classloader management

Many third-party libraries use the thread context ClassLoader to access application types
and resources. Each bundle in OSGi has it's own ClassLoader, so therefore, only one bundle
can be exposed as the thread context ClassLoader at any time. This means that if a third-party
library needs to see types that are distributed across multiple bundles, it isn't going to
work as expected.

The Platform fixes this by creating a ClassLoader that imports all the exported packages of
every module in your application. This ClassLoader is then exposed as the thread context ClassLoader,
enabling third-party libraries to see all the exported types in your application........"

Use a BundleActivator is the OSGi suggested way to solve this issues, but given the context
of the problem, it seems better to do not use a BundleActivator and use spring dm to deal
with this stuff.

But note this link:

in SpringSource Bundle Repository it is possible to find a OSGi bundle for myfaces.  This
is the manifest for myfaces-api.jar

Manifest-Version: 1.0
Export-Package: javax.faces;provider="myfaces";version="1.2.2",javax.f
Implementation-Title: Apache Myfaces JSF Core-1.2 API
Bundle-Classpath: .
Implementation-Version: 1.2.2
Built-By: lu4242
Bundle-Name: Apache MyFaces JSF API
Created-By: Apache Maven
Bundle-Vendor: SpringSource
Implementation-Vendor: The Apache Software Foundation
Implementation-Vendor-Id: org.apache.myfaces.core
Build-Jdk: 1.6.0_02
Bundle-Version: 1.2.2
Bundle-ManifestVersion: 2
Import-Package: javax.el;version="[1.0.0, 2.0.0)",javax.servlet;versio
 n="[2.5.0, 3.0.0)",javax.servlet.http;version="[2.5.0, 3.0.0)",javax.
 servlet.jsp;version="[2.1.0, 3.0.0)",javax.servlet.jsp.jstl.core;vers
 ion="[1.1.2, 2.0.0)",javax.servlet.jsp.jstl.sql;version="[1.1.2, 2.0.
 0)",javax.servlet.jsp.tagext;version="[2.1.0, 3.0.0)",org.apache.comm
 ons.logging;version="[1.1.1, 2.0.0)"
Archiver-Version: Plexus Archiver

Conclusion: The best we can do from myfaces side is use org.apache.felix maven-bundle-plugin
to create a manifest in the way described before without include BundleActivator classes,
and let this issue open, so if somebody wants to use the BundleActivator way, he/she can change
the code adding it. The only thing left is set the context class loader for Digester instances
to org.apache.myfaces.shared_impl.util.ClassUtils.getContextClassLoader().

> Add OSGi bundle information and bundle classloader / activator
> --------------------------------------------------------------
>                 Key: MYFACES-2290
>                 URL:
>             Project: MyFaces Core
>          Issue Type: New Feature
>          Components: General
>    Affects Versions: 1.2.8-SNAPSHOT
>         Environment: OSGi (Equinox, Apache Felix, ...)
>            Reporter: Felix Röthenbacher
>            Assignee: Leonardo Uribe
>            Priority: Critical
>         Attachments: myfaces-core.diff.txt, myfaces-shared.diff.txt
> The provided patch will add OSGi information to bundle manifest. A bundle activator class
makes the MyFaces framework aware that it is running in a bundle environment. A bundle classloader
is used to load classes and resources from the bundle classpath. The patch doesn't require
any new runtime dependencies and doesn't affect class loading in a non-OSGi environment. Though,
small modifications to classloading were needed. This was mainly replacing Thread.currentThread.getContextClassLoader()
with ClassUtils methods.
> To run MyFaces in an OSGi environment both bundles (myfaces-api and myfaces-impl) have
to be started in the OSGi container. Additionally, the myfaces-impl bundle has to be made
available to myfaces-api. Use a fragment bundle with myfaces-api as Fragment-Host and myfaces-impl
as Required-Bundle.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message