[jboss-remoting-commits] JBoss Remoting SVN: r5033 - in remoting3/trunk: jboss-remoting/src/main/java/org/jboss/remoting3/spi and 2 other directories.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Tue Apr 14 14:00:58 EDT 2009


Author: david.lloyd at jboss.com
Date: 2009-04-14 14:00:58 -0400 (Tue, 14 Apr 2009)
New Revision: 5033

Removed:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientConnector.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientSourceConnector.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointConnector.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/QualifiedName.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/NamedServiceRegistry.java
   remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/spi/NameTestCase.java
Modified:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ResourceType.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceSpecification.java
   remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexClientExample.java
   remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexServerExample.java
Log:
API cleanup, javadoc

Deleted: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientConnector.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientConnector.java	2009-04-14 17:18:15 UTC (rev 5032)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientConnector.java	2009-04-14 18:00:58 UTC (rev 5033)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting3;
-
-import java.net.URI;
-import org.jboss.xnio.IoFuture;
-
-/**
- * A client connector.  Opens a connection to a URI which provides a single {@code Client} instance.  Instances of this
- * interface may only be able to support a single URI scheme.  Depending on the implementation, the URI may be a
- * protocol URI or a service URI.
- */
-public interface ClientConnector extends HandleableCloseable<ClientConnector> {
-
-    /**
-     * Establish a client connection.
-     *
-     * @param requestType the request class
-     * @param replyType the reply class
-     * @param connectUri the URI to connect to
-     * @param <I> the request type
-     * @param <O> the reply type
-     * @return the future client
-     * @throws IllegalArgumentException if the provided URI scheme is not supported by this connector
-     */
-    <I, O> IoFuture<? extends Client<I, O>> openClient(Class<I> requestType, Class<O> replyType, URI connectUri) throws IllegalArgumentException;
-}

Deleted: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientSourceConnector.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientSourceConnector.java	2009-04-14 17:18:15 UTC (rev 5032)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientSourceConnector.java	2009-04-14 18:00:58 UTC (rev 5033)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting3;
-
-import java.net.URI;
-import org.jboss.xnio.IoFuture;
-
-/**
- * A client source connector.  Opens a connection to a URI which provides a {@code ClientSource} instance.  Instances of this
- * interface may only be able to support a single URI scheme.  Depending on the implementation, the URI may be a
- * protocol URI or a service URI.
- */
-public interface ClientSourceConnector extends HandleableCloseable<ClientSourceConnector> {
-
-    /**
-     * Establish a client source connection.
-     *
-     * @param requestType the request class
-     * @param replyType the reply class
-     * @param connectUri the URI to connect to
-     * @param <I> the request type
-     * @param <O> the reply type
-     * @return the future client
-     * @throws IllegalArgumentException if the provided URI scheme is not supported by this connector
-     */
-    <I, O> IoFuture<? extends ClientSource<I, O>> openClientSource(Class<I> requestType, Class<O> replyType, URI connectUri) throws IllegalArgumentException;
-}
\ No newline at end of file

Deleted: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointConnector.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointConnector.java	2009-04-14 17:18:15 UTC (rev 5032)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointConnector.java	2009-04-14 18:00:58 UTC (rev 5033)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting3;
-
-import java.net.URI;
-import org.jboss.xnio.IoFuture;
-
-/**
- * An endpoint connector.  Used to connect a whole endpoint to another whole endpoint.  Typically, services are then
- * shared between the endpoints in some fashion, though this need not be the case.
- */
-public interface EndpointConnector extends HandleableCloseable<EndpointConnector> {
-
-    /**
-     * Connect the given endpoint to the remote URI.
-     *
-     * @param endpoint the endpoint to connect
-     * @param connectUri the connection URI
-     * @return the future handle, which may be used to terminate the connection
-     */
-    IoFuture<? extends HandleableCloseable> connect(Endpoint endpoint, URI connectUri);
-}

Deleted: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/QualifiedName.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/QualifiedName.java	2009-04-14 17:18:15 UTC (rev 5032)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/QualifiedName.java	2009-04-14 18:00:58 UTC (rev 5033)
@@ -1,258 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting3;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-/**
- * A qualified name for service registration.  A qualified name is a path-like structure comprised of a series of
- * zero or more name segments.  The string representation of a qualified name is a sequence of a forward slash
- * ({@code /}) followed by a non-empty URL-encoded name segment.
- */
-public final class QualifiedName implements Comparable<QualifiedName>, Iterable<String> {
-
-    /**
-     * The root name.
-     */
-    public static final QualifiedName ROOT_NAME = new QualifiedName(new String[0]);
-
-    private final String[] segments;
-
-    /**
-     * Create a new qualified name from the given name segments.
-     *
-     * @param nameSegments the name segments
-     * @throws NullPointerException if {@code nameSegments} is {@code null} or if any element of that array is {@code null}
-     * @throws IllegalArgumentException if an element of {@code nameSegments} is an empty string
-     */
-    public QualifiedName(final String[] nameSegments) throws NullPointerException, IllegalArgumentException {
-        if (nameSegments == null) {
-            throw new NullPointerException("segments is null");
-        }
-        String[] segments = nameSegments.clone();
-        for (String s : segments) {
-            if (s == null) {
-                throw new NullPointerException("Null segment");
-            }
-            if (s.length() == 0) {
-                throw new IllegalArgumentException("Empty segment");
-            }
-        }
-        this.segments = segments;
-    }
-
-    /**
-     * Compare this qualified name to another for equality.  Returns {@code true} if both names have the same number of segments
-     * with the same content.
-     *
-     * @param o the object to compare to
-     * @return {@code true} if the given object is a qualified name which is equal to this name
-     */
-    public boolean equals(final Object o) {
-        if (this == o) return true;
-        if (! (o instanceof QualifiedName)) return false;
-        final QualifiedName name = (QualifiedName) o;
-        if (!Arrays.equals(segments, name.segments)) return false;
-        return true;
-    }
-
-    /**
-     * Get the hash code of this qualified name.  Equal to the return value of {@link Arrays#hashCode(Object[]) Arrays.hashCode(segments)}
-     * where {@code segments} is the array of decoded segment strings.
-     *
-     * @return the hash code
-     */
-    public int hashCode() {
-        return Arrays.hashCode(segments);
-    }
-
-    /**
-     * Compare this qualified name to another.  Each segment is compared in turn; if they are equal then the comparison
-     * carries on to the next segment.  If all leading segments are equal but one qualified name has more segments,
-     * then the longer name is said to come after the shorter name.
-     *
-     * @param o the other name
-     * @return {@code 0} if the elements are equal, {@code -1} if this name comes before the given name, or {@code 1} if
-     *      this name comes after the given name
-     */
-    public int compareTo(final QualifiedName o) {
-        if (this == o) return 0;
-        String[] a = segments;
-        String[] b = o.segments;
-        final int alen = a.length;
-        final int blen = b.length;
-        for (int i = 0; i < alen && i < blen; i ++) {
-            final int cmp = a[i].compareTo(b[i]);
-            if (cmp != 0) {
-                return cmp;
-            }
-        }
-        if (alen < blen) {
-            return -1;
-        } else if (alen > blen) {
-            return 1;
-        } else {
-            return 0;
-        }
-    }
-
-    /**
-     * Get the string representation of this qualified name.  The root name is "{@code /}"; all other names are comprised
-     * of one or more consecutive character sequences of a forward slash followed by one or more URL-encoded characters.
-     *
-     * @return the string representation of this name
-     */
-    public String toString() {
-        StringBuilder builder = new StringBuilder();
-        if (segments.length == 0) {
-            return "/";
-        } else for (String segment : segments) {
-            try {
-                builder.append('/');
-                builder.append(URLEncoder.encode(segment, "utf-8"));
-            } catch (UnsupportedEncodingException e) {
-                // cannot happen
-                throw new IllegalStateException(e);
-            }
-        }
-        return builder.toString();
-    }
-
-    /**
-     * Parse an absolute qualified name.  An absolute qualified name must consist of either a single forward slash ("{@code /}") or else
-     * a series of path components, each comprised of a single forward slash followed by a URL-encoded series of non-forward-slash
-     * characters.
-     *
-     * @param path the encoded absolute path
-     * @return the qualified name
-     */
-    public static QualifiedName parse(String path) {
-        final int len = path.length();
-        if (len < 1) {
-            throw new IllegalArgumentException("Empty path");
-        }
-        if (path.charAt(0) != '/') {
-            throw new IllegalArgumentException("Relative paths are not allowed");
-        }
-        if (len == 1) {
-            return ROOT_NAME;
-        }
-        return ROOT_NAME.parseRelative(path.substring(1));
-    }
-
-    /**
-     * Get an iterator over the sequence of strings.
-     *
-     * @return an iterator
-     */
-    public Iterator<String> iterator() {
-        return new Iterator<String>() {
-            int i;
-
-            public boolean hasNext() {
-                return i < segments.length;
-            }
-
-            public String next() {
-                try {
-                    return segments[i++];
-                } catch (ArrayIndexOutOfBoundsException e) {
-                    throw new NoSuchElementException("next() past end");
-                }
-            }
-
-            public void remove() {
-                throw new UnsupportedOperationException("remove()");
-            }
-        };
-    }
-
-    /**
-     * Parse a qualified name relative to this one.  A relative qualified name must consist of
-     * a series of segments comprised of one or more URL-encoded characters separated by forward slashes ("{@code /}").
-     *
-     * @param path the encoded relative path
-     * @return the qualified name
-     */
-    public QualifiedName parseRelative(String path) {
-        if (path == null) {
-            throw new NullPointerException("path is null");
-        }
-        List<String> decoded = new ArrayList<String>();
-        int segStart = 0;
-        int segEnd;
-        do {
-            segEnd = path.indexOf('/', segStart);
-            String segment = segEnd == -1 ? path.substring(segStart) : path.substring(segStart, segEnd);
-            if (segment.length() == 0) {
-                throw new IllegalArgumentException(segEnd == -1 ? "Invalid trailing slash" : "Empty segment in path");
-            }
-            try {
-                decoded.add(URLDecoder.decode(segment, "utf-8"));
-            } catch (UnsupportedEncodingException e) {
-                // cannot happen
-                throw new IllegalStateException(e);
-            }
-            segStart = segEnd + 1;
-        } while (segEnd != -1);
-        final String[] segments = this.segments;
-        final int length = segments.length;
-        final String[] newSegments = new String[length + decoded.size()];
-        System.arraycopy(segments, 0, newSegments, 0, length);
-        for (int i = 0; i < decoded.size(); i ++) {
-            newSegments[i + length] = decoded.get(i);
-        }
-        return new QualifiedName(newSegments);
-    }
-
-    /**
-     * Get a new {@code org.jboss.remoting.QualifiedName} relative to this one.
-     *
-     * @param relativePath the segment to append
-     * @return the new {@code org.jboss.remoting.QualifiedName} instance
-     */
-    public QualifiedName appendRelative(String relativePath) {
-        final String[] segments = this.segments;
-        final int length = segments.length;
-        final String[] newSegments = new String[length + 1];
-        System.arraycopy(segments, 0, newSegments, 0, length);
-        newSegments[length] = relativePath;
-        return new QualifiedName(newSegments);
-    }
-
-    /**
-     * Get the number of segments in this name.
-     *
-     * @return the number of segments
-     */
-    public int length() {
-        return segments.length;
-    }
-}

Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ResourceType.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ResourceType.java	2009-04-14 17:18:15 UTC (rev 5032)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ResourceType.java	2009-04-14 18:00:58 UTC (rev 5033)
@@ -23,11 +23,29 @@
 package org.jboss.remoting3;
 
 /**
+ * The type of resource supported by a specific connection manager.
  *
+ * @apiviz.excluded
  */
 public enum ResourceType {
+
+    /**
+     * An unknown resource.  Such a resource cannot be opened by an endpoint.
+     */
     UNKNOWN,
+    /**
+     * A client resource.  Use {@link Endpoint#openClient(java.net.URI, Class, Class) Endpoint.openClient(*)} to open
+     * a client resource URI.
+     */
     CLIENT,
+    /**
+     * A client source resource.  Use {@link Endpoint#openClientSource(java.net.URI, Class, Class) Endpoint.openClientSource(*)} to open
+     * a client source resource URI.
+     */
     CLIENT_SOURCE,
+    /**
+     * An endpoint resource.  Use {@link Endpoint#openEndpointConnection(java.net.URI) Endpoint.openEndpointConnection(*)} to open
+     * an endpoint resource URI.
+     */
     ENDPOINT,
 }

Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceSpecification.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceSpecification.java	2009-04-14 17:18:15 UTC (rev 5032)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceSpecification.java	2009-04-14 18:00:58 UTC (rev 5033)
@@ -34,6 +34,14 @@
     private final String groupName;
     private final String endpointName;
 
+    /**
+     * Construct a new instance.  Each argument is validated and converted into a canonical form.  The arguments
+     * may be "*" indicating that anything will match.
+     *
+     * @param serviceType the service type
+     * @param groupName the group name
+     * @param endpointName the endpoint name
+     */
     public ServiceSpecification(final String serviceType, final String groupName, final String endpointName) {
         if (serviceType == null) {
             throw new NullPointerException("serviceType is null");
@@ -64,22 +72,49 @@
         }
     }
 
+    /**
+     * Create an instance from a service URI.
+     *
+     * @param uri the URI
+     * @return the specificaion
+     */
     public static ServiceSpecification fromUri(final URI uri) {
         return new ServiceSpecification(ServiceURI.getServiceType(uri), ServiceURI.getGroupName(uri), ServiceURI.getEndpointName(uri));
     }
 
+    /**
+     * Get the service type of this specification.
+     *
+     * @return the service type
+     */
     public String getServiceType() {
         return serviceType;
     }
 
+    /**
+     * Get the group name of this specification.
+     *
+     * @return the group name
+     */
     public String getGroupName() {
         return groupName;
     }
 
+    /**
+     * Get the endpoint name of this specification.
+     *
+     * @return the endpoint name
+     */
     public String getEndpointName() {
         return endpointName;
     }
 
+    /**
+     * Determine whether the given URI matches this specification.
+     *
+     * @param serviceUri the service URI
+     * @return {@code true} if the URI is a service which matches this specification
+     */
     public boolean matches(final URI serviceUri) {
         if (! ServiceURI.isRemotingServiceUri(serviceUri)) {
             return false;
@@ -102,6 +137,7 @@
         return true;
     }
 
+    /** {@inheritDoc} */
     public boolean equals(final Object o) {
         if (this == o) return true;
         if (! (o instanceof ServiceSpecification)) return false;
@@ -112,7 +148,7 @@
         return true;
     }
 
-    @Override
+    /** {@inheritDoc} */
     public int hashCode() {
         int result = serviceType.hashCode();
         result = 31 * result + groupName.hashCode();

Deleted: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/NamedServiceRegistry.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/NamedServiceRegistry.java	2009-04-14 17:18:15 UTC (rev 5032)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/NamedServiceRegistry.java	2009-04-14 18:00:58 UTC (rev 5033)
@@ -1,117 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting3.spi;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import org.jboss.remoting3.CloseHandler;
-import org.jboss.remoting3.QualifiedName;
-import org.jboss.remoting3.ServiceRegistrationException;
-import org.jboss.xnio.IoUtils;
-import org.jboss.xnio.log.Logger;
-
-/**
- * A registry associating names with services.  Specifically, the name is associated with a handle to a request handler
- * source instance; this handle is owned by the registry, so closing the handle will remove the entry.
- */
-public final class NamedServiceRegistry {
-    private static final Logger log = Logger.getLogger("org.jboss.remoting.named-registry");
-
-    private final ConcurrentMap<QualifiedName, Handle<RequestHandlerSource>> map = new ConcurrentHashMap<QualifiedName, Handle<RequestHandlerSource>>();
-
-    /**
-     * Construct a new empty registry.
-     */
-    public NamedServiceRegistry() {
-    }
-
-    /**
-     * Register a service at the given path.  If the given service is closed, an exception will be thrown.  Returns
-     * a handle to the service which may be used to unregister this service from the registry.  In addition, if the
-     * service is closed, the registration will be automatically removed.  To monitor the registration, add a close
-     * handler to the returned handle.
-     *
-     * @param path the path of the service registration
-     * @param service the service
-     * @return a handle which can be used to unregister the service
-     * @throws IOException if an error occurs
-     */
-    public Handle<RequestHandlerSource> registerService(final QualifiedName path, final RequestHandlerSource service) throws IOException {
-        if (path == null) {
-            throw new NullPointerException("path is null");
-        }
-        if (service == null) {
-            throw new NullPointerException("service is null");
-        }
-        final Handle<RequestHandlerSource> handle = service.getHandle();
-        boolean ok = false;
-        try {
-            final Handle<RequestHandlerSource> oldHandle = map.putIfAbsent(path, handle);
-            if (oldHandle != null) {
-                throw new ServiceRegistrationException(String.format("Failed to register a service at path \"%s\" on %s (a service is already registered at that location)", path, this));
-            }
-            handle.addCloseHandler(new CloseHandler<Handle<RequestHandlerSource>>() {
-                public void handleClose(final Handle<RequestHandlerSource> closed) {
-                    if (map.remove(path, service)) {
-                        log.trace("Removed service %s at path \"%s\" on %s (service handle was closed)", service, path, this);
-                    }
-                }
-            });
-            log.trace("Registered %s at path \"%s\" on %s", service, path, this);
-            ok = true;
-            return handle;
-        } finally {
-            if (! ok) IoUtils.safeClose(handle);
-        }
-    }
-
-    /**
-     * Find a service at a location in the registry.
-     *
-     * @param path the path
-     * @return a handle to the service, or {@code null} if it is not found
-     */
-    public Handle<RequestHandlerSource> lookupService(QualifiedName path) {
-        return map.get(path);
-    }
-
-    /**
-     * Get an unmodifiable view of the entry set of the registry.
-     *
-     * @return a set view
-     */
-    public Set<Map.Entry<QualifiedName, Handle<RequestHandlerSource>>> getEntrySet() {
-        return Collections.unmodifiableSet(map.entrySet());
-    }
-
-    /**
-     * Returns a brief description of this object.
-     */
-    public String toString() {
-        return "named service registry <" + Integer.toHexString(hashCode()) + ">";
-    }
-}

Deleted: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/spi/NameTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/spi/NameTestCase.java	2009-04-14 17:18:15 UTC (rev 5032)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/spi/NameTestCase.java	2009-04-14 18:00:58 UTC (rev 5033)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting3.spi;
-
-import junit.framework.TestCase;
-import org.jboss.remoting3.QualifiedName;
-import java.util.Iterator;
-
-/**
- *
- */
-public final class NameTestCase extends TestCase {
-
-    public void testParseEmpty() {
-        boolean ok = false;
-        try {
-            QualifiedName.parse("");
-        } catch (IllegalArgumentException e) {
-            assertEquals("Wrong exception message", "Empty path", e.getMessage());
-            ok = true;
-        }
-        assertTrue("Exception not thrown", ok);
-    }
-
-    public void testParseRelative() {
-        boolean ok = false;
-        try {
-            QualifiedName.parse("some relative path/foo/bar");
-        } catch (IllegalArgumentException e) {
-            assertEquals("Wrong exception message", "Relative paths are not allowed", e.getMessage());
-            ok = true;
-        }
-        assertTrue("Exception not thrown", ok);
-    }
-
-    public void testParseRoot() {
-        final Iterator<String> i = QualifiedName.parse("/").iterator();
-        assertFalse(i.hasNext());
-    }
-
-    public void testParseOneLevel() {
-        final Iterator<String> i = QualifiedName.parse("/firstElement").iterator();
-        assertTrue(i.hasNext());
-        assertEquals("Wrong segment name", "firstElement", i.next());
-        assertFalse(i.hasNext());
-    }
-
-    public void testParseTwoLevel() {
-        final Iterator<String> i = QualifiedName.parse("/firstElement/secondElement").iterator();
-        assertTrue(i.hasNext());
-        assertEquals("Wrong segment name", "firstElement", i.next());
-        assertTrue(i.hasNext());
-        assertEquals("Wrong segment name", "secondElement", i.next());
-        assertFalse(i.hasNext());
-    }
-
-    public void testParseManyLevel() {
-        final Iterator<String> i = QualifiedName.parse("/firstElement/secondElement/boo/test+with+spaces%20test").iterator();
-        assertTrue(i.hasNext());
-        assertEquals("Wrong segment name", "firstElement", i.next());
-        assertTrue(i.hasNext());
-        assertEquals("Wrong segment name", "secondElement", i.next());
-        assertTrue(i.hasNext());
-        assertEquals("Wrong segment name", "boo", i.next());
-        assertTrue(i.hasNext());
-        assertEquals("Wrong segment name", "test with spaces test", i.next());
-        assertFalse(i.hasNext());
-    }
-}

Modified: remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexClientExample.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexClientExample.java	2009-04-14 17:18:15 UTC (rev 5032)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexClientExample.java	2009-04-14 18:00:58 UTC (rev 5033)
@@ -26,11 +26,9 @@
 import org.jboss.remoting3.Remoting;
 import org.jboss.remoting3.ClientSource;
 import org.jboss.remoting3.Client;
-import org.jboss.remoting3.QualifiedName;
 import org.jboss.remoting3.multiplex.MultiplexProtocol;
 import org.jboss.remoting3.multiplex.MultiplexConfiguration;
 import org.jboss.remoting3.multiplex.MultiplexConnection;
-import org.jboss.remoting3.spi.NamedServiceRegistry;
 import org.jboss.remoting3.spi.RequestHandlerSource;
 import org.jboss.remoting3.spi.Handle;
 import org.jboss.xnio.IoUtils;

Modified: remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexServerExample.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexServerExample.java	2009-04-14 17:18:15 UTC (rev 5032)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexServerExample.java	2009-04-14 18:00:58 UTC (rev 5033)
@@ -29,8 +29,6 @@
 import org.jboss.remoting3.multiplex.MultiplexConfiguration;
 import org.jboss.remoting3.spi.RequestHandlerSource;
 import org.jboss.remoting3.spi.Handle;
-import org.jboss.remoting3.spi.NamedServiceRegistry;
-import org.jboss.remoting3.QualifiedName;
 import org.jboss.xnio.IoUtils;
 import org.jboss.xnio.Buffers;
 import org.jboss.xnio.IoHandlerFactory;




More information about the jboss-remoting-commits mailing list