[jbosscache-commits] JBoss Cache SVN: r4577 - core/trunk/src/main/java/org/jboss/cache.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Oct 8 13:25:37 EDT 2007


Author: manik.surtani at jboss.com
Date: 2007-10-08 13:25:37 -0400 (Mon, 08 Oct 2007)
New Revision: 4577

Modified:
   core/trunk/src/main/java/org/jboss/cache/RegionManager.java
Log:
Missing default marshalling region causing issues

Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManager.java	2007-10-08 17:25:16 UTC (rev 4576)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java	2007-10-08 17:25:37 UTC (rev 4577)
@@ -10,6 +10,7 @@
 import org.jboss.cache.eviction.EvictionTimerTask;
 import org.jboss.cache.eviction.RegionNameConflictException;
 import org.jboss.cache.lock.NodeLock;
+import static org.jboss.cache.Region.Type.*;
 import org.jgroups.Address;
 
 import java.util.ArrayList;
@@ -55,6 +56,10 @@
     */
    public RegionManager()
    {
+      // always create a default MARSHALLING region!
+      Region r = new RegionImpl(Fqn.ROOT, this);
+      r.registerContextClassLoader(Thread.currentThread().getContextClassLoader() == null ? this.getClass().getClassLoader() : Thread.currentThread().getContextClassLoader());
+      r.setActive(true);
    }
 
    /**
@@ -126,7 +131,7 @@
     */
    public Region getRegion(Fqn fqn, boolean createIfAbsent)
    {
-      return getRegion(fqn, Region.Type.ANY, createIfAbsent);
+      return getRegion(fqn, ANY, createIfAbsent);
    }
 
    /**
@@ -146,9 +151,9 @@
 
          // this is a very poor way of telling whether a region is a marshalling one or an eviction one.  :-(
          // mandates that class loaders be registered for marshalling regions.
-         if (type == Region.Type.ANY
-                 || (type == Region.Type.MARSHALLING && r.getClassLoader() != null)
-                 || (type == Region.Type.EVICTION && r.getEvictionPolicyConfig() != null))
+         if (type == ANY
+                 || (type == MARSHALLING && r.getClassLoader() != null)
+                 || (type == EVICTION && r.getEvictionPolicyConfig() != null))
          {
             return r;
          }
@@ -159,7 +164,7 @@
       {
          Region r = new RegionImpl(fqnToUse, this);
          regionsRegistry.put(fqnToUse, r);
-         if (type == Region.Type.MARSHALLING)
+         if (type == MARSHALLING)
          {
             // insert current class loader into region so at least it is recognised as a marshalling region
             r.registerContextClassLoader(getClass().getClassLoader());
@@ -180,9 +185,9 @@
 
             // this is a very poor way of telling whether a region is a marshalling one or an eviction one.  :-(
             // mandates that class loaders be registered for marshalling regions.
-            if (type == Region.Type.ANY
-                    || (type == Region.Type.MARSHALLING && r.getClassLoader() != null)
-                    || (type == Region.Type.EVICTION && r.getEvictionPolicyConfig() != null))
+            if (type == ANY
+                    || (type == MARSHALLING && r.getClassLoader() != null)
+                    || (type == EVICTION && r.getEvictionPolicyConfig() != null))
             {
                nextBestThing = r;
             }
@@ -193,7 +198,7 @@
       // test if the default region has been defined.  If not, and if eviction regions
       // are in use, throw an exception since it is required.
       if ((nextBestThing == null || nextBestThing.getFqn().isRoot() && !regionsRegistry.containsKey(Fqn.ROOT))
-              && isUsingEvictions())
+              && type == EVICTION)
       {
          throw new RuntimeException("No default eviction region defined!");
       }
@@ -718,14 +723,14 @@
    {
       List<Region> regions;
 
-      if (type != Region.Type.ANY)
+      if (type != ANY)
       {
          regions = new ArrayList<Region>();
          // we need to loop thru the regions and only select specific regions to rtn.
          for (Region r : regionsRegistry.values())
          {
-            if ((type == Region.Type.EVICTION && r.getEvictionPolicy() != null && evictionTimerTask.isRegionRegisteredForProcessing(r)) ||
-                    (type == Region.Type.MARSHALLING && r.isActive() && r.getClassLoader() != null))
+            if ((type == EVICTION && r.getEvictionPolicy() != null && evictionTimerTask.isRegionRegisteredForProcessing(r)) ||
+                    (type == MARSHALLING && r.isActive() && r.getClassLoader() != null))
                regions.add(r);
          }
       }




More information about the jbosscache-commits mailing list