geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r777634 - /geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java
Date Fri, 22 May 2009 17:38:33 GMT
Author: djencks
Date: Fri May 22 17:38:33 2009
New Revision: 777634

URL: http://svn.apache.org/viewvc?rev=777634&view=rev
Log:
XBEAN-127 be even more cautious about binding References from Referenceable.  Introduce some
flags to configure behavior (although they are constants now)

Modified:
    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/WritableContext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java?rev=777634&r1=777633&r2=777634&view=diff
==============================================================================
--- 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
Fri May 22 17:38:33 2009
@@ -42,6 +42,9 @@
     private final AtomicReference<Map<String, Object>> bindingsRef;
     private final AtomicReference<Map<String, Object>> indexRef;
     private final boolean cacheReferences;
+    private final boolean supportReferenceable = true;
+    private final boolean checkDereferenceDifferent = true;
+    private final boolean assumeDereferenceBound = false;
 
     public WritableContext() throws NamingException {
         this("", Collections.<String, Object>emptyMap(), ContextAccess.MODIFIABLE,
false);
@@ -87,16 +90,22 @@
     }
 
     protected void addBinding(AtomicReference<Map<String, Object>> bindingsRef,
String name, String nameInNamespace, Object value, boolean rebind) throws NamingException
{
-        if (value instanceof Referenceable) {
+        if (supportReferenceable && value instanceof Referenceable) {
             Reference ref = ((Referenceable)value).getReference();
             if (ref != null) {
-                try {
-                    Object o = NamingManager.getObjectInstance(ref, null, null, new Hashtable());
-                    if (!value.equals(o)) {
-                        value = ref;
+                if (checkDereferenceDifferent) {
+                    try {
+                        Object o = NamingManager.getObjectInstance(ref, null, null, new Hashtable());
+                        if (!value.equals(o)) {
+                            value = ref;
+                        }
+                    } catch (Exception e) {
+                        if (!assumeDereferenceBound) {
+                            value = ref;
+                        }
                     }
-                } catch (Exception e) {
-                    //don't try to bind reference
+                } else {
+                    value = ref;
                 }
             }
 



Mime
View raw message