geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r432434 - in /geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/context: AbstractContext.java AbstractUnmodifiableContext.java WritableContext.java
Date Thu, 17 Aug 2006 23:42:45 GMT
Author: dain
Date: Thu Aug 17 16:42:44 2006
New Revision: 432434

URL: http://svn.apache.org/viewvc?rev=432434&view=rev
Log:
Fixed compile errors in subclasses of AbstractUnmodifiableContext by renaming internalBind
method to lookup and implementing the addBinding and removeBinding methods as OperationNotSupportedException.

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

Modified: geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractContext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractContext.java?rev=432434&r1=432433&r2=432434&view=diff
==============================================================================
--- geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractContext.java
(original)
+++ geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractContext.java
Thu Aug 17 16:42:44 2006
@@ -45,9 +45,9 @@
     }
 
     protected abstract void removeBindings(Name name) throws NamingException;
-    protected abstract Object internalLookup(Name name, boolean resolveLinks) throws NamingException;
+    protected abstract Object lookup(String stringName, Name parsedName) throws NamingException;
     protected abstract void addBinding(Name name, Object obj, boolean rebind) throws NamingException;
-    protected abstract Map getBindingsCopy();
+    protected abstract Map getBindings() throws NamingException;
 
     /**
      * Gets the name of this context withing the global namespace.  This method may return
null
@@ -147,7 +147,7 @@
     public Object lookup(Name name) throws NamingException {
         if (name == null) throw new NullPointerException("name is null");
 
-        Object value = internalLookup(name, true);
+        Object value = lookup(null, name);
 
 
         // if we got a link back we need to resolve it
@@ -166,7 +166,7 @@
 
     public Object lookupLink(Name name) throws NamingException {
         if (name == null) throw new NullPointerException("name is null");
-        return internalLookup(name, false);
+        return lookup(null, name);
     }
 
     //
@@ -245,7 +245,7 @@
     public NamingEnumeration list(Name name) throws NamingException {
         if (name == null) throw new NullPointerException("name is null");
         if (name.isEmpty()) {
-            return new ContextUtil.ListEnumeration(getBindingsCopy());
+            return new ContextUtil.ListEnumeration(getBindings());
         }
         Object target = lookup(name);
         if (target instanceof Context) {
@@ -262,7 +262,7 @@
     public NamingEnumeration listBindings(Name name) throws NamingException {
         if (name == null) throw new NullPointerException("name is null");
         if (name.isEmpty()) {
-            return new ContextUtil.ListBindingEnumeration(getBindingsCopy());
+            return new ContextUtil.ListBindingEnumeration(getBindings());
         }
         Object target = lookup(name);
         if (target instanceof Context) {

Modified: geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractUnmodifiableContext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractUnmodifiableContext.java?rev=432434&r1=432433&r2=432434&view=diff
==============================================================================
--- geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractUnmodifiableContext.java
(original)
+++ geronimo/xbean/branches/colossus/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractUnmodifiableContext.java
Thu Aug 17 16:42:44 2006
@@ -41,6 +41,14 @@
         super(nameInNamespace);
     }
 
+    protected final void addBinding(Name name, Object obj, boolean rebind) throws NamingException
{
+        throw new OperationNotSupportedException("Context is read only");
+    }
+
+    protected final void removeBindings(Name name) throws NamingException {
+        throw new OperationNotSupportedException("Context is read only");
+    }
+
     //
     //  Lookup Binding
     //
@@ -65,8 +73,11 @@
     }
 
     /**
-     * Finds the specified entry.  Normally there is no need to override this method; insted
you should
-     * simply implement the getBindings(String) method.
+     * Finds the specified entry.  Normally there is no need to override this method; instead
you should
+     * simply implement the getDeepBindings(String) and getBindings(String) method.
+     *
+     * This method will follow links except for the final element which is always just returned
without
+     * inspection.  This means this method can be used to implement lookupLink.
      *
      * @param stringName the string version of the name; maybe null
      * @param parsedName the parsed name; may be null

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=432434&r1=432433&r2=432434&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
Thu Aug 17 16:42:44 2006
@@ -73,26 +73,28 @@
         }
     }
 
-    protected Object internalLookup(Name name, boolean resolveLinks) throws NamingException
{
+    protected Object lookup(String stringName, Name parsedName) throws NamingException {
+        if (parsedName == null) parsedName = getNameParser().parse(stringName);
+
         Object result = null;
         Map bindings = this.bindings;
         Object terminalContext = null;
-        if (name.isEmpty()) {
+        if (parsedName.isEmpty()) {
             return this;
         }
-        int index = name.get(0).indexOf(':');
+        int index = parsedName.get(0).indexOf(':');
         if (index != -1) {
-            String temp = name.get(0).substring(index + 1);
-            name.remove(0);
-            name.add(0, temp);
+            String temp = parsedName.get(0).substring(index + 1);
+            parsedName.remove(0);
+            parsedName.add(0, temp);
         }
-        if (name.size() == 1) {
-            result = bindings.get(name.toString());
+        if (parsedName.size() == 1) {
+            result = bindings.get(parsedName.toString());
         } else {
             String segment = null;
-            int lastIndex = name.size() - 1;
+            int lastIndex = parsedName.size() - 1;
             for (int i = 0; i < lastIndex; i++) {
-                segment = name.get(i);
+                segment = parsedName.get(i);
                 terminalContext = bindings.get(segment);
                 if (terminalContext == null) {
                     throw new NamingException("The intermediate context "
@@ -106,7 +108,7 @@
                     bindings = ((WritableContext) terminalContext).bindings;
                 }
             }
-            segment = name.get(lastIndex);
+            segment = parsedName.get(lastIndex);
             result = ((Context) terminalContext).lookup(segment);
         }
 
@@ -157,7 +159,7 @@
         }
     }
 
-    protected Map getBindingsCopy() {
+    protected Map getBindings() {
         return bindings;
     }
 }



Mime
View raw message