[jboss-cvs] JBossCache/src-50/org/jboss/cache/pojo/util ...
Ben Wang
bwang at jboss.com
Mon Jul 31 01:13:23 EDT 2006
User: bwang
Date: 06/07/31 01:13:23
Modified: src-50/org/jboss/cache/pojo/util AopUtil.java
Log:
JBCACHE-702 user-specified region to perpend the id namespace.
Revision Changes Path
1.7 +46 -1 JBossCache/src-50/org/jboss/cache/pojo/util/AopUtil.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AopUtil.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/util/AopUtil.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- AopUtil.java 17 Jul 2006 09:25:02 -0000 1.6
+++ AopUtil.java 31 Jul 2006 05:13:23 -0000 1.7
@@ -15,6 +15,7 @@
import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor;
import org.jboss.cache.pojo.interceptors.dynamic.CacheFieldInterceptor;
import org.jboss.cache.pojo.InternalConstant;
+import org.jboss.cache.pojo.InvocationContext;
import org.jboss.util.id.GUID;
import java.io.Serializable;
@@ -27,6 +28,7 @@
public final class AopUtil
{
static final Log log = LogFactory.getLog(AopUtil.class.getName());
+ public static final String SEPARATOR = "/";
/**
* Find cache interceptor with exact fqn.
@@ -139,9 +141,52 @@
public static Fqn createInternalFqn()
{
+ String region = InvocationContext.getCurrent().getRegion();
// Use guid that is cluster-wide unique.
GUID guid = new GUID();
+ if(region == null)
+ {
return new Fqn(InternalConstant.JBOSS_INTERNAL, Fqn.fromString(guid.toString()));
+ } else
+ {
+ return new Fqn(InternalConstant.JBOSS_INTERNAL, getIdWithRegion(guid.toString()));
+ }
+ }
+
+ public static Fqn getIdWithRegion(String id)
+ {
+ String region = InvocationContext.getCurrent().getRegion();
+ if(region == null)
+ {
+ return Fqn.fromString(id);
+ } else
+ {
+ Fqn fqn= Fqn.fromString(region + SEPARATOR + id);
+ if(log.isTraceEnabled())
+ {
+ log.trace("Appending ID with region. The new id is: " +fqn.toString());
+ }
+ return fqn;
+ }
}
+
+ public static Fqn getIdWithRegion(Fqn id)
+ {
+ String region = InvocationContext.getCurrent().getRegion();
+ if(region == null)
+ {
+ return id;
+ } else
+ {
+ Fqn fqn= new Fqn(Fqn.fromString(region), id);
+ if(log.isTraceEnabled())
+ {
+ log.trace("Appending ID with region. The new id is: " +fqn.toString());
+ }
+ return fqn;
+ }
+ }
+
+
}
More information about the jboss-cvs-commits
mailing list