]
Manik Surtani commented on JBCACHE-1300:
----------------------------------------
I agree that overriding bootstrap() to set the default class loader is fragile.
What I can do is expose a (protected) setDefaultClassLoader() method on the
DefaultCacheFactory, which can be used by subclasses such as yours to set the default
class loader. Or maybe this should be public, even? Thoughts?
Standardize mechanism for setting defaultClassLoader
----------------------------------------------------
Key: JBCACHE-1300
URL:
http://jira.jboss.com/jira/browse/JBCACHE-1300
Project: JBoss Cache
Issue Type: Feature Request
Security Level: Public(Everyone can see)
Reporter: Brian Stansberry
Assigned To: Manik Surtani
Priority: Minor
Fix For: 2.1.0.GA
Right now the default classloader used by the cache's marshaller is fixed to
CacheImpl.class.getClassLoader(), with no clear mechanism for users to change that.
In the Hibernate/JBC testsuite I did the following:
public class CustomClassLoaderCacheFactory<K, V> extends DefaultCacheFactory<K,
V>
{
private ClassLoader customClassLoader;
public CustomClassLoaderCacheFactory(ClassLoader customClassLoader)
{
this.customClassLoader = customClassLoader;
}
@Override
protected void bootstrap(CacheImpl cache, CacheSPI spi, Configuration configuration)
{
super.bootstrap(cache, spi, configuration);
// Replace the deployerClassLoader
componentRegistry.registerComponent("deployerClassLoader",
customClassLoader, ClassLoader.class);
}
}
That works, but seems fragile, e.g .if how super.bootstrap() works changes it could
break. It would be better to have something more standardized; perhaps a property on
DefaultCacheFactory that could be set, w/ a guarantee in the DefaultCacheFactory javadoc
that it will be used if set.
Or something else. :-) Manik, not sure where you're planning to go w/
defaultClassLoader; I'm just throwing this request out there to get the topic in
JIRA.
OT: doing this is great in testsuites, as you can use it to configure a default
classloader that can't see some of your test classes, and thus test marshalling.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: