[ http://issues.apache.org/jira/browse/JCR-561?page=all ]
Felix Meschberger closed JCR-561. --------------------------------- I think this can be closed now. > Add support to provide custom classloader for class instantiation from > configuration > ------------------------------------------------------------------------------------ > > Key: JCR-561 > URL: http://issues.apache.org/jira/browse/JCR-561 > Project: Jackrabbit > Issue Type: Improvement > Components: config > Affects Versions: 1.0, 1.0.1, 0.9 > Reporter: Felix Meschberger > Assigned To: Felix Meschberger > Fix For: 1.1 > > > The configuration framework is based around a BaseConfig class, which > provides functionality to instantiate a class whose name is configured in the > repository configuration file. Examples of such classes are the FileSystem or > the PersistenceManager elements. > The current implementation of the BeanConfig.newInstance() method is to use > the "default classloader" to load configured classes. That is, the class > loader of the BeanConfig class is actually used. This is - generally - the > class loader which loads the repository. In certain environments, classes may > be provided from outside the core repository class loader. An example fo such > an environment is an OSGi setup where each bundle gets its own class laoder, > which is separate from all other class loaders except declared by > configuration. > I propose to enhance the BeanConfig class as follows: > public class BeanConfig { > ... > // Current default class loader, default is BeanConfig's class loader > private static ClassLoader defaultClassLoader = > BeanConfig.class.getClassLoader(); > // Current instance class loader > private ClassLoader classLoader; > ... > // Sets the default class loader for new BeanConfig instances > public static void setDefaultClassLoader(ClassLoader loader); > // Returns the default class loader for new BeanConfig instances > public static ClassLoader getClassLoader(); > // Sets the class loader of this BeanConfig instance > public void setClassLoader(ClassLoader loader); > // Returns the class loader of this BeanConfig instance > public ClassLoader getClassLoader(); > } > The BeanConfig.newInstance method would then use the following to use the > class: > public Object newInstance() throws ConfigurationException { > Class clazz = Class.forName(getClassName(), true, getClassLoader()); > ... > } > This has also been discussed on the dev list: > http://mail-archives.apache.org/mod_mbox/jackrabbit-dev/200607.mbox/[EMAIL > PROTECTED] -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira