Richard S. Hall wrote:

Sylvain Wallez wrote:

What comes to mind is to wrap services obtained from a bundle with a proxy that sets the context classloader to the bundle's classloader at each method call of the service.



I guess I don't fully comprehend the details of the issue. If you are inside the bundle's service, then it already has access to the bundle's class loader, since all of its classes are loaded by it and it will be used to load any further classes. What am I missing?


There's a lot of existing code that uses Thread.getContextClassLoader().loadClass() to dynamically load classes instead of using Class.forName(). This is to solve the common problem in app servers where such classes would be in the server's classloader (e.g. the "shared" directory in Tomcat [1]) and would load classes defined by the webapp classloader of the currently executing request.

How will such code behave in an OSGi container? My (random) thought was about this.

Hope I made it clearer :-)

Sylvain

[1] http://jakarta.apache.org/tomcat/tomcat-5.5-doc/class-loader-howto.html

--
Sylvain Wallez                        Anyware Technologies
http://people.apache.org/~sylvain     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director

Reply via email to