[weld-issues] [JBoss JIRA] Commented: (WELDSE-25) Weld SE ignores org.jboss.weld.resources.spi.ResourceLoader
Morten Christensen (JIRA)
jira-events at lists.jboss.org
Mon May 10 09:53:05 EDT 2010
[ https://jira.jboss.org/jira/browse/WELDSE-25?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12529904#action_12529904 ]
Morten Christensen commented on WELDSE-25:
------------------------------------------
I would like to pass a classloader to the Weld Class, because how classloading works and what is permitted differes from container to container. In JEE the context class loader can be used, in JSE it might depending on the Application and in OSGI it should NOT be used (it will not work accross different OSGI containers). So in conclusion, it is only in the JEE wold that that Weld can make an informed decision about classloading, in all other cases Weld need to be configurable.
Here is the class loader that I would like to be able to use under OSGI and pass to the Weld constructor. Looking at the Weld sources it would seem on the surface to be easy to just overload the constructor and pass the class-loader to all relevant objects inside it. This would be the solution I like the best, as the ResourceLoader solution would need a static variable to pass data between my OSGI bundle's activator method and Weld (And I do hate to use static variables unless I have to)
Sample OSGI bundle class loader below. Please be free to use this code for whatever purpose you want.
import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import org.osgi.framework.Bundle;
public class BundleClassLoader extends ClassLoader {
private final Bundle delegate;
public BundleClassLoader(Bundle delegate) {
this.delegate = delegate;
}
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
return delegate.loadClass(name);
}
@Override
public URL getResource(String name) {
return delegate.getResource(name);
}
@SuppressWarnings("unchecked")
@Override
public Enumeration<URL> getResources(String name) throws IOException {
return delegate.getResources(name);
}
}
> Weld SE ignores org.jboss.weld.resources.spi.ResourceLoader
> -----------------------------------------------------------
>
> Key: WELDSE-25
> URL: https://jira.jboss.org/jira/browse/WELDSE-25
> Project: Weld support for Java SE
> Issue Type: Bug
> Affects Versions: 1.0.1.Final
> Environment: Weld SE + Java 6
> Reporter: Morten Christensen
> Priority: Critical
>
> According to the docs "org.jboss.weld.resources.spi.ResourceLoader" is responsible for resource loading/class creation and if it worked it would appear to solve a lot of potential integration problems, f.x. with OSGI (see issue 520).
> Unfortunately, Weld SE does not apper to use ResourceLoaders and it ignores any implementations of this service that the Java SE app supplies. Even worse, Weld SE classloading behavior is hardcoded in "org.jboss.weld.environment.se.util.Reflections". This makes it impossible to use Weld SE where classloading does not work with the Thread's context class loader such as OSGI etc.
> Weld SE should be changed to look for service implementations of "org.jboss.weld.resources.spi.ResourceLoader" (i.e. actually work according to its own documentation).
> P.S: It would also be nice if Weld SE would allow users to supply a Classloader to the constructor for org.jboss.weld.environment.se.Weld
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the weld-issues
mailing list