Hi,s
I have done a first round of updates to the j2ee (JBoss) support that I
would like to commit. However, to get it to work I had to abstract the
way XMlBlaster handles the ClassLoaderFactory.
Basically I have done this:
Made ClassLoaderFactory and intercace:
public interface ClassLoaderFactory {
public void init(Global glob);
public URLClassLoader getPluginClassLoader(PluginInfo pluginInfo)
throws XmlBlasterException;
public URLClassLoader getXmlBlasterClassLoader() throws
XmlBlasterException;
}
Moved the old implementation to StandaloneClassLoaderFactory. Created an
aditional factory: ContextClassLoaderFactory, which used returnes the
context class loader.
Which factory to use is now configurable with the property
classLoaderFactory. Here's the new method in Global:
public ClassLoaderFactory getClassLoaderFactory() {
boolean usemlBlasterClassloader =
getProperty().get("usemlBlasterClassloader", true);
if (usemlBlasterClassloader == false) return null;
synchronized (ClassLoaderFactory.class) {
if (classLoaderFactory == null) {
String clf =
getProperty().get("classLoaderFactory",(String)null);
if ( clf != null) {
try {
Class clfc =
Thread.currentThread().getContextClassLoader().loadClass(clf);
classLoaderFactory =
(ClassLoaderFactory)clfc.newInstance();
classLoaderFactory.init(this);
return classLoaderFactory;
} catch (Exception e) {
log.warn(ME,"Could not load custom classLoaderFactory
" + clf + " using StandaloneClassLoaderFactory");
} // end of try-catch
} // end of if ()
classLoaderFactory = new StandaloneClassLoaderFactory(this);
}
}
return classLoaderFactory;
}
Basically I am wondering if this is an ok change to check in, or if you
would like it done in a different way?
//Peter