geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r707161 - in /geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming: context/ reference/
Date Wed, 22 Oct 2008 18:59:11 GMT
Author: djencks
Date: Wed Oct 22 11:59:10 2008
New Revision: 707161

URL: http://svn.apache.org/viewvc?rev=707161&view=rev
Log:
XBEAN-114 generify xbean-naming

Modified:
    geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractContext.java
    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/ContextAccessControlList.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/ContextFlyweight.java
    geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextUtil.java
    geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ImmutableContext.java
    geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/NestedContextFactory.java
    geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/VirtualSubcontext.java
    geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/WritableContext.java
    geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/reference/CachingReference.java
    geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/reference/SimpleReference.java

Modified: geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractContext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractContext.java?rev=707161&r1=707160&r2=707161&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractContext.java (original)
+++ geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/AbstractContext.java Wed Oct 22 11:59:10 2008
@@ -29,6 +29,9 @@
 import javax.naming.NameNotFoundException;
 import javax.naming.InitialContext;
 import javax.naming.OperationNotSupportedException;
+import javax.naming.NameClassPair;
+import javax.naming.Binding;
+
 import java.io.Serializable;
 import java.util.Collections;
 import java.util.Hashtable;
@@ -40,7 +43,7 @@
     private final Name parsedNameInNamespace;
     private final ContextAccess contextAccess;
     private final boolean modifiable;
-    private final ThreadLocal inCall = new ThreadLocal();
+    private final ThreadLocal<Name> inCall = new ThreadLocal<Name>();
 
     protected AbstractContext(String nameInNamespace) {
         this(nameInNamespace, ContextAccess.MODIFIABLE);
@@ -82,9 +85,10 @@
      * Gets the object bound to the name.  The name will not contain slashes.
      * @param name the name
      * @return the object bound to the name, or null if not found
+     * @throws javax.naming.NamingException on error
      */
     protected Object getBinding(String name) throws NamingException {
-        Map bindings = getBindings();
+        Map<String, Object> bindings = getBindings();
         return bindings.get(name);
     }
 
@@ -193,7 +197,7 @@
     }
 
     protected Context lookupFinalContext(Name name) throws NamingException {
-        Object value = null;
+        Object value;
         try {
             value = lookup(name.getPrefix(name.size() - 1));
         } catch (NamingException e) {
@@ -220,7 +224,7 @@
      * @return a Map from binding name to binding value
      * @throws NamingException if a problem occurs while getting the bindigns
      */
-    protected abstract Map getBindings() throws NamingException;
+    protected abstract Map<String, Object> getBindings() throws NamingException;
 
     //
     //  Add Binding
@@ -274,7 +278,7 @@
                         break;
                     } else {
                         // the current value must be a nested subcontext
-                        if (!(currentContext instanceof Context)) {
+                        if (!(currentValue instanceof Context)) {
                             throw new NotContextException("Expected an instance of context to be bound at " +
                                     part + " but found an instance of " + currentValue.getClass().getName());
                         }
@@ -298,11 +302,9 @@
         try {
             if (context instanceof AbstractContext) {
                 AbstractContext abstractContext = (AbstractContext) context;
-                Object value = abstractContext.getBinding(name);
-                return value;
+                return abstractContext.getBinding(name);
             } else {
-                Object value = context.lookup(name);
-                return value;
+                return context.lookup(name);
             }
         } catch (NamingException e) {
             return null;
@@ -340,7 +342,7 @@
      * a path specified by the name.  All necessary intermediate contexts will be created using the createContext method.
      * @param path the path to the context that will contains this context
      * @param name the name under which the value should be bound
-     * @param value the vale
+     * @param value the value
      * @return a context with the value bound at the specified name
      * @throws NamingException if a problem occurs while creating the subcontext tree
      */
@@ -368,7 +370,8 @@
      * Removes the binding from the context.  The name will not contain a path and the value will not
      * be a nested context although it may be a foreign context.
      * @param name name under which the value should be bound
-     * @param removeNotEmptyContext
+     * @param removeNotEmptyContext ??? TODO figure this out
+     * @return whether removal was successful
      * @throws NamingException if a problem occurs during the bind such as a value already being bound
      */
     protected abstract boolean removeBinding(String name, boolean removeNotEmptyContext) throws NamingException;
@@ -446,7 +449,7 @@
     protected static boolean isEmpty(Context context) throws NamingException {
         if (context instanceof AbstractContext) {
             AbstractContext abstractContext = (AbstractContext) context;
-            Map currentBindings = abstractContext.getBindings();
+            Map<String, Object> currentBindings = abstractContext.getBindings();
             return currentBindings.isEmpty();
         } else {
             NamingEnumeration namingEnumeration = context.list("");
@@ -457,7 +460,7 @@
     protected static int getSize(Context context) throws NamingException {
         if (context instanceof AbstractContext) {
             AbstractContext abstractContext = (AbstractContext) context;
-            Map currentBindings = abstractContext.getBindings();
+            Map<String, Object> currentBindings = abstractContext.getBindings();
             return currentBindings.size();
         } else {
             NamingEnumeration namingEnumeration = context.list("");
@@ -474,7 +477,7 @@
      *
      * @param context the context to remove the binding from
      * @param name the binding name
-     * @param removeNotEmptyContext
+     * @param removeNotEmptyContext ??? TODO figure this out
      * @throws NamingException if a problem occurs while unbinding
      */
     private void unbind(Context context, String name, boolean removeNotEmptyContext) throws NamingException {
@@ -537,6 +540,8 @@
 
     /**
      * Gets the name of a path withing the global namespace context.
+     * @param path path to extend
+     * @return full path in namespace
      */
     protected String getNameInNamespace(String path) {
         String nameInNamespace = getNameInNamespace();
@@ -549,6 +554,9 @@
 
     /**
      * Gets the name of a path withing the global namespace context.
+     * @param path path to extend
+     * @return full path in namespace
+     * @throws javax.naming.NamingException on error
      */
     protected Name getNameInNamespace(Name path) throws NamingException {
         Name nameInNamespace = getParsedNameInNamespace();
@@ -710,17 +718,17 @@
     // List
     //
 
-    protected NamingEnumeration list() throws NamingException {
-        Map bindings = getBindings();
+    protected NamingEnumeration<NameClassPair> list() throws NamingException {
+        Map<String, Object> bindings = getBindings();
         return new ContextUtil.ListEnumeration(bindings);
     }
 
-    protected NamingEnumeration listBindings() throws NamingException {
-        Map bindings = getBindings();
+    protected NamingEnumeration<Binding> listBindings() throws NamingException {
+        Map<String, Object> bindings = getBindings();
         return new ContextUtil.ListBindingEnumeration(bindings);
     }
 
-    public NamingEnumeration list(String name) throws NamingException {
+    public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
         if (name == null) throw new NullPointerException("name is null");
 
         // if the name is empty, list the current context
@@ -729,7 +737,7 @@
         }
 
         // lookup the target context
-        Object target = null;
+        Object target;
         try {
             target = lookup(name);
         } catch (NamingException e) {
@@ -745,7 +753,7 @@
         }
     }
 
-    public NamingEnumeration list(Name name) throws NamingException {
+    public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
         if (name == null) throw new NullPointerException("name is null");
 
         // if the name is empty, list the current context
@@ -754,7 +762,7 @@
         }
 
         // lookup the target context
-        Object target = null;
+        Object target;
         try {
             target = lookup(name);
         } catch (NamingException e) {
@@ -770,7 +778,7 @@
         }
     }
 
-    public NamingEnumeration listBindings(String name) throws NamingException {
+    public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
         if (name == null) throw new NullPointerException("name is null");
 
         // if the name is empty, list the current context
@@ -779,11 +787,11 @@
         }
 
         // lookup the target context
-        Object target = null;
+        Object target;
         try {
             target = lookup(name);
         } catch (NamingException e) {
-            throw new NotContextException(name.toString());
+            throw new NotContextException(name);
         }
 
         if (target == this) {
@@ -795,7 +803,7 @@
         }
     }
 
-    public NamingEnumeration listBindings(Name name) throws NamingException {
+    public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
         if (name == null) throw new NullPointerException("name is null");
 
         // if the name is empty, list the current context
@@ -804,7 +812,7 @@
         }
 
         // lookup the target context
-        Object target = null;
+        Object target;
         try {
             target = lookup(name);
         } catch (NamingException e) {

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?rev=707161&r1=707160&r2=707161&view=diff
==============================================================================
--- 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 Oct 22 11:59:10 2008
@@ -16,13 +16,13 @@
  */
 package org.apache.xbean.naming.context;
 
+import java.util.Collections;
+import java.util.Map;
+
 import javax.naming.Context;
 import javax.naming.Name;
 import javax.naming.NameAlreadyBoundException;
 import javax.naming.NamingException;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
 
 /**
  * @version $Rev$ $Date$
@@ -67,18 +67,18 @@
         return value;
     }
 
-    protected final Map getBindings() throws NamingException {
-        Map bindings = contextFederation.getFederatedBindings();
+    protected final Map<String, Object> getBindings() throws NamingException {
+        Map<String, Object> bindings = contextFederation.getFederatedBindings();
         bindings.putAll(getWrapperBindings());
         return bindings;
     }
 
-    protected abstract Map getWrapperBindings() throws NamingException;
+    protected abstract Map<String, Object> getWrapperBindings() throws NamingException;
 
     protected boolean addBinding(String name, Object value, boolean rebind) throws NamingException {
         if (!(value instanceof Context && !isNestedSubcontext(value))) {
             return contextFederation.addBinding(name, value, rebind);
-        } else if (value instanceof Context && !isNestedSubcontext(value)) {
+        } else if (!isNestedSubcontext(value)) {
             Context federatedContext = (Context) value;
 
             // if we already have a context bound at the specified value
@@ -92,7 +92,7 @@
                 addFederatedContext(nestedContext, federatedContext);
                 return true;
             } else {
-                AbstractFederatedContext nestedContext = (AbstractFederatedContext) createNestedSubcontext(name, Collections.EMPTY_MAP);
+                AbstractFederatedContext nestedContext = (AbstractFederatedContext) createNestedSubcontext(name, Collections.<String, Object>emptyMap());
                 addFederatedContext(nestedContext, federatedContext);
 
                 // call back into this method using the new nested context
@@ -110,9 +110,8 @@
 
     protected static void addFederatedContext(AbstractFederatedContext wrappingContext, Context innerContext) throws NamingException {
         wrappingContext.contextFederation.addContext(innerContext);
-        for (Iterator iterator = wrappingContext.getWrapperBindings().entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String name = (String) entry.getKey();
+        for (Map.Entry<String, Object> entry : wrappingContext.getWrapperBindings().entrySet()) {
+            String name = entry.getKey();
             Object value = entry.getValue();
             if (value instanceof AbstractFederatedContext) {
                 AbstractFederatedContext nestedContext = (AbstractFederatedContext) value;

Modified: geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextAccessControlList.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextAccessControlList.java?rev=707161&r1=707160&r2=707161&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextAccessControlList.java (original)
+++ geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextAccessControlList.java Wed Oct 22 11:59:10 2008
@@ -16,20 +16,20 @@
  */
 package org.apache.xbean.naming.context;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
 import javax.naming.Name;
 import javax.naming.NamingException;
-import java.util.List;
-import java.util.Iterator;
-import java.util.Collections;
-import java.util.ArrayList;
 
 /**
  * @version $Rev$ $Date$
  */
 public class ContextAccessControlList implements ContextAccess {
     private final boolean defaultAllow;
-    private final List allow;
-    private final List deny;
+    private final List<Name> allow;
+    private final List<Name> deny;
 
     public ContextAccessControlList(boolean defaultAllow, List allow, List deny) {
         this.defaultAllow = defaultAllow;
@@ -37,17 +37,16 @@
         this.deny = toACL(deny);
     }
 
-    private List toACL(List input) {
-        if (input == null) return Collections.EMPTY_LIST;
+    private List<Name> toACL(List input) {
+        if (input == null) return Collections.emptyList();
         
-        ArrayList list = new ArrayList(input.size());
-        for (Iterator iterator = input.iterator(); iterator.hasNext();) {
-            Object value = iterator.next();
+        ArrayList<Name> list = new ArrayList<Name>(input.size());
+        for (Object value : input) {
             if (value instanceof Name) {
-                list.add(value);
+                list.add((Name) value);
             } else if (value instanceof String) {
                 String string = (String) value;
-                Name name = null;
+                Name name;
                 try {
                     name = ContextUtil.NAME_PARSER.parse(string);
                 } catch (NamingException e) {
@@ -74,8 +73,7 @@
 
     protected boolean isAllowed(Name name) {
         if (name == null) throw new NullPointerException("name is null");
-        for (Iterator iterator = allow.iterator(); iterator.hasNext();) {
-            Name prefix = (Name) iterator.next();
+        for (Name prefix : allow) {
             if (name.startsWith(prefix)) {
                 return true;
             }
@@ -86,8 +84,7 @@
 
     protected boolean isDenied(Name name) {
         if (name == null) throw new NullPointerException("name is null");
-        for (Iterator iterator = deny.iterator(); iterator.hasNext();) {
-            Name prefix = (Name) iterator.next();
+        for (Name prefix : deny) {
             if (name.startsWith(prefix)) {
                 return true;
             }

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?rev=707161&r1=707160&r2=707161&view=diff
==============================================================================
--- 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 Oct 22 11:59:10 2008
@@ -16,27 +16,26 @@
  */
 package org.apache.xbean.naming.context;
 
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
 
+import javax.naming.Binding;
 import javax.naming.Context;
 import javax.naming.Name;
-import javax.naming.NamingException;
 import javax.naming.NamingEnumeration;
-import javax.naming.Binding;
+import javax.naming.NamingException;
 import javax.naming.OperationNotSupportedException;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.Map;
-import java.util.HashMap;
 
 /**
  * @version $Rev$ $Date$
  */
 public class ContextFederation {
     private final Context actualContext;
-    private final AtomicReference federatedContextRef = new AtomicReference(Collections.EMPTY_SET);
+    private final AtomicReference<Set<Context>> federatedContextRef = new AtomicReference<Set<Context>>(Collections.<Context>emptySet());
     public static final int MAX_WRITE_ATTEMPTS = 10;
 
     public ContextFederation(Context actualContext) {
@@ -44,12 +43,12 @@
     }
 
     public void addContext(Context context) {
-        Set federatedContext;
-        Set newFederatedContext;
+        Set<Context> federatedContext;
+        Set<Context> newFederatedContext;
         for (int i = 0; i < MAX_WRITE_ATTEMPTS; i++) {
             federatedContext = getFederatedContexts();
 
-            newFederatedContext = new LinkedHashSet(federatedContext);
+            newFederatedContext = new LinkedHashSet<Context>(federatedContext);
             newFederatedContext.add(context);
             newFederatedContext = Collections.unmodifiableSet(newFederatedContext);
             if (federatedContextRef.compareAndSet(federatedContext, newFederatedContext)) {
@@ -59,13 +58,12 @@
         throw new RuntimeException("Unable to update federatedContextRef within " + MAX_WRITE_ATTEMPTS + " attempts");
     }
 
-    public Set getFederatedContexts() {
-        return (Set) federatedContextRef.get();
+    public Set<Context> getFederatedContexts() {
+        return federatedContextRef.get();
     }
 
     public Object getFederatedBinding(String name) throws NamingException {
-        for (Iterator iterator = getFederatedContexts().iterator(); iterator.hasNext();) {
-            Context context = (Context) iterator.next();
+        for (Context context : getFederatedContexts()) {
 
             try {
                 Object value = context.lookup(name);
@@ -79,10 +77,9 @@
         return null;
     }
 
-    public Map getFederatedBindings() throws NamingException {
-        Map bindings = new HashMap();
-        for (Iterator iterator = getFederatedContexts().iterator(); iterator.hasNext();) {
-            Context context = (Context) iterator.next();
+    public Map<String, Object> getFederatedBindings() throws NamingException {
+        Map<String, Object> bindings = new HashMap<String, Object>();
+        for (Context context : getFederatedContexts()) {
 
             // list federated context
             NamingEnumeration namingEnumeration = context.listBindings("");
@@ -102,8 +99,7 @@
     }
 
     protected boolean addBinding(String name, Object value, boolean rebind) throws NamingException {
-        for (Iterator iterator = getFederatedContexts().iterator(); iterator.hasNext();) {
-            Context context = (Context) iterator.next();
+        for (Context context : getFederatedContexts()) {
 
             try {
                 if (rebind) {
@@ -119,8 +115,7 @@
     }
 
     protected boolean removeBinding(String name) throws NamingException {
-        for (Iterator iterator = getFederatedContexts().iterator(); iterator.hasNext();) {
-            Context context = (Context) iterator.next();
+        for (Context context : getFederatedContexts()) {
 
             try {
                 context.unbind(name);
@@ -132,9 +127,8 @@
     }
 
     public Object lookup(Name name) {
-        for (Iterator iterator = getFederatedContexts().iterator(); iterator.hasNext();) {
+        for (Context federatedContext : getFederatedContexts()) {
             try {
-                Context federatedContext = (Context) iterator.next();
                 Object value = federatedContext.lookup(name);
                 if (value instanceof Context) {
                     return new VirtualSubcontext(name, actualContext);
@@ -151,8 +145,7 @@
         Name parsedSubcontextName = actualContext.getNameParser("").parse(subcontextName);
 
         ContextFederation subcontextFederation = new ContextFederation(actualSubcontext);
-        for (Iterator iterator = getFederatedContexts().iterator(); iterator.hasNext();) {
-            Context federatedContext = (Context) iterator.next();
+        for (Context federatedContext : getFederatedContexts()) {
             VirtualSubcontext virtualSubcontext = new VirtualSubcontext(parsedSubcontextName, federatedContext);
             subcontextFederation.addContext(virtualSubcontext);
         }

Modified: geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextFlyweight.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextFlyweight.java?rev=707161&r1=707160&r2=707161&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextFlyweight.java (original)
+++ geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextFlyweight.java Wed Oct 22 11:59:10 2008
@@ -21,6 +21,9 @@
 import javax.naming.Name;
 import javax.naming.NamingEnumeration;
 import javax.naming.NameParser;
+import javax.naming.NameClassPair;
+import javax.naming.Binding;
+
 import java.util.Hashtable;
 
 /**
@@ -76,19 +79,19 @@
         getContext().rename(oldName, newName);
     }
 
-    public NamingEnumeration list(Name name) throws NamingException {
+    public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
         return getContext().list(name);
     }
 
-    public NamingEnumeration list(String name) throws NamingException {
+    public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
         return getContext().list(name);
     }
 
-    public NamingEnumeration listBindings(Name name) throws NamingException {
+    public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
         return getContext().listBindings(name);
     }
 
-    public NamingEnumeration listBindings(String name) throws NamingException {
+    public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
         return getContext().listBindings(name);
     }
 

Modified: geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextUtil.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextUtil.java?rev=707161&r1=707160&r2=707161&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextUtil.java (original)
+++ geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ContextUtil.java Wed Oct 22 11:59:10 2008
@@ -76,8 +76,8 @@
         }
     }
 
-    public static Map listToMap(NamingEnumeration enumeration) {
-        Map result = new HashMap();
+    public static Map<String, String> listToMap(NamingEnumeration enumeration) {
+        Map<String, String> result = new HashMap<String, String>();
         while (enumeration.hasMoreElements()) {
             NameClassPair nameClassPair = (NameClassPair) enumeration.nextElement();
             String name = nameClassPair.getName();
@@ -86,8 +86,8 @@
         return result;
     }
 
-    public static Map listBindingsToMap(NamingEnumeration enumeration) {
-        Map result = new HashMap();
+    public static Map<String, Object> listBindingsToMap(NamingEnumeration enumeration) {
+        Map<String, Object> result = new HashMap<String, Object>();
         while (enumeration.hasMoreElements()) {
             Binding binding = (Binding) enumeration.nextElement();
             String name = binding.getName();
@@ -96,7 +96,7 @@
         return result;
     }
 
-    public static final class ListEnumeration implements NamingEnumeration {
+    public static final class ListEnumeration implements NamingEnumeration<NameClassPair> {
         private final Iterator iterator;
 
         public ListEnumeration(Map localBindings) {
@@ -111,15 +111,15 @@
             return iterator.hasNext();
         }
 
-        public Object next() {
+        public NameClassPair next() {
             return nextElement();
         }
 
-        public Object nextElement() {
+        public NameClassPair nextElement() {
             Map.Entry entry = (Map.Entry) iterator.next();
             String name = (String) entry.getKey();
             Object value = entry.getValue();
-            String className = null;
+            String className;
             if (value instanceof Reference) {
                 Reference reference = (Reference) value;
                 className = reference.getClassName();
@@ -133,7 +133,7 @@
         }
     }
 
-    public static final class ListBindingEnumeration implements NamingEnumeration {
+    public static final class ListBindingEnumeration implements NamingEnumeration<Binding> {
         private final Iterator iterator;
 
         public ListBindingEnumeration(Map localBindings) {
@@ -148,11 +148,11 @@
             return iterator.hasNext();
         }
 
-        public Object next() {
+        public Binding next() {
             return nextElement();
         }
 
-        public Object nextElement() {
+        public Binding nextElement() {
             Map.Entry entry = (Map.Entry) iterator.next();
             String name = (String) entry.getKey();
             Object value = entry.getValue();
@@ -226,21 +226,19 @@
         }
     }
 
-    public static Map createBindings(Map absoluteBindings, NestedContextFactory factory) throws NamingException {
+    public static Map<String, Object> createBindings(Map<String, Object> absoluteBindings, NestedContextFactory factory) throws NamingException {
         // create a tree of Nodes using the absolute bindings
         Node node = buildMapTree(absoluteBindings);
 
         // convert the node tree into a tree of context objects
-        Map localBindings = ContextUtil.createBindings(null, node, factory);
 
-        return localBindings;
+        return ContextUtil.createBindings(null, node, factory);
     }
 
-    private static Map createBindings(String nameInNameSpace, Node node, NestedContextFactory factory) throws NamingException {
-        Map bindings = new HashMap(node.size());
-        for (Iterator iterator = node.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String name = (String) entry.getKey();
+    private static Map<String, Object> createBindings(String nameInNameSpace, Node node, NestedContextFactory factory) throws NamingException {
+        Map<String, Object> bindings = new HashMap<String, Object>(node.size());
+        for (Map.Entry<String, Object> entry : node.entrySet()) {
+            String name = entry.getKey();
             Object value = entry.getValue();
 
             // if this is a nested node we need to create a context for the node
@@ -264,21 +262,20 @@
     /**
      * Do nothing subclass of hashmap used to differentiate between a Map in the tree an a nested element during tree building
      */
-    public static final class Node extends HashMap {
+    public static final class Node extends HashMap<String, Object> {
     }
 
-    public static Node buildMapTree(Map absoluteBindings) throws NamingException {
+    public static Node buildMapTree(Map<String, Object> absoluteBindings) throws NamingException {
         Node rootContext = new Node();
 
-        for (Iterator iterator = absoluteBindings.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String name = (String) entry.getKey();
+        for (Map.Entry<String, Object> entry : absoluteBindings.entrySet()) {
+            String name = entry.getKey();
             Object value = entry.getValue();
 
             Node parentContext = rootContext;
 
             Name compoundName = ContextUtil.parseName(name);
-            for (Enumeration parts = compoundName.getAll(); parts.hasMoreElements(); ) {
+            for (Enumeration parts = compoundName.getAll(); parts.hasMoreElements();) {
                 String part = (String) parts.nextElement();
                 // the last element in the path is the name of the value
                 if (parts.hasMoreElements()) {

Modified: geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ImmutableContext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ImmutableContext.java?rev=707161&r1=707160&r2=707161&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ImmutableContext.java (original)
+++ geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/ImmutableContext.java Wed Oct 22 11:59:10 2008
@@ -16,60 +16,59 @@
  */
 package org.apache.xbean.naming.context;
 
-import org.apache.xbean.naming.reference.CachingReference;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.naming.Context;
+import javax.naming.Name;
 import javax.naming.NamingException;
 import javax.naming.OperationNotSupportedException;
-import javax.naming.Name;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
+
+import org.apache.xbean.naming.reference.CachingReference;
 
 /**
  *
  * @version $Rev: 417891 $ $Date: 2006-06-28 15:45:07 -0700 (Wed, 28 Jun 2006) $
  */
 public class ImmutableContext extends AbstractContext {
-    private final Map localBindings;
-    private final Map absoluteIndex;
+    private final Map<String, Object> localBindings;
+    private final Map<String, Object> absoluteIndex;
 
-    public ImmutableContext(Map bindings) throws NamingException {
+    public ImmutableContext(Map<String, Object> bindings) throws NamingException {
         this("", bindings, true);
     }
 
-    public ImmutableContext(Map bindings, boolean cacheReferences) throws NamingException {
+    public ImmutableContext(Map<String, Object> bindings, boolean cacheReferences) throws NamingException {
         this("", bindings, cacheReferences);
     }
 
-    public ImmutableContext(String nameInNamespace, Map bindings, boolean cacheReferences) throws NamingException {
+    public ImmutableContext(String nameInNamespace, Map<String, Object> bindings, boolean cacheReferences) throws NamingException {
         super(nameInNamespace, ContextAccess.UNMODIFIABLE);
 
         if (cacheReferences) {
             bindings = CachingReference.wrapReferences(bindings);
         }
 
-        Map localBindings = ContextUtil.createBindings(bindings, this);
+        Map<String, Object> localBindings = ContextUtil.createBindings(bindings, this);
         this.localBindings = Collections.unmodifiableMap(localBindings);
 
-        Map globalBindings = ImmutableContext.buildAbsoluteIndex("", localBindings);
+        Map<String, Object> globalBindings = ImmutableContext.buildAbsoluteIndex("", localBindings);
         this.absoluteIndex = Collections.unmodifiableMap(globalBindings);
     }
 
-    private static Map buildAbsoluteIndex(String nameInNamespace, Map bindings) {
+    private static Map<String, Object> buildAbsoluteIndex(String nameInNamespace, Map<String, Object> bindings) {
         String path = nameInNamespace;
         if (path.length() > 0) {
             path += "/";
         }
 
-        Map globalBindings = new HashMap();
-        for (Iterator iterator = bindings.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String name = (String) entry.getKey();
+        Map<String, Object> globalBindings = new HashMap<String, Object>();
+        for (Map.Entry<String, Object> entry : bindings.entrySet()) {
+            String name = entry.getKey();
             Object value = entry.getValue();
-            if (value instanceof ImmutableContext.NestedImmutableContext) {
-                ImmutableContext.NestedImmutableContext nestedContext = (ImmutableContext.NestedImmutableContext)value;
+            if (value instanceof NestedImmutableContext) {
+                NestedImmutableContext nestedContext = (NestedImmutableContext) value;
                 globalBindings.putAll(ImmutableContext.buildAbsoluteIndex(nestedContext.getNameInNamespace(), nestedContext.localBindings));
             }
             globalBindings.put(path + name, value);
@@ -81,7 +80,7 @@
         return absoluteIndex.get(name);
     }
 
-    protected Map getBindings() {
+    protected Map<String, Object> getBindings() {
         return localBindings;
     }
 
@@ -117,10 +116,10 @@
      * Nested context which shares the absolute index map in MapContext.
      */
     public final class NestedImmutableContext extends AbstractContext {
-        private final Map localBindings;
+        private final Map<String, Object> localBindings;
         private final String pathWithSlash;
 
-        public NestedImmutableContext(String path, Map bindings) {
+        public NestedImmutableContext(String path, Map<String, Object> bindings) {
             super(ImmutableContext.this.getNameInNamespace(path), ContextAccess.UNMODIFIABLE);
 
             if (!path.endsWith("/")) path += "/";
@@ -134,7 +133,7 @@
             return absoluteIndex.get(absoluteName);
         }
 
-        protected Map getBindings() {
+        protected Map<String, Object> getBindings() {
             return localBindings;
         }
 
@@ -162,7 +161,7 @@
             return false;
         }
 
-        public Context createNestedSubcontext(String path, Map bindings) {
+        public Context createNestedSubcontext(String path, Map<String, Object> bindings) {
             return new NestedImmutableContext(path, bindings);
         }
 

Modified: geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/NestedContextFactory.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/NestedContextFactory.java?rev=707161&r1=707160&r2=707161&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/NestedContextFactory.java (original)
+++ geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/NestedContextFactory.java Wed Oct 22 11:59:10 2008
@@ -36,6 +36,7 @@
      * @param path the path to the new nested context
      * @param bindings the initial bindings for the context
      * @return the new nested context
+     * @throws javax.naming.NamingException on error
      */
-    Context createNestedSubcontext(String path, Map bindings) throws NamingException;
+    Context createNestedSubcontext(String path, Map<String, Object> bindings) throws NamingException;
 }

Modified: geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/VirtualSubcontext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/VirtualSubcontext.java?rev=707161&r1=707160&r2=707161&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/VirtualSubcontext.java (original)
+++ geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/context/VirtualSubcontext.java Wed Oct 22 11:59:10 2008
@@ -21,6 +21,9 @@
 import javax.naming.NamingException;
 import javax.naming.NamingEnumeration;
 import javax.naming.NameParser;
+import javax.naming.Binding;
+import javax.naming.NameClassPair;
+
 import java.util.Hashtable;
 
 /**
@@ -90,19 +93,19 @@
         context.rename(getNameInContext(oldName), getNameInContext(newName));
     }
 
-    public NamingEnumeration list(Name name) throws NamingException {
+    public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
         return context.list(getNameInContext(name));
     }
 
-    public NamingEnumeration list(String name) throws NamingException {
+    public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
         return context.list(getNameInContext(name));
     }
 
-    public NamingEnumeration listBindings(Name name) throws NamingException {
+    public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
         return context.listBindings(getNameInContext(name));
     }
 
-    public NamingEnumeration listBindings(String name) throws NamingException {
+    public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
         return context.listBindings(getNameInContext(name));
     }
 

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=707161&r1=707160&r2=707161&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 Wed Oct 22 11:59:10 2008
@@ -16,50 +16,50 @@
  */
 package org.apache.xbean.naming.context;
 
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
-import org.apache.xbean.naming.reference.CachingReference;
 
 import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.NameAlreadyBoundException;
 import javax.naming.ContextNotEmptyException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
+import javax.naming.NameAlreadyBoundException;
+import javax.naming.NamingException;
+
+import org.apache.xbean.naming.reference.CachingReference;
 
 /**
  * @version $Rev$ $Date$
  */
 public class WritableContext extends AbstractFederatedContext {
     private final Lock writeLock = new ReentrantLock();
-    private final AtomicReference bindingsRef;
-    private final AtomicReference indexRef;
+    private final AtomicReference<Map<String, Object>> bindingsRef;
+    private final AtomicReference<Map<String, Object>> indexRef;
     private final boolean cacheReferences;
 
     public WritableContext() throws NamingException {
-        this("", Collections.EMPTY_MAP, ContextAccess.MODIFIABLE, false);
+        this("", Collections.<String, Object>emptyMap(), ContextAccess.MODIFIABLE, false);
     }
 
     public WritableContext(String nameInNamespace) throws NamingException {
-        this(nameInNamespace, Collections.EMPTY_MAP, ContextAccess.MODIFIABLE, false);
+        this(nameInNamespace, Collections.<String, Object>emptyMap(), ContextAccess.MODIFIABLE, false);
     }
 
-    public WritableContext(String nameInNamespace, Map bindings) throws NamingException {
+    public WritableContext(String nameInNamespace, Map<String, Object> bindings) throws NamingException {
         this(nameInNamespace, bindings, ContextAccess.MODIFIABLE, false);
     }
 
-    public WritableContext(String nameInNamespace, Map bindings, boolean cacheReferences) throws NamingException {
+    public WritableContext(String nameInNamespace, Map<String, Object> bindings, boolean cacheReferences) throws NamingException {
         this(nameInNamespace, bindings, ContextAccess.MODIFIABLE, cacheReferences);
     }
 
-    public WritableContext(String nameInNamespace, Map bindings, ContextAccess contextAccess) throws NamingException {
+    public WritableContext(String nameInNamespace, Map<String, Object> bindings, ContextAccess contextAccess) throws NamingException {
         this(nameInNamespace, bindings, contextAccess, false);
     }
 
-    public WritableContext(String nameInNamespace, Map bindings, ContextAccess contextAccess, boolean cacheReferences) throws NamingException {
+    public WritableContext(String nameInNamespace, Map<String, Object> bindings, ContextAccess contextAccess, boolean cacheReferences) throws NamingException {
         super(nameInNamespace, contextAccess);
 
         this.cacheReferences = cacheReferences;
@@ -67,10 +67,10 @@
             bindings = CachingReference.wrapReferences(bindings);
         }
 
-        Map localBindings = ContextUtil.createBindings(bindings, this);
+        Map<String, Object> localBindings = ContextUtil.createBindings(bindings, this);
 
-        this.bindingsRef = new AtomicReference(Collections.unmodifiableMap(localBindings));
-        this.indexRef = new AtomicReference(Collections.unmodifiableMap(buildIndex("", localBindings)));
+        this.bindingsRef = new AtomicReference<Map<String, Object>>(Collections.unmodifiableMap(localBindings));
+        this.indexRef = new AtomicReference<Map<String, Object>>(Collections.unmodifiableMap(buildIndex("", localBindings)));
     }
 
     protected boolean addBinding(String name, Object value, boolean rebind) throws NamingException {
@@ -82,10 +82,10 @@
         return true;
     }
 
-    protected void addBinding(AtomicReference bindingsRef, String name, String nameInNamespace, Object value, boolean rebind) throws NamingException {
+    protected void addBinding(AtomicReference<Map<String, Object>> bindingsRef, String name, String nameInNamespace, Object value, boolean rebind) throws NamingException {
         writeLock.lock();
         try {
-            Map bindings = (Map) bindingsRef.get();
+            Map<String, Object> bindings = bindingsRef.get();
 
             if (!rebind && bindings.containsKey(name)) {
                 throw new NameAlreadyBoundException(name);
@@ -94,7 +94,7 @@
                 value = CachingReference.wrapReference(getNameInNamespace(name), value);
             }
 
-            Map newBindings = new HashMap(bindings);
+            Map<String, Object> newBindings = new HashMap<String, Object>(bindings);
             newBindings.put(name,value);
             bindingsRef.set(newBindings);
 
@@ -105,12 +105,12 @@
     }
 
     private void addToIndex(String name, Object value) {
-        Map index = (Map) indexRef.get();
-        Map newIndex = new HashMap(index);
+        Map<String, Object> index = indexRef.get();
+        Map<String, Object> newIndex = new HashMap<String, Object>(index);
         newIndex.put(name, value);
         if (value instanceof NestedWritableContext) {
             NestedWritableContext nestedcontext = (NestedWritableContext) value;
-            Map newIndexValues = buildIndex(name, (Map) nestedcontext.bindingsRef.get());
+            Map<String, Object> newIndexValues = buildIndex(name, nestedcontext.bindingsRef.get());
             newIndex.putAll(newIndexValues);
         }
         indexRef.set(newIndex);
@@ -124,23 +124,23 @@
         return true;
     }
 
-    private boolean removeBinding(AtomicReference bindingsRef, String name, boolean removeNotEmptyContext) throws NamingException {
+    private boolean removeBinding(AtomicReference<Map<String, Object>> bindingsRef, String name, boolean removeNotEmptyContext) throws NamingException {
         writeLock.lock();
         try {
-            Map bindings = (Map) bindingsRef.get();
+            Map<String, Object> bindings = bindingsRef.get();
             if (!bindings.containsKey(name)) {
                 // remove is idempotent meaning remove succeededs even if there was no value bound
                 return false;
             }
 
-            Map newBindings = new HashMap(bindings);
+            Map<String, Object> newBindings = new HashMap<String, Object>(bindings);
             Object oldValue = newBindings.remove(name);
             if (!removeNotEmptyContext && oldValue instanceof Context && !isEmpty((Context)oldValue)) {
                 throw new ContextNotEmptyException(name);
             }
             bindingsRef.set(newBindings);
 
-            Map newIndex = removeFromIndex(name);
+            Map<String, Object> newIndex = removeFromIndex(name);
             indexRef.set(newIndex);
             return true;
         } finally {
@@ -148,39 +148,37 @@
         }
     }
 
-    private Map removeFromIndex(String name) {
-        Map index = (Map) indexRef.get();
-        Map newIndex = new HashMap(index);
+    private Map<String, Object> removeFromIndex(String name) {
+        Map<String, Object> index = indexRef.get();
+        Map<String, Object> newIndex = new HashMap<String, Object>(index);
         Object oldValue = newIndex.remove(name);
         if (oldValue instanceof NestedWritableContext) {
             NestedWritableContext nestedcontext = (NestedWritableContext) oldValue;
-            Map removedIndexValues = buildIndex(name, (Map) nestedcontext.bindingsRef.get());
-            for (Iterator iterator = removedIndexValues.keySet().iterator(); iterator.hasNext();) {
-                String key = (String) iterator.next();
+            Map<String, Object> removedIndexValues = buildIndex(name, nestedcontext.bindingsRef.get());
+            for (String key : removedIndexValues.keySet()) {
                 newIndex.remove(key);
             }
         }
         return newIndex;
     }
 
-    public Context createNestedSubcontext(String path, Map bindings) throws NamingException {
+    public Context createNestedSubcontext(String path, Map<String, Object> bindings) throws NamingException {
         return new NestedWritableContext(path,bindings);
     }
 
-    private static Map buildIndex(String nameInNamespace, Map bindings) {
+    private static Map<String, Object> buildIndex(String nameInNamespace, Map<String, Object> bindings) {
         String path = nameInNamespace;
         if (path.length() > 0 && !path.endsWith("/")) {
             path += "/";
         }
 
-        Map absoluteIndex = new HashMap();
-        for (Iterator iterator = bindings.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String name = (String) entry.getKey();
+        Map<String, Object> absoluteIndex = new HashMap<String, Object>();
+        for (Map.Entry<String, Object> entry : bindings.entrySet()) {
+            String name = entry.getKey();
             Object value = entry.getValue();
             if (value instanceof NestedWritableContext) {
-                NestedWritableContext nestedContext = (NestedWritableContext)value;
-                absoluteIndex.putAll(buildIndex(nestedContext.pathWithSlash, (Map) nestedContext.bindingsRef.get()));
+                NestedWritableContext nestedContext = (NestedWritableContext) value;
+                absoluteIndex.putAll(buildIndex(nestedContext.pathWithSlash, nestedContext.bindingsRef.get()));
             }
             absoluteIndex.put(path + name, value);
         }
@@ -188,32 +186,31 @@
     }
 
     protected Object getDeepBinding(String name) {
-        Map index = (Map) indexRef.get();
+        Map<String, Object> index = indexRef.get();
         return index.get(name);
     }
 
-    protected Map getWrapperBindings() throws NamingException {
-        Map bindings = (Map) bindingsRef.get();
-        return bindings;
+    protected Map<String, Object> getWrapperBindings() throws NamingException {
+        return bindingsRef.get();
     }
 
     /**
      * Nested context which shares the absolute index map in MapContext.
      */
     public class NestedWritableContext extends AbstractFederatedContext {
-        private final AtomicReference bindingsRef;
+        private final AtomicReference<Map<String, Object>> bindingsRef;
         private final String pathWithSlash;
 
-        public NestedWritableContext(String path, Map bindings) throws NamingException {
+        public NestedWritableContext(String path, Map<String, Object> bindings) throws NamingException {
             super(WritableContext.this, path);
 
             if (!path.endsWith("/")) path += "/";
             this.pathWithSlash = path;
 
-            this.bindingsRef = new AtomicReference(Collections.unmodifiableMap(bindings));
+            this.bindingsRef = new AtomicReference<Map<String, Object>>(Collections.unmodifiableMap(bindings));
         }
 
-        public Context createNestedSubcontext(String path, Map bindings) throws NamingException {
+        public Context createNestedSubcontext(String path, Map<String, Object> bindings) throws NamingException {
             return new NestedWritableContext(path, bindings);
         }
 
@@ -222,9 +219,8 @@
             return WritableContext.this.getDeepBinding(absoluteName);
         }
 
-        protected Map getWrapperBindings() throws NamingException {
-            Map bindings = (Map) bindingsRef.get();
-            return bindings;
+        protected Map<String, Object> getWrapperBindings() throws NamingException {
+            return bindingsRef.get();
         }
 
         protected boolean addBinding(String name, Object value, boolean rebind) throws NamingException {

Modified: geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/reference/CachingReference.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/reference/CachingReference.java?rev=707161&r1=707160&r2=707161&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/reference/CachingReference.java (original)
+++ geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/reference/CachingReference.java Wed Oct 22 11:59:10 2008
@@ -16,13 +16,13 @@
  */
 package org.apache.xbean.naming.reference;
 
-import org.apache.xbean.naming.context.ContextUtil;
+import java.util.LinkedHashMap;
+import java.util.Map;
 
-import javax.naming.Reference;
 import javax.naming.NamingException;
-import java.util.Map;
-import java.util.LinkedHashMap;
-import java.util.Iterator;
+import javax.naming.Reference;
+
+import org.apache.xbean.naming.context.ContextUtil;
 
 /**
  * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $
@@ -35,14 +35,13 @@
         return value;
     }
 
-    public static Map wrapReferences(Map bindings) {
-        LinkedHashMap newBindings = new LinkedHashMap(bindings);
-        for (Iterator iterator = bindings.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String name = (String) entry.getKey();
+    public static Map<String, Object> wrapReferences(Map<String, Object> bindings) {
+        LinkedHashMap<String, Object> newBindings = new LinkedHashMap<String, Object>(bindings);
+        for (Map.Entry<String, Object> entry : bindings.entrySet()) {
+            String name = entry.getKey();
             Object value = entry.getValue();
             if (value instanceof Reference && !(value instanceof CachingReference)) {
-                newBindings.put(name, new CachingReference(name, (Reference)value));
+                newBindings.put(name, new CachingReference(name, (Reference) value));
             }
         }
         return newBindings;

Modified: geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/reference/SimpleReference.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/reference/SimpleReference.java?rev=707161&r1=707160&r2=707161&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/reference/SimpleReference.java (original)
+++ geronimo/xbean/trunk/xbean-naming/src/main/java/org/apache/xbean/naming/reference/SimpleReference.java Wed Oct 22 11:59:10 2008
@@ -30,13 +30,13 @@
  * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $
  */
 public abstract class SimpleReference extends Reference {
-    private static final Enumeration EMPTY_ENUMERATION = new Enumeration() {
+    private static final Enumeration<RefAddr> EMPTY_ENUMERATION = new Enumeration<RefAddr>() {
         public boolean hasMoreElements() {
             return false;
         }
 
-        public Object nextElement() {
-            return new NoSuchElementException();
+        public RefAddr nextElement() {
+            throw new NoSuchElementException();
         }
     };
 
@@ -47,6 +47,7 @@
     /**
      * Gets the actual referenced Object.
      * @return the referenced object
+     * @throws javax.naming.NamingException on error
      */
     public abstract Object getContent() throws NamingException;
 
@@ -63,7 +64,7 @@
      * to obtain the class name of a factory.  This factory in turn understands the simple
      * reference.  This style is much slower because JNDI will use reflection to load and
      * create this class.
-     * @return
+     * @return factory class name
      */
     public final String getFactoryClassName() {
         return SimpleObjectFactory.class.getName();
@@ -84,7 +85,7 @@
         throw new ArrayIndexOutOfBoundsException(posn);
     }
 
-    public final Enumeration getAll() {
+    public final Enumeration<RefAddr> getAll() {
         return EMPTY_ENUMERATION;
     }
 



Mime
View raw message