"flavia.rainone(a)jboss.com" wrote :
| I have committed a temporary ugly hack, but I need to figure out how can I retrieve
the classLoader in this scenario.
|
I've now at least removed the super horrible hack,
but this code definitely needs a proper cleanup,
as I've still found a bunch of weird things; catching NPE to do some logic, ...
I've currently used reflection to get to the underlying classloader.
This might not be so hackish, but we could still make some effort to see if there is a
better way of doing this.
| static
| {
| getClassLoader = AccessController.doPrivileged(new
PrivilegedAction<Method>()
| {
| public Method run()
| {
| try
| {
| Method method =
BaseClassLoaderSource.class.getDeclaredMethod("getClassLoader");
| method.setAccessible(true);
| return method;
| }
| catch (NoSuchMethodException e)
| {
| throw new RuntimeException("Cannot get classloader from " +
BaseClassLoaderSource.class.getName(), e);
| }
| }
| });
| }
|
| static ClassLoader getClassLoader(BaseClassLoaderSource clSource)
| {
| try
| {
| return (ClassLoader)getClassLoader.invoke(clSource);
| }
| catch (Exception e)
| {
| throw new RuntimeException(e);
| }
| }
|
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4262606#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...