[jboss-remoting-commits] JBoss Remoting SVN: r5567 - in remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3: spi and 1 other directory.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Fri Oct 23 15:34:47 EDT 2009


Author: david.lloyd at jboss.com
Date: 2009-10-23 15:34:47 -0400 (Fri, 23 Oct 2009)
New Revision: 5567

Added:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/RemotingServiceDescriptor.java
Removed:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderDescriptor.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/MarshallingProtocolDescriptor.java
Modified:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Remoting.java
Log:
Round out service location code with support for all registerable types

Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Remoting.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Remoting.java	2009-10-23 19:10:31 UTC (rev 5566)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Remoting.java	2009-10-23 19:34:47 UTC (rev 5567)
@@ -31,13 +31,18 @@
 import java.util.concurrent.TimeUnit;
 import java.util.ServiceLoader;
 import org.jboss.remoting3.spi.RequestHandler;
-import org.jboss.remoting3.spi.ConnectionProviderDescriptor;
-import org.jboss.remoting3.spi.MarshallingProtocolDescriptor;
+import org.jboss.remoting3.spi.RemotingServiceDescriptor;
+import org.jboss.remoting3.spi.MarshallingProtocol;
+import org.jboss.remoting3.spi.ConnectionProviderFactory;
 import org.jboss.xnio.CloseableExecutor;
 import org.jboss.xnio.IoUtils;
 import org.jboss.xnio.OptionMap;
-import org.jboss.xnio.Option;
 import org.jboss.xnio.log.Logger;
+import org.jboss.marshalling.ClassTable;
+import org.jboss.marshalling.ObjectTable;
+import org.jboss.marshalling.ClassResolver;
+import org.jboss.marshalling.ObjectResolver;
+import org.jboss.marshalling.ClassExternalizerFactory;
 
 /**
  * The standalone interface into Remoting.  This class contains static methods that are useful to standalone programs
@@ -81,37 +86,50 @@
      * <li>{@link Options#LOAD_PROVIDERS} - specify whether providers should be auto-loaded (default {@code true})</li>
      * </ul>
      *
-     * @param name the endpoint name
+     * @param endpointName the endpoint name
      * @param optionMap the endpoint options
      * @return the endpoint
      * @throws IOException if an error occurs
      */
-    public static Endpoint createEndpoint(final String name, final OptionMap optionMap) throws IOException {
-        if (name == null) {
-            throw new NullPointerException("name is null");
+    public static Endpoint createEndpoint(final String endpointName, final OptionMap optionMap) throws IOException {
+        if (endpointName == null) {
+            throw new NullPointerException("endpointName is null");
         }
         if (optionMap == null) {
             throw new NullPointerException("optionMap is null");
         }
         final CloseableExecutor executor = createExecutor(optionMap.get(Options.MAX_THREADS, 10));
-        final Endpoint endpoint = createEndpoint(executor, name);
+        final Endpoint endpoint = createEndpoint(executor, endpointName);
         endpoint.addCloseHandler(new CloseHandler<Endpoint>() {
             public void handleClose(final Endpoint closed) {
                 IoUtils.safeClose(executor);
             }
         });
         if (optionMap.get(Options.LOAD_PROVIDERS, true)) {
-            for (ConnectionProviderDescriptor descriptor : ServiceLoader.load(ConnectionProviderDescriptor.class)) try {
-                endpoint.addConnectionProvider(descriptor.getUriScheme(), descriptor.getConnectionProviderFactory());
-            } catch (DuplicateRegistrationException e) {
-                log.debug("Duplicate registration for URI scheme '" + descriptor.getUriScheme() + "'");
+            for (RemotingServiceDescriptor descriptor : ServiceLoader.load(RemotingServiceDescriptor.class)) {
+                final String name = descriptor.getName();
+                final Class serviceType = descriptor.getType();
+                final Object service = descriptor.getService();
+                try {
+                    if (serviceType == ConnectionProviderFactory.class) {
+                        endpoint.addConnectionProvider(name, (ConnectionProviderFactory<?>) service);
+                    } else if (serviceType == MarshallingProtocol.class) {
+                        endpoint.addMarshallingProtocol(name, (MarshallingProtocol) service);
+                    } else if (serviceType == ClassTable.class) {
+                        endpoint.addUserClassTable(name, (ClassTable) service);
+                    } else if (serviceType == ObjectTable.class) {
+                        endpoint.addUserObjectTable(name, (ObjectTable) service);
+                    } else if (serviceType == ClassResolver.class) {
+                        endpoint.addUserClassResolver(name, (ClassResolver) service);
+                    } else if (serviceType == ObjectResolver.class) {
+                        endpoint.addUserObjectResolver(name, (ObjectResolver) service);
+                    } else if (serviceType == ClassExternalizerFactory.class) {
+                        endpoint.addUserExternalizerFactory(name, (ClassExternalizerFactory) service);
+                    }
+                } catch (DuplicateRegistrationException e) {
+                    log.debug("Duplicate registration for '" + name + "' of type " + serviceType);
+                }
             }
-            for (MarshallingProtocolDescriptor descriptor : ServiceLoader.load(MarshallingProtocolDescriptor.class)) try {
-                endpoint.addMarshallingProtocol(descriptor.getName(), descriptor.getMarshallingProtocol());
-            } catch (DuplicateRegistrationException e) {
-                log.debug("Duplicate registration for marshalling protocol '" + descriptor.getName() + "'");
-            }
-            // todo - marshallers and components thereof
         }
         return endpoint;
     }

Deleted: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderDescriptor.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderDescriptor.java	2009-10-23 19:10:31 UTC (rev 5566)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderDescriptor.java	2009-10-23 19:34:47 UTC (rev 5567)
@@ -1,50 +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.spi;
-
-/**
- * A descriptor for automatically-discovered connection provider types.  Since instances of this interface are
- * constructed automatically, implementing classes should have a no-arg constructor.
- * <p>
- * To add an automatically-discovered provider, create a file called {@code "META-INF/services/org.jboss.remoting3.spi.ConnectionProviderDescriptor"}
- * and populate it with the names of classes that implement this interface.
- *
- * @see java.util.ServiceLoader
- */
-public interface ConnectionProviderDescriptor {
-
-    /**
-     * Get the URI scheme for this provider.  A provider factory may be registered more than one time with different
-     * URI schemes.
-     *
-     * @return the URI scheme
-     */
-    String getUriScheme();
-
-    /**
-     * Get the connection provider factory to associate with the given URI scheme.
-     *
-     * @return the connection provider factory
-     */
-    ConnectionProviderFactory<?> getConnectionProviderFactory();
-}

Deleted: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/MarshallingProtocolDescriptor.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/MarshallingProtocolDescriptor.java	2009-10-23 19:10:31 UTC (rev 5566)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/MarshallingProtocolDescriptor.java	2009-10-23 19:34:47 UTC (rev 5567)
@@ -1,49 +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.spi;
-
-/**
- * A descriptor for automatically-discovered marshaller types.  Since instances of this interface are
- * constructed automatically, implementing classes should have a no-arg constructor.
- * <p>
- * To add an automatically-discovered marshaller, create a file called {@code "META-INF/services/org.jboss.remoting3.spi.MarshallingProtocolDescriptor"}
- * and populate it with the names of classes that implement this interface.
- *
- * @see java.util.ServiceLoader
- */
-public interface MarshallingProtocolDescriptor {
-
-    /**
-     * Get the name of this marshalling protocol.
-     *
-     * @return the name
-     */
-    String getName();
-
-    /**
-     * Get the marshalling protocol to associate with the given name.
-     *
-     * @return the marshalling protocol
-     */
-    MarshallingProtocol getMarshallingProtocol();
-}

Copied: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/RemotingServiceDescriptor.java (from rev 5566, remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/MarshallingProtocolDescriptor.java)
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/RemotingServiceDescriptor.java	                        (rev 0)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/RemotingServiceDescriptor.java	2009-10-23 19:34:47 UTC (rev 5567)
@@ -0,0 +1,67 @@
+/*
+ * 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.spi;
+
+/**
+ * A descriptor for automatically-discovered remoting service types.  Since instances of this interface are
+ * constructed automatically, implementing classes should have a no-arg constructor.
+ * <p>
+ * To add an automatically-discovered service, create a file called {@code "META-INF/services/org.jboss.remoting3.spi.RemotingServiceDescriptor"}
+ * and populate it with the names of classes that implement this interface.
+ *
+ * @see java.util.ServiceLoader
+ */
+public interface RemotingServiceDescriptor<T> {
+
+    /**
+     * Get the type of service provided by this descriptor.  Only the following types are supported:
+     * <ul>
+     * <li><code>{@link MarshallingProtocol}.class</code> - named marshalling protocol</li>
+     * <li><code>{@link ConnectionProviderFactory}.class</code> - named connection provider URI scheme</li>
+     * <li><code>{@link org.jboss.marshalling.ClassTable ClassTable}.class</code> - named marshalling class table</li>
+     * <li><code>{@link org.jboss.marshalling.ObjectTable ObjectTable}.class</code> - named marshalling object table</li>
+     * <li><code>{@link org.jboss.marshalling.ClassExternalizerFactory ClassExternalizerFactory}.class</code> - named marshalling externalizer factory</li>
+     * <li><code>{@link org.jboss.marshalling.ClassResolver ClassResolver}.class</code> - named marshalling class resolver</li>
+     * <li><code>{@link org.jboss.marshalling.ObjectResolver ObjectResolver}.class</code> - named marshalling object resolver</li>
+     * </ul>
+     * Other types are ignored, allowing new types to be added in the future while maintaining compatibility with
+     * older versions.
+     *
+     * @return the type of remoting service
+     */
+    Class<T> getType();
+
+    /**
+     * Get the name of this service.
+     *
+     * @return the name
+     */
+    String getName();
+
+    /**
+     * Get the service to associate with the given name.
+     *
+     * @return the service
+     */
+    T getService();
+}



More information about the jboss-remoting-commits mailing list