[seam-commits] Seam SVN: r8779 - trunk/src/main/org/jboss/seam/cache.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Aug 22 08:53:12 EDT 2008


Author: pete.muir at jboss.org
Date: 2008-08-22 08:53:11 -0400 (Fri, 22 Aug 2008)
New Revision: 8779

Modified:
   trunk/src/main/org/jboss/seam/cache/AbstractJBossCacheProvider.java
   trunk/src/main/org/jboss/seam/cache/CacheProvider.java
   trunk/src/main/org/jboss/seam/cache/JbossCache2Provider.java
Log:
Use reflection to remove build errors

Modified: trunk/src/main/org/jboss/seam/cache/AbstractJBossCacheProvider.java
===================================================================
--- trunk/src/main/org/jboss/seam/cache/AbstractJBossCacheProvider.java	2008-08-22 11:34:44 UTC (rev 8778)
+++ trunk/src/main/org/jboss/seam/cache/AbstractJBossCacheProvider.java	2008-08-22 12:53:11 UTC (rev 8779)
@@ -10,7 +10,7 @@
       super.setConfiguration("treecache.xml");
    }
    
-   private Fqn defaultFqn = Fqn.fromString(defaultRegion);
+   private Fqn defaultFqn;
    
    protected Fqn getFqn(String region)
    {
@@ -20,6 +20,10 @@
       }
       else
       {
+         if (defaultFqn == null)
+         {
+            defaultFqn = Fqn.fromString(getDefaultRegion());
+         }
          return defaultFqn;
       }
    }

Modified: trunk/src/main/org/jboss/seam/cache/CacheProvider.java
===================================================================
--- trunk/src/main/org/jboss/seam/cache/CacheProvider.java	2008-08-22 11:34:44 UTC (rev 8778)
+++ trunk/src/main/org/jboss/seam/cache/CacheProvider.java	2008-08-22 12:53:11 UTC (rev 8779)
@@ -22,7 +22,7 @@
     */
    public static final String DEFAULT_REGION = "org.jboss.seam.cache.DefaultRegion";
    private String configuration;
-   protected String defaultRegion = DEFAULT_REGION;
+   private String defaultRegion = DEFAULT_REGION;
 
    /**
     * @return - the cache the cache provider delegates to

Modified: trunk/src/main/org/jboss/seam/cache/JbossCache2Provider.java
===================================================================
--- trunk/src/main/org/jboss/seam/cache/JbossCache2Provider.java	2008-08-22 11:34:44 UTC (rev 8778)
+++ trunk/src/main/org/jboss/seam/cache/JbossCache2Provider.java	2008-08-22 12:53:11 UTC (rev 8779)
@@ -3,9 +3,12 @@
 import static org.jboss.seam.ScopeType.APPLICATION;
 import static org.jboss.seam.annotations.Install.BUILT_IN;
 
+import java.lang.reflect.Method;
+
 import org.jboss.cache.Cache;
 import org.jboss.cache.CacheFactory;
 import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
 import org.jboss.seam.annotations.AutoCreate;
 import org.jboss.seam.annotations.Create;
 import org.jboss.seam.annotations.Destroy;
@@ -15,6 +18,7 @@
 import org.jboss.seam.annotations.intercept.BypassInterceptors;
 import org.jboss.seam.log.LogProvider;
 import org.jboss.seam.log.Logging;
+import org.jboss.seam.util.Reflections;
 
 /**
  * Implementation of CacheProvider backed by JBoss Cache 2.x.
@@ -31,6 +35,26 @@
 @AutoCreate
 public class JbossCache2Provider extends AbstractJBossCacheProvider<Cache>
 {
+   
+   private static Method GET;
+   private static Method PUT;
+   private static Method REMOVE;
+   private static Method REMOVE_NODE;
+   
+   static
+   {
+      try
+      {
+         GET = Cache.class.getDeclaredMethod("get", Fqn.class, String.class);
+         PUT = Cache.class.getDeclaredMethod("put", Fqn.class, String.class, Object.class);
+         REMOVE = Cache.class.getDeclaredMethod("remove", Fqn.class, String.class);
+         REMOVE_NODE = Cache.class.getDeclaredMethod("removeNode", Fqn.class);
+      }
+      catch (Exception e)
+      {
+         throw new IllegalStateException("Unable to use JBoss Cache 2", e);
+      }
+   }
 
    private org.jboss.cache.Cache cache;
 
@@ -75,25 +99,25 @@
    @Override
    public Object get(String region, String key)
    {
-      return cache.get(getFqn(region), key);
+      return Reflections.invokeAndWrap(GET, cache, getFqn(region), key);
    }
 
    @Override
    public void put(String region, String key, Object object)
    {
-      cache.put(getFqn(region), key, object);
+      Reflections.invokeAndWrap(PUT, cache, getFqn(region), key, object);
    }
 
    @Override
    public void remove(String region, String key)
    {
-      cache.remove(getFqn(region), key);
+      Reflections.invokeAndWrap(REMOVE, cache, getFqn(region), key);
    }
 
    @Override
    public void clear()
    {
-      cache.removeNode(getFqn(null));
+      Reflections.invokeAndWrap(REMOVE_NODE, cache, getFqn(null));
    }
 
    @Override




More information about the seam-commits mailing list