Author: david.lloyd(a)jboss.com
Date: 2008-11-14 19:46:59 -0500 (Fri, 14 Nov 2008)
New Revision: 4689
Added:
remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceURI.java
Removed:
remoting3/trunk/util/src/main/java/org/jboss/remoting/util/ServiceURI.java
Modified:
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java
Log:
Move ServiceURI to api module
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceURI.java (from rev
4687, remoting3/trunk/util/src/main/java/org/jboss/remoting/util/ServiceURI.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceURI.java
(rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceURI.java 2008-11-15
00:46:59 UTC (rev 4689)
@@ -0,0 +1,131 @@
+package org.jboss.remoting;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * A parser for JBoss Remoting URI types.
+ */
+public final class ServiceURI {
+ public static final String SCHEME = "jrs";
+
+ private ServiceURI() {
+ }
+
+ /**
+ * Determine if this URI is a valid Remoting service URI.
+ *
+ * @param uri the URI
+ * @return {@code true} if the given URI is a valid Remoting service URI
+ */
+ public static boolean isRemotingServiceUri(final URI uri) {
+ return SCHEME.equals(uri.getScheme()) && uri.isOpaque();
+ }
+
+ /**
+ * Get the service type from a Remoting service URI.
+ *
+ * @param uri the URI
+ * @return the service type
+ * @throws IllegalArgumentException if the given URI is not for a remoting service
+ */
+ public static String getServiceType(final URI uri) throws IllegalArgumentException {
+ if (! isRemotingServiceUri(uri)) {
+ throw new IllegalArgumentException("Not a valid remoting service
URI");
+ }
+ final String ssp = uri.getSchemeSpecificPart();
+ final int firstColon = ssp.indexOf(':');
+ final String serviceType;
+ if (firstColon == -1) {
+ serviceType = ssp;
+ } else {
+ serviceType = ssp.substring(0, firstColon);
+ }
+ return serviceType;
+ }
+
+ /**
+ * Get the group name from a Remoting service URI.
+ *
+ * @param uri the URI
+ * @return the group name
+ * @throws IllegalArgumentException if the given URI is not for a remoting service
+ */
+ public static String getGroupName(final URI uri) throws IllegalArgumentException {
+ if (! isRemotingServiceUri(uri)) {
+ throw new IllegalArgumentException("Not a valid remoting service
URI");
+ }
+ final String ssp = uri.getSchemeSpecificPart();
+ final int firstColon = ssp.indexOf(':');
+ final String groupName;
+ if (firstColon == -1) {
+ return "";
+ }
+ final int secondColon = ssp.indexOf(':', firstColon + 1);
+ if (secondColon == -1) {
+ groupName = ssp.substring(firstColon + 1);
+ } else {
+ groupName = ssp.substring(firstColon + 1, secondColon);
+ }
+ return groupName;
+ }
+
+ /**
+ * Get the endpoint name from a Remoting service URI.
+ *
+ * @param uri the URI
+ * @return the endpoint name
+ * @throws IllegalArgumentException if the given URI is not for a remoting service
+ */
+ public static String getEndpointName(final URI uri) throws IllegalArgumentException
{
+ if (! isRemotingServiceUri(uri)) {
+ throw new IllegalArgumentException("Not a valid remoting service
URI");
+ }
+ final String ssp = uri.getSchemeSpecificPart();
+ final int firstColon = ssp.indexOf(':');
+ final String endpointName;
+ if (firstColon == -1) {
+ return "";
+ }
+ final int secondColon = ssp.indexOf(':', firstColon + 1);
+ if (secondColon == -1) {
+ return "";
+ }
+ // ::: is not officially supported, but this leaves room for extensions
+ final int thirdColon = ssp.indexOf(':', secondColon + 1);
+ if (thirdColon == -1) {
+ endpointName = ssp.substring(secondColon + 1);
+ } else {
+ endpointName = ssp.substring(secondColon + 1, thirdColon);
+ }
+ return endpointName;
+ }
+
+ /**
+ * Create a Remoting service URI.
+ *
+ * @param serviceType the service type, if any
+ * @param groupName the group name, if any
+ * @param endpointName the endpoint name, if any
+ * @return the URI
+ */
+ public static URI create(String serviceType, String groupName, String endpointName)
{
+ try {
+ StringBuilder builder = new StringBuilder(serviceType.length() +
groupName.length() + endpointName.length() + 2);
+ if (serviceType != null && serviceType.length() > 0) {
+ builder.append(serviceType);
+ }
+ builder.append(':');
+ if (groupName != null && groupName.length() > 0) {
+ builder.append(groupName);
+ }
+ builder.append(':');
+ if (endpointName != null && endpointName.length() > 0) {
+ builder.append(endpointName);
+ }
+ return new URI(SCHEME, builder.toString(), null);
+ } catch (URISyntaxException e) {
+ throw new IllegalStateException("URI syntax exception should not be
possible here", e);
+ }
+ }
+}
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java
===================================================================
---
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java 2008-11-15
00:29:52 UTC (rev 4688)
+++
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java 2008-11-15
00:46:59 UTC (rev 4689)
@@ -21,6 +21,7 @@
import org.jboss.remoting.LocalServiceConfiguration;
import org.jboss.remoting.EndpointPermission;
import org.jboss.remoting.RemoteServiceConfiguration;
+import org.jboss.remoting.ServiceURI;
import org.jboss.remoting.spi.AbstractSimpleCloseable;
import org.jboss.remoting.spi.Handle;
import org.jboss.remoting.spi.RequestHandler;
@@ -28,7 +29,6 @@
import org.jboss.remoting.util.CollectionUtil;
import org.jboss.remoting.util.NamingThreadFactory;
import org.jboss.remoting.util.OrderedExecutorFactory;
-import org.jboss.remoting.util.ServiceURI;
import org.jboss.remoting.version.Version;
import org.jboss.xnio.FailedIoFuture;
import org.jboss.xnio.FinishedIoFuture;
Deleted: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/ServiceURI.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/ServiceURI.java 2008-11-15
00:29:52 UTC (rev 4688)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/ServiceURI.java 2008-11-15
00:46:59 UTC (rev 4689)
@@ -1,131 +0,0 @@
-package org.jboss.remoting.util;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-/**
- * A parser for JBoss Remoting URI types.
- */
-public final class ServiceURI {
- public static final String SCHEME = "jrs";
-
- private ServiceURI() {
- }
-
- /**
- * Determine if this URI is a valid Remoting service URI.
- *
- * @param uri the URI
- * @return {@code true} if the given URI is a valid Remoting service URI
- */
- public static boolean isRemotingServiceUri(final URI uri) {
- return SCHEME.equals(uri.getScheme()) && uri.isOpaque();
- }
-
- /**
- * Get the service type from a Remoting service URI.
- *
- * @param uri the URI
- * @return the service type
- * @throws IllegalArgumentException if the given URI is not for a remoting service
- */
- public static String getServiceType(final URI uri) throws IllegalArgumentException {
- if (! isRemotingServiceUri(uri)) {
- throw new IllegalArgumentException("Not a valid remoting service
URI");
- }
- final String ssp = uri.getSchemeSpecificPart();
- final int firstColon = ssp.indexOf(':');
- final String serviceType;
- if (firstColon == -1) {
- serviceType = ssp;
- } else {
- serviceType = ssp.substring(0, firstColon);
- }
- return serviceType;
- }
-
- /**
- * Get the group name from a Remoting service URI.
- *
- * @param uri the URI
- * @return the group name
- * @throws IllegalArgumentException if the given URI is not for a remoting service
- */
- public static String getGroupName(final URI uri) throws IllegalArgumentException {
- if (! isRemotingServiceUri(uri)) {
- throw new IllegalArgumentException("Not a valid remoting service
URI");
- }
- final String ssp = uri.getSchemeSpecificPart();
- final int firstColon = ssp.indexOf(':');
- final String groupName;
- if (firstColon == -1) {
- return "";
- }
- final int secondColon = ssp.indexOf(':', firstColon + 1);
- if (secondColon == -1) {
- groupName = ssp.substring(firstColon + 1);
- } else {
- groupName = ssp.substring(firstColon + 1, secondColon);
- }
- return groupName;
- }
-
- /**
- * Get the endpoint name from a Remoting service URI.
- *
- * @param uri the URI
- * @return the endpoint name
- * @throws IllegalArgumentException if the given URI is not for a remoting service
- */
- public static String getEndpointName(final URI uri) throws IllegalArgumentException
{
- if (! isRemotingServiceUri(uri)) {
- throw new IllegalArgumentException("Not a valid remoting service
URI");
- }
- final String ssp = uri.getSchemeSpecificPart();
- final int firstColon = ssp.indexOf(':');
- final String endpointName;
- if (firstColon == -1) {
- return "";
- }
- final int secondColon = ssp.indexOf(':', firstColon + 1);
- if (secondColon == -1) {
- return "";
- }
- // ::: is not officially supported, but this leaves room for extensions
- final int thirdColon = ssp.indexOf(':', secondColon + 1);
- if (thirdColon == -1) {
- endpointName = ssp.substring(secondColon + 1);
- } else {
- endpointName = ssp.substring(secondColon + 1, thirdColon);
- }
- return endpointName;
- }
-
- /**
- * Create a Remoting service URI.
- *
- * @param serviceType the service type, if any
- * @param groupName the group name, if any
- * @param endpointName the endpoint name, if any
- * @return the URI
- */
- public static URI create(String serviceType, String groupName, String endpointName)
{
- try {
- StringBuilder builder = new StringBuilder(serviceType.length() +
groupName.length() + endpointName.length() + 2);
- if (serviceType != null && serviceType.length() > 0) {
- builder.append(serviceType);
- }
- builder.append(':');
- if (groupName != null && groupName.length() > 0) {
- builder.append(groupName);
- }
- builder.append(':');
- if (endpointName != null && endpointName.length() > 0) {
- builder.append(endpointName);
- }
- return new URI(SCHEME, builder.toString(), null);
- } catch (URISyntaxException e) {
- throw new IllegalStateException("URI syntax exception should not be
possible here", e);
- }
- }
-}
Show replies by date