geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r520977 - in /geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context: AbstractFederatedContext.java ContextFederation.java WritableContext.java
Date Wed, 21 Mar 2007 19:23:06 GMT
Author: dain
Date: Wed Mar 21 12:23:05 2007
New Revision: 520977

URL: http://svn.apache.org/viewvc?view=rev&rev=520977
Log:
Federated contexts should not list bindings to find a single value.
Fixed rebind error in federated contexts where bind would be to the wrong location in the
index but not the local bindings

Modified:
    geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractFederatedContext.java
    geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextFederation.java
    geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java

Modified: geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractFederatedContext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractFederatedContext.java?view=diff&rev=520977&r1=520976&r2=520977
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractFederatedContext.java
(original)
+++ geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractFederatedContext.java
Wed Mar 21 12:23:05 2007
@@ -59,6 +59,14 @@
         return super.faultLookup(stringName, parsedName);
     }
 
+    protected Object getBinding(String name) throws NamingException {
+        Object value = contextFederation.getFederatedBinding(name);
+        if (value == null) {
+            value = getWrapperBindings().get(name);
+        }
+        return value;
+    }
+
     protected final Map getBindings() throws NamingException {
         Map bindings = contextFederation.getFederatedBindings();
         bindings.putAll(getWrapperBindings());

Modified: geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextFederation.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextFederation.java?view=diff&rev=520977&r1=520976&r2=520977
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextFederation.java
(original)
+++ geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextFederation.java
Wed Mar 21 12:23:05 2007
@@ -63,6 +63,22 @@
         return (Set) federatedContextRef.get();
     }
 
+    public Object getFederatedBinding(String name) throws NamingException {
+        for (Iterator iterator = getFederatedContexts().iterator(); iterator.hasNext();)
{
+            Context context = (Context) iterator.next();
+
+            try {
+                Object value = context.lookup(name);
+                if (value != null) {
+                    return value;
+                }
+            } catch (NamingException e) {
+                // ignore
+            }
+        }
+        return null;
+    }
+
     public Map getFederatedBindings() throws NamingException {
         Map bindings = new HashMap();
         for (Iterator iterator = getFederatedContexts().iterator(); iterator.hasNext();)
{

Modified: geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java?view=diff&rev=520977&r1=520976&r2=520977
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java
(original)
+++ geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java
Wed Mar 21 12:23:05 2007
@@ -78,11 +78,11 @@
             return true;
         }
 
-        addBinding(bindingsRef, name, value, rebind);
+        addBinding(bindingsRef, name, getNameInNamespace(name), value, rebind);
         return true;
     }
 
-    protected void addBinding(AtomicReference bindingsRef, String name, Object value, boolean
rebind) throws NamingException {
+    protected void addBinding(AtomicReference bindingsRef, String name, String nameInNamespace,
Object value, boolean rebind) throws NamingException {
         writeLock.lock();
         try {
             Map bindings = (Map) bindingsRef.get();
@@ -98,14 +98,13 @@
             newBindings.put(name,value);
             bindingsRef.set(newBindings);
 
-            Map newIndex = addToIndex(name, value);
-            indexRef.set(newIndex);
+            addToIndex(nameInNamespace, value);
         } finally {
             writeLock.unlock();
         }
     }
 
-    private Map addToIndex(String name, Object value) {
+    private void addToIndex(String name, Object value) {
         Map index = (Map) indexRef.get();
         Map newIndex = new HashMap(index);
         newIndex.put(name, value);
@@ -114,7 +113,7 @@
             Map newIndexValues = buildIndex(name, (Map) nestedcontext.bindingsRef.get());
             newIndex.putAll(newIndexValues);
         }
-        return newIndex;
+        indexRef.set(newIndex);
     }
 
     protected boolean removeBinding(String name, boolean removeNotEmptyContext) throws NamingException
{
@@ -233,7 +232,7 @@
                 return true;
             }
 
-            WritableContext.this.addBinding(bindingsRef, name, value, rebind);
+            WritableContext.this.addBinding(bindingsRef, name, getNameInNamespace(name),
value, rebind);
             return true;
         }
 



Mime
View raw message