# Adding a New Transport

It is quite straightforward to extend Remoting with a new transport (other than the part about writing the new transport!). There are only three requirements. Suppose the new transport is to be called "nio", which would then be used by an InvokerLocator such as "nio://bluemonkey.com:5555/?timeout=10000".

1. There needs to be a class org.jboss.remoting.transport.nio.TransportServerFactory which implements the interface org.jboss.remoting.transport.ServerFactory:

                 public interface ServerFactory
                 {
                    public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) throws IOException;

                    public boolean supportsSSL();
                 }

2. There needs to be a class org.jboss.remoting.transport.nio.TransportClientFactory which implements the interface org.jboss.remoting.transport.ClientFactory:

                 public interface ClientFactory
                 {
                    public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException;

                    public boolean supportsSSL();
                 }

3. The factory classes must be loadable when the first "nio" InvokerLocator is encountered.

The factories can be quite simple. The createServerInvoker() method must return an instance of an appropriate subclass of org.jboss.remoting.ServerInvoker, the createClientInvoker() method must return an appropriate implementation of the interface org.jboss.remoting.transport.ClientInvoker, and the supportsSSL() methods indicate if the transport supports SSL.

The factories for the "socket" transport, for example, are

        package org.jboss.remoting.transport.socket;

        import org.jboss.remoting.InvokerLocator;
        import org.jboss.remoting.ServerInvoker;
        import org.jboss.remoting.transport.ServerFactory;
        import java.util.Map;

        public class TransportServerFactory implements ServerFactory
        {
           public ServerInvoker createServerInvoker(InvokerLocator locator, Map config)
           {
              return new SocketServerInvoker(locator, config);
           }

           public boolean supportsSSL()
           {
              return false;
           }
        }

and

        package org.jboss.remoting.transport.socket;

        import org.jboss.remoting.InvokerLocator;
        import org.jboss.remoting.transport.ClientFactory;
        import org.jboss.remoting.transport.ClientInvoker;
        import java.io.IOException;
        import java.util.Map;

        public class TransportClientFactory implements ClientFactory
        {
           public ClientInvoker createClientInvoker(InvokerLocator locator, Map config)
                 throws IOException
           {
              return new SocketClientInvoker(locator, config);
           }

           public boolean supportsSSL()
           {
              return false;
           }
        }

Similarly, the server invoker factory for the "sslsocket" transport is

        package org.jboss.remoting.transport.sslsocket;

        import org.jboss.remoting.InvokerLocator;
        import org.jboss.remoting.ServerInvoker;
        import org.jboss.remoting.transport.ServerFactory;
        import java.util.Map;

        public class TransportServerFactory implements ServerFactory
        {
           public ServerInvoker createServerInvoker(InvokerLocator locator, Map config)
           {
              return new SSLSocketServerInvoker(locator, config);
           }

           public boolean supportsSSL()
           {
              return true;
           }
        }