[jboss-dev-forums] [Design of POJO Server] - JBVFS-67, VFSCacheFactory.getInstance(String defaultCacheImp
scott.stark@jboss.org
do-not-reply at jboss.com
Thu Nov 6 12:27:31 EST 2008
I want to add a VFSCacheFactory.getInstance(String defaultCacheImpl) factory method so we can set the cache to use in the beans descriptor rather than having to set a system property. I would say this value takes precedence over the system property:
| public static VFSCache getInstance()
| {
| return getInstance(null);
| }
| public static VFSCache getInstance(String defaultCacheImpl)
| {
| if (instance == null)
| {
| synchronized (lock)
| {
| if (instance == null)
| instance = AccessController.doPrivileged(new VFSCacheCreatorAction(defaultCacheImpl));
| }
| }
| return instance;
| }
|
| private static class VFSCacheCreatorAction implements PrivilegedAction<VFSCache>
| {
| private String defaultCacheImpl;
| VFSCacheCreatorAction(String defaultCacheImpl)
| {
| this.defaultCacheImpl = defaultCacheImpl;
| }
|
| public VFSCache run()
| {
| try
| {
| String className = defaultCacheImpl;
| if(className == null)
| className = System.getProperty(VFSUtils.VFS_CACHE_KEY);
| if (className != null)
| {
| log.info("Initializing VFSCache [" + className + "] ...");
| ClassLoader cl = VFSCacheFactory.class.getClassLoader();
| Class<?> clazz = cl.loadClass(className);
| VFSCache cache = VFSCache.class.cast(clazz.newInstance());
| cache.start(); // start here, so we fall back to default no-op in case start fails
| log.info("Using VFSCache [" + cache + "] ...");
| return cache;
| }
| }
| catch (Throwable t)
| {
| log.warn("Exception instantiating VFS cache: " + t);
| }
| log.info("Using VFSCache [NoopVFSCache] ...");
| return new NoopVFSCache();
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4187445#4187445
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4187445
More information about the jboss-dev-forums
mailing list