Author: david.lloyd(a)jboss.com
Date: 2009-01-08 17:36:45 -0500 (Thu, 08 Jan 2009)
New Revision: 4789
Added:
remoting3/trunk/api/src/main/java/org/jboss/remoting/QualifiedName.java
Removed:
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/QualifiedName.java
Modified:
remoting3/trunk/api/src/main/java/org/jboss/remoting/Client.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientContext.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/CloseHandler.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/Endpoint.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/HandleableCloseable.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/LocalServiceConfiguration.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/RemoteServiceConfiguration.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestCancelHandler.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestContext.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestListener.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceContext.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceListener.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceURI.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/package-info.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/NamedServiceRegistry.java
remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/NameTestCase.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConnection.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexReadHandler.java
remoting3/trunk/protocol/multiplex/src/test/java/org/jboss/remoting/protocol/multiplex/ConnectionTestCase.java
remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexClientExample.java
remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexServerExample.java
remoting3/trunk/standalone/src/main/java/org/jboss/remoting/Remoting.java
Log:
Move QualifiedName to the main Remoting package
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/Client.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/Client.java 2009-01-08 04:17:15
UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/Client.java 2009-01-08 22:36:45
UTC (rev 4789)
@@ -11,6 +11,8 @@
*
* @param <I> the request type
* @param <O> the reply type
+ *
+ * @apiviz.landmark
*/
public interface Client<I, O> extends HandleableCloseable<Client<I, O>>
{
/**
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientContext.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientContext.java 2009-01-08
04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientContext.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -4,6 +4,8 @@
/**
* The server context for a single remote client instance.
+ *
+ * @apiviz.exclude
*/
public interface ClientContext extends HandleableCloseable<ClientContext> {
/**
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/CloseHandler.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/CloseHandler.java 2009-01-08
04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/CloseHandler.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -4,6 +4,8 @@
* A handler which is notified of a resource close.
*
* @param <T> the type of resource
+ *
+ * @apiviz.exclude
*/
public interface CloseHandler<T> {
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/Endpoint.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/Endpoint.java 2009-01-08 04:17:15
UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/Endpoint.java 2009-01-08 22:36:45
UTC (rev 4789)
@@ -10,6 +10,8 @@
/**
* A potential participant in a JBoss Remoting communications relationship.
+ *
+ * @apiviz.landmark
*/
public interface Endpoint extends HandleableCloseable<Endpoint> {
/**
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/HandleableCloseable.java
===================================================================
---
remoting3/trunk/api/src/main/java/org/jboss/remoting/HandleableCloseable.java 2009-01-08
04:17:15 UTC (rev 4788)
+++
remoting3/trunk/api/src/main/java/org/jboss/remoting/HandleableCloseable.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -7,6 +7,8 @@
* A Remoting resource that can be closed.
*
* @param <T> the type that is passed to the close handler
+ *
+ * @apiviz.exclude
*/
public interface HandleableCloseable<T> extends Closeable {
@@ -28,6 +30,8 @@
/**
* A key which may be used to remove this handler.
+ *
+ * @apiviz.exclude
*/
interface Key {
Modified:
remoting3/trunk/api/src/main/java/org/jboss/remoting/LocalServiceConfiguration.java
===================================================================
---
remoting3/trunk/api/src/main/java/org/jboss/remoting/LocalServiceConfiguration.java 2009-01-08
04:17:15 UTC (rev 4788)
+++
remoting3/trunk/api/src/main/java/org/jboss/remoting/LocalServiceConfiguration.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -24,6 +24,8 @@
/**
* A configuration for a service to be deployed into the endpoint.
+ *
+ * @apiviz.exclude
*/
public final class LocalServiceConfiguration<I, O> {
private final RequestListener<I, O> requestListener;
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/QualifiedName.java (from rev
4761, remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/QualifiedName.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/QualifiedName.java
(rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/QualifiedName.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -0,0 +1,222 @@
+/*
+ * 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.remoting;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * 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 a qualified name. A 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 path
+ * @return the qualified name
+ */
+ public static QualifiedName parse(String path) {
+ List<String> decoded = new ArrayList<String>();
+ 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;
+ }
+ int segStart = 0;
+ int segEnd;
+ do {
+ segEnd = path.indexOf('/', segStart + 1);
+ String segment = segEnd == -1 ? path.substring(segStart + 1) :
path.substring(segStart + 1, 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;
+ } while (segEnd != -1);
+ return new QualifiedName(decoded.toArray(new String[decoded.size()]));
+ }
+
+ /**
+ * 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()");
+ }
+ };
+ }
+
+ /**
+ * Get the number of segments in this name.
+ *
+ * @return the number of segments
+ */
+ public int length() {
+ return segments.length;
+ }
+}
Modified:
remoting3/trunk/api/src/main/java/org/jboss/remoting/RemoteServiceConfiguration.java
===================================================================
---
remoting3/trunk/api/src/main/java/org/jboss/remoting/RemoteServiceConfiguration.java 2009-01-08
04:17:15 UTC (rev 4788)
+++
remoting3/trunk/api/src/main/java/org/jboss/remoting/RemoteServiceConfiguration.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -26,6 +26,8 @@
/**
* A configuration for registering a remote service with an endpoint.
+ *
+ * @apiviz.exclude
*/
public final class RemoteServiceConfiguration {
private String serviceType;
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestCancelHandler.java
===================================================================
---
remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestCancelHandler.java 2009-01-08
04:17:15 UTC (rev 4788)
+++
remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestCancelHandler.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -4,6 +4,8 @@
* A handler for request listeners to receive a notification when a request was
cancelled.
*
* @param <O> the reply type
+ *
+ * @apiviz.exclude
*/
public interface RequestCancelHandler<O> {
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestContext.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestContext.java 2009-01-08
04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestContext.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -9,6 +9,8 @@
* specified in this interface.
*
* @param <O> the reply type
+ *
+ * @apiviz.exclude
*/
public interface RequestContext<O> extends Executor {
/**
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestListener.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestListener.java 2009-01-08
04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestListener.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -5,6 +5,8 @@
*
* @param <I> the request type
* @param <O> the reply type
+ *
+ * @apiviz.landmark
*/
public interface RequestListener<I, O> {
/**
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceContext.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceContext.java 2009-01-08
04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceContext.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -5,6 +5,8 @@
/**
* The server-side context of a service. Used to hold state relating to a service (known
as a {@code ContextSource} on
* the client side).
+ *
+ * @apiviz.exclude
*/
public interface ServiceContext extends HandleableCloseable<ServiceContext> {
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceListener.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceListener.java 2009-01-08
04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceListener.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -26,6 +26,8 @@
/**
* A listener for watching service registrations on an endpoint.
+ *
+ * @apiviz.landmark
*/
public interface ServiceListener {
@@ -39,6 +41,8 @@
/**
* Information about a registered service.
+ *
+ * @apiviz.exclude
*/
final class ServiceInfo {
private String endpointName;
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceURI.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceURI.java 2009-01-08
04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceURI.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -5,6 +5,8 @@
/**
* A parser for JBoss Remoting URI types.
+ *
+ * @apiviz.exclude
*/
public final class ServiceURI {
public static final String SCHEME = "jrs";
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/package-info.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/package-info.java 2009-01-08
04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/package-info.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -1,4 +1,6 @@
/**
* The base Remoting 3 API package.
+ *
+ * @apiviz.exclude org.jboss.remoting.transporter
*/
package org.jboss.remoting;
\ No newline at end of file
Modified:
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/NamedServiceRegistry.java
===================================================================
---
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/NamedServiceRegistry.java 2009-01-08
04:17:15 UTC (rev 4788)
+++
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/NamedServiceRegistry.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -30,6 +30,7 @@
import java.io.IOException;
import org.jboss.remoting.ServiceRegistrationException;
import org.jboss.remoting.CloseHandler;
+import org.jboss.remoting.QualifiedName;
import org.jboss.xnio.IoUtils;
import org.jboss.xnio.log.Logger;
Deleted: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/QualifiedName.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/QualifiedName.java 2009-01-08
04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/QualifiedName.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -1,222 +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.remoting.spi;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.io.UnsupportedEncodingException;
-
-/**
- * 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 a qualified name. A 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 path
- * @return the qualified name
- */
- public static QualifiedName parse(String path) {
- List<String> decoded = new ArrayList<String>();
- 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;
- }
- int segStart = 0;
- int segEnd;
- do {
- segEnd = path.indexOf('/', segStart + 1);
- String segment = segEnd == -1 ? path.substring(segStart + 1) :
path.substring(segStart + 1, 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;
- } while (segEnd != -1);
- return new QualifiedName(decoded.toArray(new String[decoded.size()]));
- }
-
- /**
- * 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()");
- }
- };
- }
-
- /**
- * Get the number of segments in this name.
- *
- * @return the number of segments
- */
- public int length() {
- return segments.length;
- }
-}
Modified: remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/NameTestCase.java
===================================================================
--- remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/NameTestCase.java 2009-01-08
04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/NameTestCase.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -24,6 +24,7 @@
import junit.framework.TestCase;
import org.jboss.remoting.test.support.LoggingHelper;
+import org.jboss.remoting.QualifiedName;
import java.util.Iterator;
/**
Modified:
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConnection.java
===================================================================
---
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConnection.java 2009-01-08
04:17:15 UTC (rev 4788)
+++
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConnection.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -37,7 +37,7 @@
import org.jboss.remoting.spi.NamedServiceRegistry;
import org.jboss.remoting.spi.SpiUtils;
import org.jboss.remoting.spi.AbstractHandleableCloseable;
-import org.jboss.remoting.spi.QualifiedName;
+import org.jboss.remoting.QualifiedName;
import org.jboss.remoting.Endpoint;
import org.jboss.remoting.IndeterminateOutcomeException;
import java.util.concurrent.Executor;
Modified:
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexReadHandler.java
===================================================================
---
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexReadHandler.java 2009-01-08
04:17:15 UTC (rev 4788)
+++
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexReadHandler.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -36,7 +36,7 @@
import org.jboss.remoting.ReplyException;
import org.jboss.remoting.RemoteExecutionException;
import org.jboss.remoting.ServiceRegistrationException;
-import org.jboss.remoting.spi.QualifiedName;
+import org.jboss.remoting.QualifiedName;
import org.jboss.marshalling.Unmarshaller;
import org.jboss.marshalling.Marshalling;
import org.jboss.marshalling.Marshaller;
Modified:
remoting3/trunk/protocol/multiplex/src/test/java/org/jboss/remoting/protocol/multiplex/ConnectionTestCase.java
===================================================================
---
remoting3/trunk/protocol/multiplex/src/test/java/org/jboss/remoting/protocol/multiplex/ConnectionTestCase.java 2009-01-08
04:17:15 UTC (rev 4788)
+++
remoting3/trunk/protocol/multiplex/src/test/java/org/jboss/remoting/protocol/multiplex/ConnectionTestCase.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -41,7 +41,7 @@
import org.jboss.remoting.RemoteExecutionException;
import org.jboss.remoting.ClientSource;
import org.jboss.remoting.Client;
-import org.jboss.remoting.spi.QualifiedName;
+import org.jboss.remoting.QualifiedName;
import org.jboss.remoting.spi.NamedServiceRegistry;
import org.jboss.remoting.spi.RequestHandlerSource;
import org.jboss.remoting.spi.Handle;
Modified:
remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexClientExample.java
===================================================================
---
remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexClientExample.java 2009-01-08
04:17:15 UTC (rev 4788)
+++
remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexClientExample.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -26,11 +26,11 @@
import org.jboss.remoting.Remoting;
import org.jboss.remoting.ClientSource;
import org.jboss.remoting.Client;
+import org.jboss.remoting.QualifiedName;
import org.jboss.remoting.protocol.multiplex.MultiplexProtocol;
import org.jboss.remoting.protocol.multiplex.MultiplexConfiguration;
import org.jboss.remoting.protocol.multiplex.MultiplexConnection;
import org.jboss.remoting.spi.NamedServiceRegistry;
-import org.jboss.remoting.spi.QualifiedName;
import org.jboss.remoting.spi.RequestHandlerSource;
import org.jboss.remoting.spi.Handle;
import org.jboss.xnio.IoUtils;
Modified:
remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexServerExample.java
===================================================================
---
remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexServerExample.java 2009-01-08
04:17:15 UTC (rev 4788)
+++
remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexServerExample.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -30,7 +30,7 @@
import org.jboss.remoting.spi.RequestHandlerSource;
import org.jboss.remoting.spi.Handle;
import org.jboss.remoting.spi.NamedServiceRegistry;
-import org.jboss.remoting.spi.QualifiedName;
+import org.jboss.remoting.QualifiedName;
import org.jboss.xnio.IoUtils;
import org.jboss.xnio.Buffers;
import org.jboss.xnio.IoHandlerFactory;
Modified: remoting3/trunk/standalone/src/main/java/org/jboss/remoting/Remoting.java
===================================================================
--- remoting3/trunk/standalone/src/main/java/org/jboss/remoting/Remoting.java 2009-01-08
04:17:15 UTC (rev 4788)
+++ remoting3/trunk/standalone/src/main/java/org/jboss/remoting/Remoting.java 2009-01-08
22:36:45 UTC (rev 4789)
@@ -18,6 +18,8 @@
/**
* The standalone interface into Remoting. This class contains static methods that are
useful to standalone programs
* for managing endpoints and services in a simple fashion.
+ *
+ * @apiviz.landmark
*/
public final class Remoting {