harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r449489 [3/3] - in /incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java: javax/naming/directory/ javax/naming/ldap/ javax/naming/spi/ org/apache/harmony/jndi/internal/ org/apache/harmony/jndi/provider/ org/apache/harmony/jn...
Date Sun, 24 Sep 2006 21:19:40 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/BindingEnumeration.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/BindingEnumeration.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/BindingEnumeration.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/BindingEnumeration.java
Sun Sep 24 14:19:38 2006
@@ -27,17 +27,27 @@
 
 import javax.naming.Binding;
 import javax.naming.Name;
+import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 
-
 /**
- * Enumeration of {@link Binding} objects,
- * used by {@link RegistryContext#listBindings(Name)} method.
- *
- * @author  Vasily Zakharov
+ * Enumeration of {@link Binding} objects, used by
+ * {@link RegistryContext#listBindings(Name)} method.
+ * 
+ * @author Vasily Zakharov
  * @version $Revision: 1.1.2.2 $
  */
-class BindingEnumeration extends NameClassPairEnumeration {
+class BindingEnumeration implements NamingEnumeration<Binding> {
+
+    /**
+     * Binding names returned from {@link Registry#list()} method.
+     */
+    protected final String[] names;
+
+    /**
+     * Index of the next name to return.
+     */
+    protected int index = 0;
 
     /**
      * Registry context.
@@ -46,34 +56,30 @@
 
     /**
      * Creates this enumeration.
-     *
-     * @param   names
-     *          Binding names returned from {@link Registry#list()} method.
-     *
-     * @param   context
-     *          RegistryContext to extract bindings from.
+     * 
+     * @param names Binding names returned from {@link Registry#list()} method.
+     * 
+     * @param context RegistryContext to extract bindings from.
      */
     public BindingEnumeration(String[] names, RegistryContext context) {
-        super(names);
+        super();
+        this.names = names;
         this.context = context.cloneContext();
     }
 
-    /**
-     * {@inheritDoc}
-     */
     public boolean hasMore() {
-        if (super.hasMore()) {
+        if (index < names.length) {
             return true;
-        } else {
-            close();
-            return false;
         }
+        close();
+        return false;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public Object next() throws NoSuchElementException, NamingException {
+    public boolean hasMoreElements() {
+        return hasMore();
+    }
+
+    public Binding next() throws NoSuchElementException, NamingException {
         if (!hasMore()) {
             throw new NoSuchElementException();
         }
@@ -84,18 +90,16 @@
         return binding;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void close() {
-        super.close();
-        finalize();
+    public Binding nextElement() {
+        try {
+            return next();
+        } catch (NamingException e) {
+            throw (NoSuchElementException) new NoSuchElementException().initCause(e);
+        }
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    protected void finalize() {
+    public void close() {
+        index = names.length;
         context.close();
     }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/NameClassPairEnumeration.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/NameClassPairEnumeration.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/NameClassPairEnumeration.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/NameClassPairEnumeration.java
Sun Sep 24 14:19:38 2006
@@ -30,15 +30,14 @@
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 
-
 /**
- * Enumeration of {@link NameClassPair} objects,
- * used by {@link RegistryContext#list(Name)} method.
- *
- * @author  Vasily Zakharov
+ * Enumeration of {@link NameClassPair} objects, used by
+ * {@link RegistryContext#list(Name)} method.
+ * 
+ * @author Vasily Zakharov
  * @version $Revision: 1.1.2.2 $
  */
-class NameClassPairEnumeration implements NamingEnumeration {
+class NameClassPairEnumeration implements NamingEnumeration<NameClassPair> {
 
     /**
      * Binding names returned from {@link Registry#list()} method.
@@ -52,25 +51,18 @@
 
     /**
      * Creates this enumeration.
-     *
-     * @param   names
-     *          Binding names returned from {@link Registry#list()} method.
+     * 
+     * @param names Binding names returned from {@link Registry#list()} method.
      */
     public NameClassPairEnumeration(String[] names) {
         this.names = names;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     public boolean hasMore() {
         return (index < names.length);
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public Object next() throws NamingException, NoSuchElementException {
+    public NameClassPair next() throws NamingException, NoSuchElementException {
         if (!hasMore()) {
             throw new NoSuchElementException();
         }
@@ -81,28 +73,18 @@
         return pair;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     public boolean hasMoreElements() {
         return hasMore();
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public Object nextElement() {
+    public NameClassPair nextElement() {
         try {
             return next();
         } catch (NamingException e) {
-            throw (NoSuchElementException)
-                    new NoSuchElementException().initCause(e);
+            throw (NoSuchElementException) new NoSuchElementException().initCause(e);
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
     public void close() {
         index = names.length;
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContext.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContext.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContext.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContext.java
Sun Sep 24 14:19:38 2006
@@ -35,19 +35,14 @@
 import java.rmi.StubNotFoundException;
 import java.rmi.UnknownHostException;
 import java.rmi.UnmarshalException;
-
 import java.rmi.activation.ActivateFailedException;
-
 import java.rmi.registry.LocateRegistry;
 import java.rmi.registry.Registry;
-
 import java.rmi.server.ExportException;
 import java.rmi.server.RMIClientSocketFactory;
-import java.rmi.server.SkeletonMismatchException;
-import java.rmi.server.SkeletonNotFoundException;
-
 import java.util.Hashtable;
 
+import javax.naming.Binding;
 import javax.naming.CommunicationException;
 import javax.naming.CompositeName;
 import javax.naming.ConfigurationException;
@@ -55,6 +50,7 @@
 import javax.naming.InvalidNameException;
 import javax.naming.Name;
 import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameClassPair;
 import javax.naming.NameNotFoundException;
 import javax.naming.NameParser;
 import javax.naming.NamingEnumeration;
@@ -66,7 +62,6 @@
 import javax.naming.Referenceable;
 import javax.naming.ServiceUnavailableException;
 import javax.naming.StringRefAddr;
-
 import javax.naming.spi.NamingManager;
 
 
@@ -125,7 +120,7 @@
     /**
      * Local environment.
      */
-    protected Hashtable environment;
+    protected Hashtable<Object, Object> environment;
 
     /**
      * RMI Registry.
@@ -156,14 +151,15 @@
      * @throws  NamingException
      *          If some naming error occurs.
      */
-    public RegistryContext(String host, int port, Hashtable environment)
+    @SuppressWarnings("unchecked")
+    public RegistryContext(String host, int port, Hashtable<?, ?> environment)
             throws NamingException {
         this.host = host;
         this.port = port;
 
         this.environment = ((environment != null)
-                ? (Hashtable) environment.clone()
-                : new Hashtable());
+                ? (Hashtable<Object, Object>) environment.clone()
+                : new Hashtable<Object, Object>());
 
         if (this.environment.get(SECURITY_MANAGER) != null) {
             installSecurityManager();
@@ -203,11 +199,12 @@
      * @param   context
      *          Context to copy.
      */
+    @SuppressWarnings("unchecked")
     protected RegistryContext(RegistryContext context) {
         host = context.host;
         port = context.port;
         csf = context.csf;
-        environment = (Hashtable) context.environment.clone();
+        environment = (Hashtable<Object, Object>) context.environment.clone();
         registry = context.registry;
         reference = context.reference;
     }
@@ -376,7 +373,7 @@
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration list(Name name) throws NamingException {
+    public NamingEnumeration<NameClassPair> list(Name name) throws NamingException
{
         if (name.isEmpty()) {
             try {
                 return new NameClassPairEnumeration(registry.list());
@@ -384,32 +381,31 @@
                 throw (NamingException)
                         newNamingException(e).fillInStackTrace();
             }
-        } else {
-            Object obj = lookup(name);
+        }
+        Object obj = lookup(name);
 
-            if (obj instanceof Context) {
-                try {
-                    return ((Context) obj).list("");
-                } finally {
-                    ((Context) obj).close();
-                }
+        if (obj instanceof Context) {
+            try {
+                return ((Context) obj).list("");
+            } finally {
+                ((Context) obj).close();
             }
-            throw new NotContextException(
-                    "Name specifies an object that is not a context: " + name);
         }
+        throw new NotContextException(
+                "Name specifies an object that is not a context: " + name);
     }
 
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration list(String name) throws NamingException {
+    public NamingEnumeration<NameClassPair> list(String name) throws NamingException
{
         return list(new CompositeName(name));
     }
 
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration listBindings(Name name) throws NamingException {
+    public NamingEnumeration<Binding> listBindings(Name name) throws NamingException
{
         if (name.isEmpty()) {
             try {
                 return new BindingEnumeration(registry.list(), this);
@@ -417,25 +413,24 @@
                 throw (NamingException)
                         newNamingException(e).fillInStackTrace();
             }
-        } else {
-            Object obj = lookup(name);
+        }
+        Object obj = lookup(name);
 
-            if (obj instanceof Context) {
-                try {
-                    return ((Context) obj).listBindings("");
-                } finally {
-                    ((Context) obj).close();
-                }
+        if (obj instanceof Context) {
+            try {
+                return ((Context) obj).listBindings("");
+            } finally {
+                ((Context) obj).close();
             }
-            throw new NotContextException(
-                    "Name specifies an object that is not a context: " + name);
         }
+        throw new NotContextException(
+                "Name specifies an object that is not a context: " + name);
     }
 
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration listBindings(String name) throws NamingException {
+    public NamingEnumeration<Binding> listBindings(String name) throws NamingException
{
         return listBindings(new CompositeName(name));
     }
 
@@ -479,8 +474,8 @@
     /**
      * {@inheritDoc}
      */
-    public Hashtable getEnvironment() {
-        return (Hashtable) environment.clone();
+    public Hashtable<?, ?> getEnvironment() {
+        return (Hashtable<?, ?>) environment.clone();
     }
 
     /**
@@ -565,9 +560,8 @@
     protected String getMyComponents(Name name) {
         if (name instanceof CompositeName) {
             return name.get(0);
-        } else {
-            return name.toString();
         }
+        return name.toString();
     }
 
     /**
@@ -681,6 +675,7 @@
      *
      * @return  Generated {@link NamingException} exception.
      */
+    @SuppressWarnings("deprecation")
     protected NamingException newNamingException(Throwable e) {
         NamingException ret =
                   (e instanceof AccessException)
@@ -694,8 +689,8 @@
                         ? new CommunicationException()
                 : (e instanceof ActivateFailedException)
                || (e instanceof NoSuchObjectException)
-               || (e instanceof SkeletonMismatchException)
-               || (e instanceof SkeletonNotFoundException)
+               || (e instanceof java.rmi.server.SkeletonMismatchException)
+               || (e instanceof java.rmi.server.SkeletonNotFoundException)
                || (e instanceof StubNotFoundException)
                || (e instanceof UnknownHostException)
                         ? new ConfigurationException()

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContextFactory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContextFactory.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContextFactory.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContextFactory.java
Sun Sep 24 14:19:38 2006
@@ -33,7 +33,6 @@
 import javax.naming.RefAddr;
 import javax.naming.Reference;
 import javax.naming.StringRefAddr;
-
 import javax.naming.spi.InitialContextFactory;
 import javax.naming.spi.ObjectFactory;
 
@@ -57,7 +56,7 @@
     /**
      * {@inheritDoc}
      */
-    public Context getInitialContext(Hashtable environment)
+    public Context getInitialContext(Hashtable<?, ?> environment)
             throws NamingException {
         String url = null;
 
@@ -74,17 +73,16 @@
 
         if (obj instanceof Context) {
             return (Context) obj;
-        } else {
-            throw new NotContextException("Object instantiated using the "
-                    + "URL specified in environment is not a context: " + url);
         }
+        throw new NotContextException("Object instantiated using the "
+                + "URL specified in environment is not a context: " + url);
     }
 
     /**
      * {@inheritDoc}
      */
     public Object getObjectInstance(Object obj, Name name, Context nameCtx,
-            Hashtable environment) throws Exception {
+            Hashtable<?, ?> environment) throws Exception {
         if (!(obj instanceof Reference)) {
             return null;
         }
@@ -99,10 +97,10 @@
         if (size < 1) {
             throw new ConfigurationException("Reference is empty");
         }
-        Vector urls = new Vector(size);
+        Vector<Object> urls = new Vector<Object>(size);
 
-        for (Enumeration e = reference.getAll(); e.hasMoreElements(); ) {
-            RefAddr refAddr = (RefAddr) e.nextElement();
+        for (Enumeration<RefAddr> e = reference.getAll(); e.hasMoreElements(); ) {
+            RefAddr refAddr = e.nextElement();
 
             if ((refAddr instanceof StringRefAddr)
                     && refAddr.getType().equals(RegistryContext.ADDRESS_TYPE)) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Skel.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Skel.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Skel.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Skel.java
Sun Sep 24 14:19:38 2006
@@ -27,7 +27,7 @@
  */
 package org.apache.harmony.jndi.provider.rmi.registry;
 
-
+@SuppressWarnings("deprecation")
 public final class RemoteReferenceWrapper_Skel implements java.rmi.server.Skeleton {
 
     private static final long interfaceHash = 2534274963554139942L;
@@ -37,7 +37,7 @@
     };
 
     public java.rmi.server.Operation[] getOperations() {
-        return (java.rmi.server.Operation[]) operations.clone();
+        return operations.clone();
     }
 
     public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int opnum,
long hash) throws java.lang.Exception {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Stub.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Stub.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Stub.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Stub.java
Sun Sep 24 14:19:38 2006
@@ -27,7 +27,7 @@
  */
 package org.apache.harmony.jndi.provider.rmi.registry;
 
-
+@SuppressWarnings("deprecation")
 public final class RemoteReferenceWrapper_Stub extends java.rmi.server.RemoteStub
         implements org.apache.harmony.jndi.provider.rmi.registry.RemoteReference, java.rmi.Remote
{
 
@@ -70,26 +70,25 @@
             if (useNewInvoke) {
                 java.lang.Object $result = ref.invoke(this, $method_getReference_0, null,
3529874867989176284L);
                 return ((javax.naming.Reference) $result);
-            } else {
-                java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject)
this, operations, 0, interfaceHash);
-
-                ref.invoke(call);
+            }
+            java.rmi.server.RemoteCall call = ref.newCall(this, operations, 0, interfaceHash);
 
-                javax.naming.Reference $result;
+            ref.invoke(call);
 
-                try {
-                    java.io.ObjectInput in = call.getInputStream();
-                    $result = (javax.naming.Reference) in.readObject();
-                } catch (java.io.IOException e) {
-                    throw new java.rmi.UnmarshalException("Error unmarshalling return value",
e);
-                } catch (java.lang.ClassNotFoundException e) {
-                    throw new java.rmi.UnmarshalException("Error unmarshalling return value",
e);
-                } finally {
-                    ref.done(call);
-                }
+            javax.naming.Reference $result;
 
-                return $result;
+            try {
+                java.io.ObjectInput in = call.getInputStream();
+                $result = (javax.naming.Reference) in.readObject();
+            } catch (java.io.IOException e) {
+                throw new java.rmi.UnmarshalException("Error unmarshalling return value",
e);
+            } catch (java.lang.ClassNotFoundException e) {
+                throw new java.rmi.UnmarshalException("Error unmarshalling return value",
e);
+            } finally {
+                ref.done(call);
             }
+
+            return $result;
         } catch (java.lang.RuntimeException e) {
             throw e;
         } catch (java.rmi.RemoteException e) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContext.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContext.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContext.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContext.java
Sun Sep 24 14:19:38 2006
@@ -54,7 +54,7 @@
      * @param   environment
      *          Environment to copy.
      */
-    public rmiURLContext(Hashtable environment) {
+    public rmiURLContext(Hashtable<?, ?> environment) {
         super(environment);
     }
 
@@ -75,8 +75,9 @@
      * @throws  NamingException
      *          If some naming error occurs.
      */
+    @Override
     protected ResolveResult getRootURLContext(
-            String url, Hashtable environment) throws NamingException {
+            String url, Hashtable<?, ?> environment) throws NamingException {
         if (!url.startsWith(RegistryContext.RMI_URL_PREFIX)) {
             throw new IllegalArgumentException(
                     "Not an RMI URL, incorrect prefix: " + url);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContextFactory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContextFactory.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContextFactory.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContextFactory.java
Sun Sep 24 14:19:38 2006
@@ -40,7 +40,9 @@
     /**
      * Default constructor.
      */
-    public rmiURLContextFactory() {}
+    public rmiURLContextFactory() {
+        super();
+    }
 
     /**
      * Returns new {@link rmiURLContext}. Used by
@@ -51,7 +53,8 @@
      *
      * @return  New {@link rmiURLContext}.
      */
-    protected Context createURLContext(Hashtable environment) {
+    @Override
+    protected Context createURLContext(Hashtable<?, ?> environment) {
         return new rmiURLContext(environment);
     }
 }



Mime
View raw message