[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[xmlblaster-devel] JBoss support/ClassLoaderFactory
Hi,
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 useXmlBlasterClassloader =
getProperty().get("useXmlBlasterClassloader", true);
if (useXmlBlasterClassloader == 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
--
------------------------------------------------------------
Peter Antman Chief Technology Officer, Development
Technology in Media, Box 34105 100 26 Stockholm
WWW: http://www.tim.se WWW: http://www.backsource.org
Email: pra at tim.se
Phone: +46-(0)8-506 381 11 Mobile: +46-(0)704 20 58 11
------------------------------------------------------------