You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2007/09/27 00:15:46 UTC

svn commit: r579828 [2/2] - in /geronimo/sandbox/gshell/trunk/gshell-whisper: ./ src/main/java/org/apache/geronimo/gshell/whisper/crypto/ src/main/java/org/apache/geronimo/gshell/whisper/marshal/ src/main/java/org/apache/geronimo/gshell/whisper/message...

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseConfiguration.java?rev=579828&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseConfiguration.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseConfiguration.java Wed Sep 26 15:15:42 2007
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.whisper.transport.base;
+
+import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
+import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.ThreadModel;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class BaseConfiguration
+{
+    private IoHandler handler;
+
+    private ThreadModel threadModel;
+
+    protected BaseConfiguration() {}
+
+    public void setHandler(final IoHandler handler) {
+        this.handler = handler;
+    }
+
+    public IoHandler getHandler() {
+        return handler;
+    }
+
+    public ThreadModel getThreadModel() {
+        return threadModel;
+    }
+
+    public void setThreadModel(final ThreadModel threadModel) {
+        this.threadModel = threadModel;
+    }
+
+    public String toString() {
+        return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
+    }
+
+    //
+    // TODO: Add a list of filters to tack on
+    //
+}

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseConfiguration.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseConfiguration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java (from r578596, geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseCommon.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java?p2=geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java&p1=geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseCommon.java&r1=578596&r2=579828&rev=579828&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseCommon.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java Wed Sep 26 15:15:42 2007
@@ -22,10 +22,7 @@
 import java.net.SocketAddress;
 
 import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
-import org.apache.geronimo.gshell.whisper.message.MessageHandler;
-import org.apache.geronimo.gshell.whisper.message.spi.MessageProvider;
-import org.apache.geronimo.gshell.whisper.request.RequestResponseFilter;
-import org.apache.geronimo.gshell.whisper.stream.SessionStreamFilter;
+import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
 import org.apache.geronimo.gshell.whisper.transport.Transport;
 import org.apache.geronimo.gshell.whisper.transport.TransportExceptionMonitor;
 import org.apache.geronimo.gshell.whisper.transport.TransportServer;
@@ -39,9 +36,10 @@
 import org.apache.mina.common.IoServiceListener;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.SimpleByteBufferAllocator;
+import org.apache.mina.common.ThreadModel;
 import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
-import org.codehaus.plexus.PlexusContainer;
+import org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,7 +48,7 @@
  *
  * @version $Rev$ $Date$
  */
-public abstract class BaseCommon
+public abstract class BaseService<T extends IoService>
 {
     static {
         // Setup our exception monitor
@@ -61,196 +59,160 @@
         ByteBuffer.setAllocator(new SimpleByteBufferAllocator());
     }
 
-    protected final Logger log = LoggerFactory.getLogger(getClass());
+    protected transient final Logger log = LoggerFactory.getLogger(getClass());
 
-    private IoHandler handler;
-
-    private IoService service;
+    protected AddressFactory addressFactory;
 
-    // private StatCollector statCollector;
+    protected BaseService(final AddressFactory addressFactory) {
+        this.addressFactory = addressFactory;
+    }
 
     public String toString() {
-        return ReflectionToStringBuilder.toString(this);
+        return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
+    }
+
+    //
+    // Configuration
+    //
+
+    protected abstract BaseConfiguration getBaseConfiguration();
+
+    private IoHandler handler;
+
+    protected synchronized IoHandler createHandler() throws Exception {
+        return getBaseConfiguration().getHandler();
     }
 
-    protected IoHandler getHandler() {
+    protected synchronized IoHandler getHandler() throws Exception {
         if (handler == null) {
-            throw new IllegalStateException("Handler not bound");
+            handler = createHandler();
+        }
+
+        if (handler == null) {
+            throw new IllegalStateException("Handler has not been configured");
         }
         
         return handler;
     }
 
-    public IoService getService() {
-        return service;
+    private ThreadModel threadModel;
+
+    protected synchronized ThreadModel createThreadModel() throws Exception {
+        return getBaseConfiguration().getThreadModel();
+    }
+
+    protected synchronized ThreadModel getThreadModel() throws Exception {
+        if (threadModel == null) {
+            threadModel = createThreadModel();
+        }
+
+        // This can be null to leave the default model installed
+        return threadModel;
     }
 
-    //
-    // Configuration
-    //
-    
     protected void configure(final IoService service) throws Exception {
         assert service != null;
 
-        this.service = service;
-
+        log.debug("Configure: {}", service);
+        
+        // Watch for service events
         service.addListener(new IoServiceListener() {
+            private void log(Object msg) {
+                System.err.println(">>> [" + Thread.currentThread().getName() + "] " + msg);
+            }
+
             public void serviceActivated(final IoService service, final SocketAddress serviceAddress, final IoHandler handler, final IoServiceConfig config) {
-                log.info("Service activated: {}", service);
+                log("Service activated: " + service);
 
-                // log.info("Service activated: {}, {}, {}, {}", service, serviceAddress, handler, config);
+                log.debug("Service activated: {}, filters:", service);
 
-                logFilters(service);
+                for (IoFilterChain.Entry entry : service.getFilterChain().getAll()) {
+                    log.debug("    {}", entry);
+                }
             }
 
             public void serviceDeactivated(final IoService service, final SocketAddress serviceAddress, final IoHandler handler, final IoServiceConfig config) {
-                log.info("Service deactivated: {}", service);
+                log("Service deactivated: " + service);
 
-                // log.info("Service deactivated: {}, {}, {}, {}", service, serviceAddress, handler, config);
+                log.debug("Service deactivated: {}", service);
             }
 
             public void sessionCreated(final IoSession session) {
-                log.info("Session created: {}", session);
+                log("Session created: " + service);
 
-                logFilters(session);
+                log.debug("Session created: {}; filters:", session);
+
+                for (IoFilterChain.Entry entry : session.getFilterChain().getAll()) {
+                    log.debug("    {}", entry);
+                }
             }
 
             public void sessionDestroyed(final IoSession session) {
-                log.info("Session destroyed: {}", session);
+                log("Session destroyed: " + service);
+                
+                log.debug("Session destroyed: {}", session);
             }
         });
 
-        // Setup the io handler
-        handler = getMessageHandler();
 
-        // Install the default set of filters
+        configure(service.getDefaultConfig());
+        
         configure(service.getFilterChain());
-
-        //
-        // TODO: Start up a scheduled task to periodically log stats
-        //
-
-        // Setup stat collection
-        // statCollector = new StatCollector(service);
-        // statCollector.start();
     }
 
-    protected void configure(final DefaultIoFilterChainBuilder chain) throws Exception {
-        assert chain != null;
+    protected void configure(final IoServiceConfig config) throws Exception {
+        assert config != null;
 
-        // chain.addLast(ProfilerTimerFilter.class.getSimpleName(), new ProfilerTimerFilter());
-
-        //
-        // TODO: Test this guy out....
-        //
-        // chain.addLast(CryptoContextInjectingFilter.class.getSimpleName(), new CryptoContextInjectingFilter(getProvider().getCryptoContext()));
-
-        chain.addLast(ProtocolCodecFilter.class.getSimpleName(), new ProtocolCodecFilter(getProvider().getProtocolCodecFactory()));
-        
-        chain.addLast(LoggingFilter.class.getSimpleName(), new LoggingFilter());
+        log.debug("Configure: {}", config);
 
-        chain.addLast(SessionStreamFilter.class.getSimpleName(), new SessionStreamFilter());
+        ThreadModel threadModel = getThreadModel();
 
-        chain.addLast(RequestResponseFilter.class.getSimpleName(), new RequestResponseFilter());
-    }
-
-    public void close() {
-        // statCollector.stop();
+        if (threadModel != null) {
+            config.setThreadModel(threadModel);
+            log.debug("Installed custom thread model: {}", threadModel);
+        }
     }
 
-    //
-    // Logging Helpers
-    //
-    
-    protected void logFilters(final IoService service) {
-        assert service != null;
+    protected void configure(final DefaultIoFilterChainBuilder chain) throws Exception {
+        assert chain != null;
 
-        log.debug("Service filters:");
+        log.debug("Configure: {}", chain);
 
-        for (IoFilterChain.Entry entry : service.getFilterChain().getAll()) {
-            log.debug("    {}", entry);
-        }
-    }
+        // For right now just add a few hard codded to test with
 
-    protected void logFilters(final IoSession session) {
-        assert session != null;
-        
-        log.debug("Session filters:");
+        chain.addLast(ProtocolCodecFilter.class.getSimpleName(), new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
 
-        for (IoFilterChain.Entry entry : session.getFilterChain().getAll()) {
-            log.debug("    {}", entry);
-        }
+        chain.addLast(LoggingFilter.class.getSimpleName(), new LoggingFilter());
     }
 
-    /*
-    protected void logStats(final IoSession session) {
+    protected void configure(final IoSession session) throws Exception {
         assert session != null;
 
-        IoSessionStat stat = (IoSessionStat) session.getAttribute(StatCollector.KEY);
-
-        if (stat != null) {
-            log.debug("Stats: {}", ReflectionToStringBuilder.toString(stat, ToStringStyle.SHORT_PREFIX_STYLE));
-        }
+        log.debug("Configure: {}", session);
     }
-    */
-    
+
     //
-    // AutoWire Support, Setters exposed to support Plexus autowire()  Getters exposed to handle state checking.
+    // Closeable
     //
 
-    private PlexusContainer container;
-
-    private MessageProvider provider;
+    private boolean closed;
 
-    private MessageHandler messageHandler;
-
-    public void setMessageHandler(final MessageHandler messageHandler) {
-        assert messageHandler != null;
-
-        log.trace("Using message handler: {}", messageHandler);
-
-        this.messageHandler = messageHandler;
+    public synchronized boolean isClosed() {
+        return closed;
     }
 
-    protected MessageHandler getMessageHandler() {
-        if (messageHandler == null) {
-            throw new IllegalStateException("Message handler not bound");
+    protected void ensureOpened() {
+        if (isClosed()) {
+            throw new IllegalStateException("Closed");
         }
-
-        return messageHandler;
-    }
-    
-    public void setProvider(final MessageProvider provider) {
-        assert provider != null;
-
-        log.trace("Using provider: {}", provider);
-
-        this.provider = provider;
-    }
-
-    protected MessageProvider getProvider() {
-        if (provider == null) {
-            throw new IllegalStateException("Provider not bound");
-        }
-
-        return provider;
-    }
-
-    //
-    // HACK: Added for manual wiring of the message visitor, autowire() can't seem to handle it... :-(
-    //
-
-    public void setContainer(final PlexusContainer container) {
-        log.trace("Using plexus container: {}", container);
-
-        this.container = container;
     }
 
-    protected PlexusContainer getContainer() {
-        if (container == null) {
-            throw new IllegalStateException("Container not bound");
+    public synchronized void close() {
+        if (isClosed()) {
+            // ignore duplicate close
+            return;
         }
 
-        return container;
+        closed = true;
     }
 }

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransport.java?rev=579828&r1=579827&r2=579828&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransport.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransport.java Wed Sep 26 15:15:42 2007
@@ -23,132 +23,170 @@
 import java.io.OutputStream;
 import java.net.SocketAddress;
 import java.net.URI;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.geronimo.gshell.common.Duration;
 import org.apache.geronimo.gshell.whisper.message.Message;
-import org.apache.geronimo.gshell.whisper.message.MessageHandler;
-import org.apache.geronimo.gshell.whisper.message.MessageVisitor;
 import org.apache.geronimo.gshell.whisper.request.Requestor;
-import org.apache.geronimo.gshell.whisper.session.ThreadPoolModel;
+import org.apache.geronimo.gshell.whisper.session.SessionAttributeBinder;
 import org.apache.geronimo.gshell.whisper.stream.SessionInputStream;
 import org.apache.geronimo.gshell.whisper.stream.SessionOutputStream;
 import org.apache.geronimo.gshell.whisper.transport.Transport;
 import org.apache.mina.common.CloseFuture;
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.IoConnector;
+import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.WriteFuture;
-import org.codehaus.plexus.component.annotations.Requirement;
 
 /**
  * Support for {@link Transport} implementations.
  *
  * @version $Rev$ $Date$
  */
-public abstract class BaseTransport
-    extends BaseCommon
+public abstract class BaseTransport<T extends IoConnector>
+    extends BaseService
     implements Transport
 {
-    private static final AtomicLong COUNTER = new AtomicLong(0);
-    
-    protected final URI remoteLocation;
+    private static final AtomicLong INSTANCE_COUNTER = new AtomicLong(0);
 
-    protected final SocketAddress remoteAddress;
+    private static final SessionAttributeBinder<Transport> TRANSPORT = new SessionAttributeBinder<Transport>(Transport.class);
 
-    protected final URI localLocation;
+    protected URI remoteLocation;
 
-    protected final SocketAddress localAddress;
+    protected SocketAddress remoteAddress;
 
-    protected IoConnector connector;
+    protected URI localLocation;
 
-    protected ThreadPoolModel threadModel;
+    protected SocketAddress localAddress;
+
+    protected T connector;
 
     protected IoSession session;
 
-    protected boolean connected;
+    protected BaseTransport(final AddressFactory addressFactory) {
+        super(addressFactory);
+    }
 
-    @Requirement(role=MessageVisitor.class, hint="client")
-    private MessageVisitor v;
+    //
+    // Configuration
+    //
 
-    protected BaseTransport(final URI remoteLocation, final SocketAddress remoteAddress, final URI localLocation, final SocketAddress localAddress) throws Exception {
-        assert remoteLocation != null;
-        assert remoteAddress != null;
+    protected static class BaseTransportConfiguration
+        extends BaseConfiguration
+        implements Transport.Configuration
+    {
+        // TODO:
+    }
 
-        this.remoteLocation = remoteLocation;
-        this.remoteAddress = remoteAddress;
+    private Configuration config;
 
-        this.localLocation = localLocation;
-        this.localAddress = localAddress;
+    protected abstract Configuration createConfiguration();
+
+    public synchronized Configuration getConfiguration() {
+        if (config == null) {
+            config = createConfiguration();
+        }
+
+        return config;
     }
 
-    protected abstract IoConnector createConnector() throws Exception;
+    public synchronized void setConfiguration(final Configuration config) {
+        assert config != null;
 
-    protected synchronized void init() throws Exception {
-        // For now we must manually bind the message handler, plexus is unable to provide injection for us
-        setMessageHandler((MessageHandler) getContainer().lookup(MessageHandler.class, "client"));
+        this.config = config;
 
-        // Setup the connector service
-        connector = createConnector();
+        log.debug("Using configuration: {}", config);
+    }
+
+    @Override
+    protected synchronized BaseConfiguration getBaseConfiguration() {
+        return (BaseConfiguration) getConfiguration();
+    }
 
-        // Install the thread model
-        threadModel = new ThreadPoolModel(getClass().getSimpleName() + "-" + COUNTER.getAndIncrement());
-        connector.getDefaultConfig().setThreadModel(threadModel);
+    //
+    // Connection
+    //
 
-        // Configure the connector
-        configure(connector);
+    protected abstract T createConnector() throws Exception;
+
+    synchronized void connect(final URI remote, final URI local) throws Exception {
+        this.remoteLocation = remote;
+        this.remoteAddress = addressFactory.create(remote);
+
+        this.localLocation = local;
+        this.localAddress = addressFactory.create(local);
+
+        connect();
     }
 
-    public synchronized void connect() throws Exception {
-        if (connected) {
-            throw new IllegalStateException("Already connected");
-        }
+    synchronized void connect() throws Exception {
+        log.debug("Connecting");
 
-        init();
+        connector = createConnector();
+        log.debug("Connector: {}", connector);
 
-        log.info("Connecting to: {}", remoteAddress);
+        configure(connector);
 
-        ConnectFuture cf = connector.connect(remoteAddress, localAddress, getHandler());
+        IoHandler handler = getHandler();
+        log.debug("Handler: {}", handler);
 
+        log.info("Connecting to: {}", remoteAddress);
+        ConnectFuture cf = connector.connect(remoteAddress, localAddress, handler);
+
+        log.debug("Waiting for connection to establish");
         cf.join();
 
+        // And fetch session so we can talk
         session = cf.getSession();
+        log.debug("Session: ", session);
 
-        connected = true;
+        // Maybe configure something
+        configure(session);
 
-        log.info("Connected");
-    }
+        // Stuff the transport instance into the session's context so we can find ourself later
+        TRANSPORT.bind(session, this);
 
-    public boolean isConnected() {
-        return connected;
+        log.info("Connected to: {}", session.getRemoteAddress());
     }
 
     public synchronized void close() {
+        if (isClosed()) {
+            // Ignore duplciate close
+            return;
+        }
+
         try {
+            TRANSPORT.unbind(session);
+            
             CloseFuture cf = session.close();
-
             cf.join();
-
-            threadModel.close();
         }
         finally {
             super.close();
         }
     }
 
-    public URI getRemoteLocation() {
+    public URI getRemote() {
         return remoteLocation;
     }
 
-    public URI getLocalLocation() {
+    public URI getLocal() {
         return localLocation;
     }
 
+    public T getConnector() {
+        return connector;
+    }
+
     public IoSession getSession() {
         return session;
     }
 
+    //
+    // Streams
+    //
+
     public InputStream getInputStream() {
         return SessionInputStream.BINDER.lookup(session);
     }
@@ -157,6 +195,14 @@
         return SessionOutputStream.BINDER.lookup(session);
     }
 
+    public OutputStream getErrorStream() {
+        throw new UnsupportedOperationException("TODO");
+    }
+
+    //
+    // Sending Messages
+    //
+
     public WriteFuture send(final Object msg) throws Exception {
         assert msg != null;
 
@@ -173,17 +219,26 @@
 
     public Message request(final Message msg, final Duration timeout) throws Exception {
         assert msg != null;
+        assert timeout != null;
 
         Requestor requestor = new Requestor(this);
 
         return requestor.request(msg, timeout);
     }
 
-    public Message request(final Message msg, final long timeout, final TimeUnit unit) throws Exception {
-        assert msg != null;
+    //
+    // Listeners
+    //
 
-        Requestor requestor = new Requestor(this);
+    public void addListener(final Listener listener) {
+        assert listener != null;
+
+        throw new UnsupportedOperationException();
+    }
+
+    public void removeListener(final Listener listener) {
+        assert listener != null;
 
-        return requestor.request(msg, timeout, unit);
+        throw new UnsupportedOperationException();
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransportFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransportFactory.java?rev=579828&r1=579827&r2=579828&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransportFactory.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransportFactory.java Wed Sep 26 15:15:42 2007
@@ -24,6 +24,7 @@
 import org.apache.geronimo.gshell.whisper.transport.Transport;
 import org.apache.geronimo.gshell.whisper.transport.TransportFactory;
 import org.apache.geronimo.gshell.whisper.transport.TransportServer;
+import org.apache.mina.common.IoHandler;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.component.annotations.Requirement;
 
@@ -32,46 +33,103 @@
  *
  * @version $Rev$ $Date$
  */
-public abstract class BaseTransportFactory
+public abstract class BaseTransportFactory<T extends BaseTransport, TC extends Transport.Configuration, S extends BaseTransportServer, SC extends TransportServer.Configuration>
     implements TransportFactory
 {
     @Requirement
     protected PlexusContainer container;
 
+    private final String scheme;
+
+    protected BaseTransportFactory(final String scheme) {
+        assert scheme != null;
+        
+        this.scheme = scheme;
+    }
+
+    public String getScheme() {
+        return scheme;
+    }
+
     //
-    // NOTE: We use autowire() here to get a few components injected.  These are injected via setters.
+    // Transport (Client) Connection
     //
 
-    public Transport connect(final URI remote, final URI local) throws Exception {
+    public T connect(final URI remote, final URI local, final TC config) throws Exception {
         assert remote != null;
+        assert config != null;
         // local can be null
 
-        Transport transport = createTransport(remote, local);
+        // noinspection unchecked
+        T transport = (T) container.lookup(Transport.class, scheme);
 
-        container.autowire(transport);
+        transport.setConfiguration(config);
 
-        transport.connect();
+        transport.connect(remote, local);
 
         return transport;
     }
 
-    protected abstract Transport createTransport(final URI remote, final URI local) throws Exception;
+    public T connect(final URI remote, final URI local, final IoHandler handler) throws Exception {
+        assert remote != null;
+        assert handler != null;
+        // local can be null
+
+        // noinspection unchecked
+        T transport = (T) container.lookup(Transport.class, scheme);
+
+        transport.getConfiguration().setHandler(handler);
+
+        transport.connect(remote, local);
+
+        return transport;
+    }
+
+    /*
+    public Transport connect(final URI remote, final URI local) throws Exception {
+        return connect(remote, local, (Transport.Configuration) null);
+    }
 
     public Transport connect(final URI remote) throws Exception {
         return connect(remote, null);
     }
+    */
 
-    public TransportServer bind(final URI location) throws Exception {
+    //
+    // TransportServer Binding
+    //
+
+    public S bind(final URI location, final SC config) throws Exception {
         assert location != null;
+        assert config != null;
 
-        TransportServer server = createTransportServer(location);
+        // noinspection unchecked
+        S server = (S) container.lookup(TransportServer.class, scheme);
 
-        container.autowire(server);
+        server.setConfiguration(config);
 
-        server.bind();
+        server.bind(location);
 
         return server;
     }
 
-    protected abstract TransportServer createTransportServer(final URI location) throws Exception;
+    public S bind(final URI location, final IoHandler handler) throws Exception {
+        assert location != null;
+        assert handler != null;
+
+        // noinspection unchecked
+        S server = (S) container.lookup(TransportServer.class, scheme);
+
+        server.getConfiguration().setHandler(handler);
+
+        server.bind(location);
+
+        return server;
+    }
+
+    /*
+    public TransportServer bind(final URI location) throws Exception {
+        return bind(location, (TransportServer.Configuration) null);
+    }
+    */
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransportServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransportServer.java?rev=579828&r1=579827&r2=579828&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransportServer.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransportServer.java Wed Sep 26 15:15:42 2007
@@ -23,87 +23,123 @@
 import java.net.URI;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.geronimo.gshell.whisper.message.MessageHandler;
-import org.apache.geronimo.gshell.whisper.session.ThreadPoolModel;
 import org.apache.geronimo.gshell.whisper.transport.TransportServer;
 import org.apache.mina.common.IoAcceptor;
+import org.apache.mina.common.IoHandler;
 
 /**
  * Support for {@link TransportServer} implementations.
  *
  * @version $Rev$ $Date$
  */
-public abstract class BaseTransportServer
-    extends BaseCommon
+public abstract class BaseTransportServer<T extends IoAcceptor>
+    extends BaseService
     implements TransportServer
 {
-    private static final AtomicLong COUNTER = new AtomicLong(0);
+    private static final AtomicLong INSTANCE_COUNTER = new AtomicLong(0);
 
-    protected final URI location;
+    protected URI location;
 
-    protected final SocketAddress address;
+    protected SocketAddress address;
 
-    protected IoAcceptor acceptor;
+    protected T acceptor;
 
-    protected ThreadPoolModel threadModel;
+    protected BaseTransportServer(final AddressFactory addressFactory) {
+        super(addressFactory);
+    }
 
-    protected boolean bound;
+    //
+    // Configuration
+    //
+
+    protected static class BaseTransportServerConfiguration
+        extends BaseConfiguration
+        implements TransportServer.Configuration
+    {
+        // TODO:
+    }
 
-    protected BaseTransportServer(final URI location, final SocketAddress address) {
-        assert location != null;
-        assert address != null;
+    private Configuration config;
 
-        this.location = location;
-        this.address = address;
+    protected abstract Configuration createConfiguration();
+
+    public synchronized Configuration getConfiguration() {
+        if (config == null) {
+            config = createConfiguration();
+        }
+
+        return config;
     }
 
-    public URI getLocation() {
-        return location;
+    public synchronized void setConfiguration(final Configuration config) {
+        assert config != null;
+        
+        this.config = config;
+
+        log.debug("Using configuration: {}", config);
     }
 
-    protected abstract IoAcceptor createAcceptor() throws Exception;
+    @Override
+    protected synchronized BaseConfiguration getBaseConfiguration() {
+        return (BaseConfiguration) getConfiguration();
+    }
 
-    protected synchronized void init() throws Exception {
-        // For now we must manually bind the message handler, plexus is unable to provide injection for us
-        setMessageHandler((MessageHandler) getContainer().lookup(MessageHandler.class, "server"));
+    protected abstract T createAcceptor() throws Exception;
 
-        // Setup the acceptor service
-        acceptor = createAcceptor();
+    synchronized void bind(final URI location) throws Exception {
+        assert location != null;
 
-        // Install the thread model
-        threadModel = new ThreadPoolModel(getClass().getSimpleName() + "-" + COUNTER.getAndIncrement());
-        acceptor.getDefaultConfig().setThreadModel(threadModel);
+        this.location = location;
+        this.address = addressFactory.create(location);
 
-        // Configure the acceptor
-        configure(acceptor);
+        bind();
     }
 
-    public synchronized void bind() throws Exception {
-        if (bound) {
-            throw new IllegalStateException("Already bound");
-        }
-
-        init();
+    synchronized void bind() throws Exception {
+        acceptor = createAcceptor();
+        log.debug("Acceptor: {}", acceptor);
 
-        acceptor.bind(address, getHandler());
+        configure(acceptor);
 
-        bound = true;
+        IoHandler handler = getHandler();
+        log.debug("Handler: {}", handler);
 
+        log.info("Binding to: {}", address);
+        acceptor.bind(address, handler);
+        
         log.info("Listening on: {}", address);
     }
 
-    public boolean isBound() {
-        return bound;
+    public URI getLocation() {
+        return location;
+    }
+
+    public T getAcceptor() {
+        return acceptor;
     }
 
     public synchronized void close() {
         try {
             acceptor.unbind(address);
-
-            threadModel.close();
         }
         finally {
             super.close();
         }
+    }
+
+    //
+    // Listeners
+    //
+
+    public void addListener(final Listener listener) {
+        assert listener != null;
+
+        throw new UnsupportedOperationException();
+    }
+
+    public void removeListener(final Listener listener) {
+        assert listener != null;
+
+        throw new UnsupportedOperationException();
     }
 }

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslAddressFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslAddressFactory.java?rev=579828&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslAddressFactory.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslAddressFactory.java Wed Sep 26 15:15:42 2007
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.whisper.transport.ssl;
+
+import org.apache.geronimo.gshell.whisper.transport.base.AddressFactory;
+import org.apache.geronimo.gshell.whisper.transport.tcp.TcpAddressFactory;
+import org.codehaus.plexus.component.annotations.Component;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=AddressFactory.class, hint="ssl")
+public class SslAddressFactory
+    extends TcpAddressFactory
+{
+    // Empty
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslAddressFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslAddressFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslAddressFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransport.java?rev=579828&r1=579827&r2=579828&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransport.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransport.java Wed Sep 26 15:15:42 2007
@@ -19,23 +19,29 @@
 
 package org.apache.geronimo.gshell.whisper.transport.ssl;
 
-import java.net.URI;
-
 import org.apache.geronimo.gshell.whisper.ssl.SSLContextFactory;
+import org.apache.geronimo.gshell.whisper.transport.Transport;
 import org.apache.geronimo.gshell.whisper.transport.tcp.TcpTransport;
 import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.filter.SSLFilter;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.InstantiationStrategy;
+import org.codehaus.plexus.component.annotations.Requirement;
 
 /**
  * Provides TCP+SSL client-side support.
  *
  * @version $Rev$ $Date$
  */
+@Component(role=Transport.class, hint="ssl", instantiationStrategy=InstantiationStrategy.PER_LOOKUP)
 public class SslTransport
     extends TcpTransport
 {
-    public SslTransport(final URI remote, final URI local) throws Exception {
-        super(remote, local);
+    @Requirement
+    private SSLContextFactory contextFactory;
+
+    public SslTransport() {
+        super(new SslAddressFactory());
     }
 
     @Override
@@ -44,29 +50,19 @@
 
         super.configure(chain);
 
-        SSLFilter sslFilter = new SSLFilter(getSslContextFactory().createClientContext());
-        sslFilter.setUseClientMode(true);
+        SSLFilter filter = new SSLFilter(contextFactory.createClientContext());
+        filter.setUseClientMode(true);
 
-        chain.addFirst(SSLFilter.class.getSimpleName(), sslFilter);
+        chain.addFirst(SSLFilter.class.getSimpleName(), filter);
     }
 
-    //
-    // AutoWire Support, Setters exposed to support Plexus autowire()  Getters exposed to handle state checking.
-    //
-
-    private SSLContextFactory sslContextFactory;
-    
-    public void setSslContextFactory(final SSLContextFactory factory) {
-        log.debug("Using SSL Context Factory: {}", factory);
-
-        this.sslContextFactory = factory;
+    protected Transport.Configuration createConfiguration() {
+        return new Configuration();
     }
 
-    protected SSLContextFactory getSslContextFactory() {
-        if (sslContextFactory == null) {
-            throw new IllegalStateException("SSL context factory not bound");
-        }
-
-        return sslContextFactory;
+    public static class Configuration
+        extends BaseTransportConfiguration
+    {
+        // TODO:
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransportFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransportFactory.java?rev=579828&r1=579827&r2=579828&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransportFactory.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransportFactory.java Wed Sep 26 15:15:42 2007
@@ -19,11 +19,7 @@
 
 package org.apache.geronimo.gshell.whisper.transport.ssl;
 
-import java.net.URI;
-
-import org.apache.geronimo.gshell.whisper.transport.Transport;
 import org.apache.geronimo.gshell.whisper.transport.TransportFactory;
-import org.apache.geronimo.gshell.whisper.transport.TransportServer;
 import org.apache.geronimo.gshell.whisper.transport.tcp.TcpTransportFactory;
 import org.codehaus.plexus.component.annotations.Component;
 
@@ -34,15 +30,11 @@
  */
 @Component(role=TransportFactory.class, hint="ssl")
 public class SslTransportFactory
-    extends TcpTransportFactory
+    extends TcpTransportFactory<SslTransport, SslTransportServer>
 {
-    @Override
-    protected Transport createTransport(final URI remote, final URI local) throws Exception {
-        return new SslTransport(remote, local);
-    }
+    public static final String SCHEME = "ssl";
 
-    @Override
-    protected TransportServer createTransportServer(final URI location) throws Exception {
-        return new SslTransportServer(location);
+    public SslTransportFactory() {
+        super(SCHEME);
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransportServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransportServer.java?rev=579828&r1=579827&r2=579828&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransportServer.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransportServer.java Wed Sep 26 15:15:42 2007
@@ -19,23 +19,29 @@
 
 package org.apache.geronimo.gshell.whisper.transport.ssl;
 
-import java.net.URI;
-
 import org.apache.geronimo.gshell.whisper.ssl.SSLContextFactory;
+import org.apache.geronimo.gshell.whisper.transport.TransportServer;
 import org.apache.geronimo.gshell.whisper.transport.tcp.TcpTransportServer;
 import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.filter.SSLFilter;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.InstantiationStrategy;
+import org.codehaus.plexus.component.annotations.Requirement;
 
 /**
  * Provides TCP+SSL server-side support.
  *
  * @version $Rev$ $Date$
  */
+@Component(role=TransportServer.class, hint="ssl", instantiationStrategy=InstantiationStrategy.PER_LOOKUP)
 public class SslTransportServer
     extends TcpTransportServer
 {
-    public SslTransportServer(final URI location) throws Exception {
-        super(location);
+    @Requirement
+    private SSLContextFactory contextFactory;
+
+    public SslTransportServer() {
+        super(new SslAddressFactory());
     }
 
     @Override
@@ -44,28 +50,18 @@
 
         super.configure(chain);
 
-        SSLFilter sslFilter = new SSLFilter(getSslContextFactory().createServerContext());
+        SSLFilter sslFilter = new SSLFilter(contextFactory.createServerContext());
 
         chain.addFirst(SSLFilter.class.getSimpleName(), sslFilter);
     }
 
-    //
-    // AutoWire Support, Setters exposed to support Plexus autowire()  Getters exposed to handle state checking.
-    //
-
-    private SSLContextFactory sslContextFactory;
-
-    public void setSslContextFactory(final SSLContextFactory factory) {
-        log.debug("Using SSL Context Factory: {}", factory);
-
-        this.sslContextFactory = factory;
+    protected TransportServer.Configuration createConfiguration() {
+        return new Configuration();
     }
 
-    protected SSLContextFactory getSslContextFactory() {
-        if (sslContextFactory == null) {
-            throw new IllegalStateException("SSL context factory not bound");
-        }
-
-        return sslContextFactory;
+    public static class Configuration
+        extends BaseTransportServerConfiguration
+    {
+        // TODO:
     }
 }

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpAddressFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpAddressFactory.java?rev=579828&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpAddressFactory.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpAddressFactory.java Wed Sep 26 15:15:42 2007
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.whisper.transport.tcp;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.URI;
+
+import org.apache.geronimo.gshell.whisper.transport.base.AddressFactory;
+import org.codehaus.plexus.component.annotations.Component;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=AddressFactory.class, hint="tcp")
+public class TcpAddressFactory
+    implements AddressFactory<InetSocketAddress>
+{
+    public InetSocketAddress create(URI location) throws Exception {
+        InetSocketAddress addr = null;
+
+        if (location != null) {
+            addr = new InetSocketAddress(InetAddress.getByName(location.getHost()), location.getPort());
+        }
+
+        return addr;
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpAddressFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpAddressFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpAddressFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransport.java?rev=579828&r1=579827&r2=579828&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransport.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransport.java Wed Sep 26 15:15:42 2007
@@ -19,34 +19,44 @@
 
 package org.apache.geronimo.gshell.whisper.transport.tcp;
 
-import java.net.URI;
 import java.util.concurrent.Executors;
 
+import org.apache.geronimo.gshell.whisper.transport.Transport;
+import org.apache.geronimo.gshell.whisper.transport.base.AddressFactory;
 import org.apache.geronimo.gshell.whisper.transport.base.BaseTransport;
-import org.apache.mina.common.IoConnector;
 import org.apache.mina.transport.socket.nio.SocketConnector;
-import org.apache.mina.transport.socket.nio.SocketConnectorConfig;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.InstantiationStrategy;
 
 /**
  * Provides TCP client-side support.
  *
  * @version $Rev$ $Date$
  */
+@Component(role=Transport.class, hint="tcp", instantiationStrategy=InstantiationStrategy.PER_LOOKUP)
 public class TcpTransport
-    extends BaseTransport
+    extends BaseTransport<SocketConnector>
 {
-    public TcpTransport(final URI remote, final URI local) throws Exception {
-        super(remote, TcpTransportFactory.address(remote), local, TcpTransportFactory.address(local));
+    public TcpTransport() {
+        super(new TcpAddressFactory());
     }
 
-    @Override
-    protected IoConnector createConnector() throws Exception {
-        SocketConnector connector = new SocketConnector(Runtime.getRuntime().availableProcessors() + 1, Executors.newCachedThreadPool());
+    protected TcpTransport(final AddressFactory addressFactory) {
+        super(addressFactory);
+    }
 
-        SocketConnectorConfig config = connector.getDefaultConfig();
+    @Override
+    protected SocketConnector createConnector() throws Exception {
+        return new SocketConnector(Runtime.getRuntime().availableProcessors() + 1, Executors.newCachedThreadPool());
+    }
 
-        config.getSessionConfig().setKeepAlive(true);
+    protected Transport.Configuration createConfiguration() {
+        return new Configuration();
+    }
 
-        return connector;
+    public static class Configuration
+        extends BaseTransportConfiguration
+    {
+        // TODO:
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransportFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransportFactory.java?rev=579828&r1=579827&r2=579828&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransportFactory.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransportFactory.java Wed Sep 26 15:15:42 2007
@@ -19,14 +19,7 @@
 
 package org.apache.geronimo.gshell.whisper.transport.tcp;
 
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.URI;
-import java.net.UnknownHostException;
-
-import org.apache.geronimo.gshell.whisper.transport.Transport;
 import org.apache.geronimo.gshell.whisper.transport.TransportFactory;
-import org.apache.geronimo.gshell.whisper.transport.TransportServer;
 import org.apache.geronimo.gshell.whisper.transport.base.BaseTransportFactory;
 import org.codehaus.plexus.component.annotations.Component;
 
@@ -36,26 +29,16 @@
  * @version $Rev$ $Date$
  */
 @Component(role=TransportFactory.class, hint="tcp")
-public class TcpTransportFactory
+public class TcpTransportFactory<T extends TcpTransport, S extends TcpTransportServer>
     extends BaseTransportFactory
 {
-    @Override
-    protected Transport createTransport(final URI remote, final URI local) throws Exception {
-        return new TcpTransport(remote, local);
-    }
+    public static final String SCHEME = "tcp";
 
-    @Override
-    protected TransportServer createTransportServer(final URI location) throws Exception {
-        return new TcpTransportServer(location);
+    public TcpTransportFactory() {
+        super(SCHEME);
     }
 
-    static InetSocketAddress address(final URI location) throws UnknownHostException {
-        InetSocketAddress addr = null;
-
-        if (location != null) {
-            addr = new InetSocketAddress(InetAddress.getByName(location.getHost()), location.getPort());
-        }
-
-        return addr;
+    protected TcpTransportFactory(final String scheme) {
+        super(scheme);
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransportServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransportServer.java?rev=579828&r1=579827&r2=579828&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransportServer.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransportServer.java Wed Sep 26 15:15:42 2007
@@ -19,34 +19,44 @@
 
 package org.apache.geronimo.gshell.whisper.transport.tcp;
 
-import java.net.URI;
 import java.util.concurrent.Executors;
 
+import org.apache.geronimo.gshell.whisper.transport.TransportServer;
+import org.apache.geronimo.gshell.whisper.transport.base.AddressFactory;
 import org.apache.geronimo.gshell.whisper.transport.base.BaseTransportServer;
-import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.InstantiationStrategy;
 
 /**
  * Provides TCP server-side support.
  *
  * @version $Rev$ $Date$
  */
+@Component(role=TransportServer.class, hint="tcp", instantiationStrategy=InstantiationStrategy.PER_LOOKUP)
 public class TcpTransportServer
     extends BaseTransportServer
 {
-    public TcpTransportServer(final URI location) throws Exception {
-        super(location, TcpTransportFactory.address(location));
+    public TcpTransportServer() {
+        super(new TcpAddressFactory());
     }
 
-    @Override
-    protected IoAcceptor createAcceptor() throws Exception {
-        SocketAcceptor acceptor = new SocketAcceptor(Runtime.getRuntime().availableProcessors() + 1, Executors.newCachedThreadPool());
+    protected TcpTransportServer(final AddressFactory addressFactory) {
+        super(addressFactory);
+    }
 
-        SocketAcceptorConfig config = acceptor.getDefaultConfig();
+    @Override
+    protected SocketAcceptor createAcceptor() throws Exception {
+        return new SocketAcceptor(Runtime.getRuntime().availableProcessors() + 1, Executors.newCachedThreadPool());
+    }
 
-        config.getSessionConfig().setKeepAlive(true);
+    protected TransportServer.Configuration createConfiguration() {
+        return new Configuration();
+    }
 
-        return acceptor;
+    public static class Configuration
+        extends BaseTransportServerConfiguration
+    {
+        // TODO:
     }
 }

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmAddressFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmAddressFactory.java?rev=579828&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmAddressFactory.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmAddressFactory.java Wed Sep 26 15:15:42 2007
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.whisper.transport.vm;
+
+import java.net.URI;
+
+import org.apache.geronimo.gshell.whisper.transport.base.AddressFactory;
+import org.apache.mina.transport.vmpipe.VmPipeAddress;
+import org.codehaus.plexus.component.annotations.Component;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=AddressFactory.class, hint="vm")
+public class VmAddressFactory
+    implements AddressFactory<VmPipeAddress>
+{
+    public VmPipeAddress create(URI location) throws Exception {
+        VmPipeAddress addr = null;
+
+        if (location != null) {
+            addr = new VmPipeAddress(location.getPort());
+        }
+
+        return addr;
+    }
+}

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmAddressFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmAddressFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmAddressFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransport.java?rev=579828&r1=579827&r2=579828&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransport.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransport.java Wed Sep 26 15:15:42 2007
@@ -19,26 +19,37 @@
 
 package org.apache.geronimo.gshell.whisper.transport.vm;
 
-import java.net.URI;
-
+import org.apache.geronimo.gshell.whisper.transport.Transport;
 import org.apache.geronimo.gshell.whisper.transport.base.BaseTransport;
-import org.apache.mina.common.IoConnector;
 import org.apache.mina.transport.vmpipe.VmPipeConnector;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.InstantiationStrategy;
 
 /**
  * Provides in-VM client-side support.
  *
  * @version $Rev$ $Date$
  */
+@Component(role=Transport.class, hint="vm", instantiationStrategy=InstantiationStrategy.PER_LOOKUP)
 public class VmTransport
-    extends BaseTransport
+    extends BaseTransport<VmPipeConnector>
 {
-    public VmTransport(final URI remote, final URI local) throws Exception {
-        super(remote, VmTransportFactory.address(remote), local, VmTransportFactory.address(local));
+    public VmTransport() {
+        super(new VmAddressFactory());
     }
 
     @Override
-    protected IoConnector createConnector() throws Exception {
+    protected VmPipeConnector createConnector() throws Exception {
         return new VmPipeConnector();
+    }
+
+    protected Transport.Configuration createConfiguration() {
+        return new Configuration();
+    }
+
+    public static class Configuration
+        extends BaseTransportConfiguration
+    {
+        // TODO:
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactory.java?rev=579828&r1=579827&r2=579828&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactory.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactory.java Wed Sep 26 15:15:42 2007
@@ -19,13 +19,8 @@
 
 package org.apache.geronimo.gshell.whisper.transport.vm;
 
-import java.net.URI;
-
-import org.apache.geronimo.gshell.whisper.transport.Transport;
 import org.apache.geronimo.gshell.whisper.transport.TransportFactory;
-import org.apache.geronimo.gshell.whisper.transport.TransportServer;
 import org.apache.geronimo.gshell.whisper.transport.base.BaseTransportFactory;
-import org.apache.mina.transport.vmpipe.VmPipeAddress;
 import org.codehaus.plexus.component.annotations.Component;
 
 /**
@@ -37,23 +32,9 @@
 public class VmTransportFactory
     extends BaseTransportFactory
 {
-    @Override
-    protected Transport createTransport(final URI remote, final URI local) throws Exception {
-        return new VmTransport(remote, local);
-    }
-
-    @Override
-    protected TransportServer createTransportServer(final URI location) throws Exception {
-        return new VmTransportServer(location);
-    }
-
-    static VmPipeAddress address(final URI location) {
-        VmPipeAddress addr = null;
-
-        if (location != null) {
-            addr = new VmPipeAddress(location.getPort());
-        }
+    public static final String SCHEME = "vm";
 
-        return addr;
+    public VmTransportFactory() {
+        super(SCHEME);
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportServer.java?rev=579828&r1=579827&r2=579828&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportServer.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportServer.java Wed Sep 26 15:15:42 2007
@@ -19,26 +19,37 @@
 
 package org.apache.geronimo.gshell.whisper.transport.vm;
 
-import java.net.URI;
-
+import org.apache.geronimo.gshell.whisper.transport.TransportServer;
 import org.apache.geronimo.gshell.whisper.transport.base.BaseTransportServer;
-import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.transport.vmpipe.VmPipeAcceptor;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.InstantiationStrategy;
 
 /**
  * Provides in-VM server-side support.
  *
  * @version $Rev$ $Date$
  */
+@Component(role=TransportServer.class, hint="vm", instantiationStrategy=InstantiationStrategy.PER_LOOKUP)
 public class VmTransportServer
     extends BaseTransportServer
 {
-    public VmTransportServer(final URI location) throws Exception {
-        super(location, VmTransportFactory.address(location));
+    public VmTransportServer() {
+        super(new VmAddressFactory());
     }
 
     @Override
-    protected IoAcceptor createAcceptor() throws Exception {
+    protected VmPipeAcceptor createAcceptor() throws Exception {
         return new VmPipeAcceptor();
+    }
+
+    protected TransportServer.Configuration createConfiguration() {
+        return new Configuration();
+    }
+
+    public static class Configuration
+        extends BaseTransportServerConfiguration
+    {
+        // TODO:
     }
 }

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/message/PingPongProtocolTester.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/message/PingPongProtocolTester.java?rev=579828&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/message/PingPongProtocolTester.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/message/PingPongProtocolTester.java Wed Sep 26 15:15:42 2007
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.whisper.message;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.apache.geronimo.gshell.whisper.transport.Transport;
+import org.apache.geronimo.gshell.whisper.transport.TransportFactory;
+import org.apache.geronimo.gshell.whisper.transport.TransportFactoryLocator;
+import org.apache.geronimo.gshell.whisper.transport.TransportServer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.demux.DemuxingIoHandler;
+import org.apache.mina.handler.demux.MessageHandler;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class PingPongProtocolTester
+    extends PlexusTestCase
+{
+    private static void log(Object msg) {
+        System.err.println(">>> [" + Thread.currentThread().getName() + "] " + msg);
+    }
+
+    public static enum PingPongMessageType
+        implements Message.Type
+    {
+        PING(PingMessage.class),
+        PONG(PongMessage.class);
+
+        Class<? extends Message> type;
+
+        PingPongMessageType(Class<? extends Message> type) {
+            this.type = type;
+        }
+
+        public Class<? extends Message> getType() {
+            return type;
+        }
+    }
+
+    public static class PingMessage
+        extends BaseMessage
+    {
+        public PingMessage() {
+            super(PingPongMessageType.PING);
+        }
+    }
+
+    public static class PongMessage
+        extends BaseMessage
+    {
+        public PongMessage() {
+            super(PingPongMessageType.PONG);
+        }
+    }
+
+
+    public static class PingHandler
+        implements MessageHandler<PingMessage>
+    {
+        public void messageReceived(IoSession session, PingMessage message) throws Exception {
+            log(message);
+
+            Thread.sleep(5 * 1000);
+
+            session.write(new PingMessage()).join();
+        }
+    }
+
+    public static class PongHandler
+        implements MessageHandler<PongMessage>
+    {
+        public void messageReceived(IoSession session, PongMessage message) throws Exception {
+            log(message);
+
+            session.write(new PingMessage()).join();
+        }
+    }
+
+    public static class PingPongProtocolHandler
+        extends DemuxingIoHandler
+    {
+        public void sessionCreated(final IoSession session) throws Exception {
+            log("Registering handlers");
+
+            addMessageHandler(PingMessage.class, new PingHandler());
+
+            addMessageHandler(PongMessage.class, new PongHandler());
+
+            synchronized (System.err) {
+                log("Handlers:");
+
+                for (Map.Entry entry : getMessageHandlerMap().entrySet()) {
+                    log("     " + entry.getKey() + "     " + entry.getValue());
+                }
+            }
+        }
+
+        /*
+        public void sessionOpened(IoSession session) throws Exception {
+            if (!TRANSPORT.isBound(session)) {
+                Transport transport = new TransportAdapter(session);
+
+                TRANSPORT.bind(session, transport);
+
+                synchronized (System.err) {
+                    log("BOUND Transport adapter: " + transport + ", for session: " + session);
+                    new Throwable().printStackTrace();
+                }
+            }
+        }
+        */
+
+        public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
+            synchronized (System.err) {
+                log("ERROR: session=" + session + ", cause=" + cause);
+
+                if (cause != null) {
+                    cause.printStackTrace();
+                }
+
+                session.close();
+            }
+        }
+    }
+
+    public static class PingPongClientHandler
+        extends PingPongProtocolHandler
+    {
+
+    }
+
+    public static class PingPongServerHandler
+        extends PingPongProtocolHandler
+    {
+
+    }
+
+    public void testPingPong() throws Exception {
+        URI uri = new URI("vm://local:1");
+
+        TransportFactoryLocator locator = (TransportFactoryLocator) lookup(TransportFactoryLocator.class);
+
+        log("Locator: " + locator);
+
+        TransportFactory factory = locator.locate(uri);
+
+        log("Factory: " + factory);
+
+        TransportServer server = factory.bind(uri, new PingPongServerHandler());
+
+        log("Server: " + server);
+
+        Transport client = factory.connect(uri, null, new PingPongClientHandler());
+
+        log("Client: " + client);
+
+        Thread.sleep(5 * 1000);
+
+        client.send(new PingMessage()).join();
+        
+        Thread.sleep(30 * 1000);
+
+        client.close();
+
+        server.close();
+    }
+}

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/message/PingPongProtocolTester.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/message/PingPongProtocolTester.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/message/PingPongProtocolTester.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocatorTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocatorTest.java?rev=579828&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocatorTest.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocatorTest.java Wed Sep 26 15:15:42 2007
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.whisper.transport;
+
+import java.net.URI;
+
+import org.apache.geronimo.gshell.whisper.transport.ssl.SslTransportFactory;
+import org.apache.geronimo.gshell.whisper.transport.tcp.TcpTransportFactory;
+import org.apache.geronimo.gshell.whisper.transport.vm.VmTransportFactory;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+/**
+ * Tests for the {@link TransportFactoryLocator} class.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TransportFactoryLocatorTest
+    extends PlexusTestCase
+{
+    TransportFactoryLocator locator;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        locator = (TransportFactoryLocator) lookup(TransportFactoryLocator.class);
+        assertNotNull(locator);
+    }
+
+    public void testLocate_vm() throws Exception {
+        URI uri = new URI("vm://local:1");
+
+        TransportFactory factory = locator.locate(uri);
+
+        assertTrue(factory instanceof VmTransportFactory);
+
+        assertNotNull(factory);
+    }
+
+    public void testLocate_tcp() throws Exception {
+        URI uri = new URI("tcp://localhost:9999");
+
+        TransportFactory factory = locator.locate(uri);
+
+        assertTrue(factory instanceof TcpTransportFactory);
+
+        assertNotNull(factory);
+    }
+
+    public void testLocate_ssl() throws Exception {
+        URI uri = new URI("ssl://localhost:9999");
+
+        TransportFactory factory = locator.locate(uri);
+
+        assertTrue(factory instanceof SslTransportFactory);
+
+        assertNotNull(factory);
+    }
+
+    public void testLocate_unknown() throws Exception {
+        URI uri = new URI("unknown://localhost:9999");
+
+        try {
+            locator.locate(uri);
+            fail();
+        }
+        catch (ComponentLookupException expected) {}
+    }
+
+    public void testLocate_badLocation() throws Exception {
+        URI uri = new URI("localhost");
+
+        try {
+            locator.locate(uri);
+            fail();
+        }
+        catch (InvalidLocationException expected) {}
+    }
+}

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocatorTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocatorTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactoryTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactoryTest.java?rev=579828&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactoryTest.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactoryTest.java Wed Sep 26 15:15:42 2007
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.whisper.transport.vm;
+
+import java.net.URI;
+
+import org.apache.geronimo.gshell.whisper.transport.TransportFactory;
+import org.apache.geronimo.gshell.whisper.transport.TransportFactoryLocator;
+import org.apache.geronimo.gshell.whisper.transport.TransportServer;
+import org.apache.mina.common.IoHandlerAdapter;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ * Tests for the {@link VmTransportFactory} class.
+ *
+ * @version $Rev$ $Date$
+ */
+public class VmTransportFactoryTest
+    extends PlexusTestCase
+{
+    TransportFactory factory;
+
+    URI uri;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        TransportFactoryLocator locator = (TransportFactoryLocator) lookup(TransportFactoryLocator.class);
+
+        assertNotNull(locator);
+
+        uri = new URI("vm://local:1");
+
+        factory = locator.locate(uri);
+
+        assertNotNull(factory);
+    }
+
+    public void testBindWithConfig() throws Exception {
+        VmTransportServer.Configuration config = new VmTransportServer.Configuration();
+        config.setHandler(new IoHandlerAdapter());
+
+        TransportServer server = factory.bind(uri, config);
+        
+        assertNotNull(server);
+        
+        assertTrue(server instanceof VmTransportServer);
+
+        server.close();
+    }
+
+    public void testBindWithHandler() throws Exception {
+        TransportServer server = factory.bind(uri, new IoHandlerAdapter());
+
+        assertNotNull(server);
+
+        assertTrue(server instanceof VmTransportServer);
+
+        server.close();
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactoryTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactoryTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportTest.java?rev=579828&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportTest.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportTest.java Wed Sep 26 15:15:42 2007
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.whisper.transport.vm;
+
+import java.net.URI;
+
+import org.apache.geronimo.gshell.whisper.transport.InvalidLocationException;
+import org.apache.geronimo.gshell.whisper.transport.TransportFactory;
+import org.apache.geronimo.gshell.whisper.transport.TransportFactoryLocator;
+import org.apache.geronimo.gshell.whisper.transport.ssl.SslTransportFactory;
+import org.apache.geronimo.gshell.whisper.transport.tcp.TcpTransportFactory;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+/**
+ * Tests for the {@link VmTransport} class.
+ *
+ * @version $Rev$ $Date$
+ */
+public class VmTransportTest
+    extends PlexusTestCase
+{
+    TransportFactoryLocator locator;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        locator = (TransportFactoryLocator) lookup(TransportFactoryLocator.class);
+
+        assertNotNull(locator);
+    }
+
+    public void testLocate_vm() throws Exception {
+        URI uri = new URI("vm://local:1");
+
+        TransportFactory factory = locator.locate(uri);
+
+        assertTrue(factory instanceof VmTransportFactory);
+
+        assertNotNull(factory);
+    }
+
+    public void testLocate_tcp() throws Exception {
+        URI uri = new URI("tcp://localhost:9999");
+
+        TransportFactory factory = locator.locate(uri);
+
+        assertTrue(factory instanceof TcpTransportFactory);
+
+        assertNotNull(factory);
+    }
+
+    public void testLocate_ssl() throws Exception {
+        URI uri = new URI("ssl://localhost:9999");
+
+        TransportFactory factory = locator.locate(uri);
+
+        assertTrue(factory instanceof SslTransportFactory);
+
+        assertNotNull(factory);
+    }
+
+    public void testLocate_unknown() throws Exception {
+        URI uri = new URI("unknown://localhost:9999");
+
+        try {
+            locator.locate(uri);
+            fail();
+        }
+        catch (ComponentLookupException expected) {}
+    }
+
+    public void testLocate_badLocation() throws Exception {
+        URI uri = new URI("localhost");
+
+        try {
+            locator.locate(uri);
+            fail();
+        }
+        catch (InvalidLocationException expected) {}
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain