geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r434268 - in /geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming: context/WritableContext.java reference/CachingReference.java
Date Thu, 24 Aug 2006 00:26:24 GMT
Author: dain
Date: Wed Aug 23 17:26:23 2006
New Revision: 434268

URL: http://svn.apache.org/viewvc?rev=434268&view=rev
Log:
Fixed bugs in cacheReferences logic in WritableContext

Modified:
    geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java
    geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/reference/CachingReference.java

Modified: geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java?rev=434268&r1=434267&r2=434268&view=diff
==============================================================================
--- geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java
(original)
+++ geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java
Wed Aug 23 17:26:23 2006
@@ -36,17 +36,18 @@
     private final Lock writeLock = new ReentrantLock();
     private final AtomicReference bindingsRef;
     private final AtomicReference indexRef;
+    private final boolean cacheReferences;
 
     public WritableContext() throws NamingException {
-        this("", Collections.EMPTY_MAP, ContextAccess.MODIFIABLE, true);
+        this("", Collections.EMPTY_MAP, ContextAccess.MODIFIABLE, false);
     }
 
     public WritableContext(String nameInNamespace) throws NamingException {
-        this(nameInNamespace, Collections.EMPTY_MAP, ContextAccess.MODIFIABLE, true);
+        this(nameInNamespace, Collections.EMPTY_MAP, ContextAccess.MODIFIABLE, false);
     }
 
     public WritableContext(String nameInNamespace, Map bindings) throws NamingException {
-        this(nameInNamespace, bindings, ContextAccess.MODIFIABLE, true);
+        this(nameInNamespace, bindings, ContextAccess.MODIFIABLE, false);
     }
 
     public WritableContext(String nameInNamespace, Map bindings, boolean cacheReferences)
throws NamingException {
@@ -54,14 +55,14 @@
     }
 
     public WritableContext(String nameInNamespace, Map bindings, ContextAccess contextAccess)
throws NamingException {
-        this(nameInNamespace, bindings, contextAccess, true);
+        this(nameInNamespace, bindings, contextAccess, false);
     }
 
     public WritableContext(String nameInNamespace, Map bindings, ContextAccess contextAccess,
boolean cacheReferences) throws NamingException {
         super(nameInNamespace, contextAccess);
 
-        // todo we need to wrap any reference bound, not just the initial bindings
-        if (cacheReferences) {
+        this.cacheReferences = cacheReferences;
+        if (this.cacheReferences) {
             bindings = CachingReference.wrapReferences(bindings);
         }
 
@@ -93,6 +94,10 @@
                 NestedWritableContext nestedContext = (NestedWritableContext) createNestedSubcontext(name,
Collections.EMPTY_MAP);
                 nestedContext.addFederatedContext(federatedContext);
                 value = nestedContext;
+            }
+
+            if (cacheReferences) {
+                value = CachingReference.wrapReference(getNameInNamespace(name), value);
             }
 
             Map newBindings = new HashMap(bindings);

Modified: geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/reference/CachingReference.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/reference/CachingReference.java?rev=434268&r1=434267&r2=434268&view=diff
==============================================================================
--- geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/reference/CachingReference.java
(original)
+++ geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/reference/CachingReference.java
Wed Aug 23 17:26:23 2006
@@ -28,6 +28,13 @@
  * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $
  */
 public class CachingReference extends SimpleReference {
+    public static Object wrapReference(String fullName, Object value) {
+        if (value instanceof Reference && !(value instanceof CachingReference)) {
+            return new CachingReference(fullName, (Reference)value);
+        }
+        return value;
+    }
+
     public static Map wrapReferences(Map bindings) {
         LinkedHashMap newBindings = new LinkedHashMap(bindings);
         for (Iterator iterator = bindings.entrySet().iterator(); iterator.hasNext();) {



Mime
View raw message