geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r578566 [3/4] - in /geronimo/sandbox/gshell/trunk/gshell-whisper: ./ src/ src/main/java/org/apache/geronimo/gshell/remote/ src/main/java/org/apache/geronimo/gshell/whisper/ src/main/java/org/apache/geronimo/gshell/whisper/crypto/ src/main/j...
Date Sun, 23 Sep 2007 12:02:52 GMT
Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/Response.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/Response.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/Response.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/Response.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,104 @@
+/*
+ * 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.request;
+
+import org.apache.geronimo.gshell.common.tostring.ToStringBuilder;
+import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
+import org.apache.geronimo.gshell.whisper.message.Message;
+import org.apache.geronimo.gshell.whisper.message.MessageID;
+
+//
+// NOTE: Snatched and massaged from Apache Mina
+//
+
+/**
+ * Represents a response to a request message.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Response
+{
+    private final Request request;
+
+    private final Type type;
+
+    private final Message message;
+
+    public Response(final Request request, final Message message, final Type type) {
+        this.request = request;
+        this.type = type;
+        this.message = message;
+    }
+
+    public int hashCode() {
+        return getRequest().getId().hashCode();
+    }
+
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        }
+        else if (obj == null) {
+            return false;
+        }
+        else if (!(obj instanceof Response)) {
+            return false;
+        }
+
+        Response resp = (Response) obj;
+
+        return getRequest().equals(resp.getRequest()) && getType().equals(resp.getType());
+    }
+
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
+                .append("id", getId())
+                .append("responseTo", getRequest().getId())
+                .append("message", message)
+                .toString();
+    }
+
+    public Request getRequest() {
+        return request;
+    }
+
+    public Type getType() {
+        return type;
+    }
+
+    public Message getMessage() {
+        return message;
+    }
+
+    public MessageID getId() {
+        return getMessage().getId();
+    }
+
+    //
+    // Response Type
+    //
+
+    public static enum Type
+    {
+        WHOLE,
+        PARTIAL,
+        PARTIAL_LAST
+    }
+}

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/package-info.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/package-info.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/package-info.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * Provides support for synchronous request/response messaging.
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.whisper.request;
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/SessionAttributeBinder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/SessionAttributeBinder.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/SessionAttributeBinder.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/SessionAttributeBinder.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,128 @@
+/*
+ * 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.session;
+
+import org.apache.mina.common.IoSession;
+
+/**
+ * Helper to manage binding operations for typed session attribute objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SessionAttributeBinder<T>
+{
+    private final String key;
+
+    public SessionAttributeBinder(final String key) {
+        assert key != null;
+        
+        this.key = key;
+    }
+
+    public SessionAttributeBinder(final Class type) {
+        this(type.getName());
+    }
+
+    public SessionAttributeBinder(final Class type, final String suffix) {
+        this(type.getName() + "." + suffix);
+    }
+
+    public boolean isBound(final IoSession session) {
+        assert session != null;
+        
+        return session.containsAttribute(key);
+    }
+
+    @SuppressWarnings({"unchecked"})
+    public T lookup(final IoSession session) {
+        assert session != null;
+
+        T obj = (T) session.getAttribute(key);
+
+        if (obj == null) {
+            throw new NotBoundException(key);
+        }
+
+        return obj;
+    }
+
+    @SuppressWarnings({"unchecked"})
+    public T lookup(final IoSession session, final T defaultValue) {
+        assert session != null;
+
+        T obj = (T) session.getAttribute(key);
+
+        if (obj == null) {
+            return defaultValue;
+        }
+
+        return obj;
+    }
+
+    public T bind(final IoSession session, final T obj) {
+        assert session != null;
+        assert obj != null;
+        
+        Object prev = session.getAttribute(key);
+
+        if (prev != null) {
+            throw new AlreadyBoundException(key);
+        }
+
+        session.setAttribute(key, obj);
+
+        return obj;
+    }
+    
+    @SuppressWarnings({"unchecked"})
+    public T rebind(final IoSession session, final T obj) {
+        assert session != null;
+        assert obj != null;
+
+        T prev = (T) session.getAttribute(key);
+
+        session.setAttribute(key, obj);
+
+        return prev;
+    }
+
+    @SuppressWarnings({"unchecked"})
+    public T unbind(final IoSession session) {
+        assert session != null;
+
+        return (T) session.removeAttribute(key);
+    }
+
+    public static class NotBoundException
+        extends RuntimeException
+    {
+        public NotBoundException(final String key) {
+            super(key);
+        }
+    }
+
+    public static class AlreadyBoundException
+        extends RuntimeException
+    {
+        public AlreadyBoundException(final String key) {
+            super(key);
+        }
+    }
+}
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/ThreadPoolModel.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/ThreadPoolModel.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/ThreadPoolModel.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/ThreadPoolModel.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,97 @@
+/*
+ * 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.session;
+
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.geronimo.gshell.common.NamedThreadFactory;
+import org.apache.mina.common.IoFilterChain;
+import org.apache.mina.common.ThreadModel;
+import org.apache.mina.filter.executor.ExecutorFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A custom {@link ThreadModel} to get some more control over the pool configuration as well as how threads are constructed.
+ *
+ * @version $Rev$ $Date$
+ */
+@SuppressWarnings({"FieldCanBeLocal"})
+public class ThreadPoolModel
+    implements ThreadModel
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private final ThreadPoolExecutor threadPool;
+
+    private final ExecutorFilter filter;
+
+    public ThreadPoolModel(final String name) {
+        assert name != null;
+
+        ThreadGroup group = new ThreadGroup(name);
+
+        ThreadFactory tf = new NamedThreadFactory(name, group);
+
+        //
+        // TODO: See which is better SynchronousQueue<Runnable> or LinkedBlockingQueue<Runnable>
+        //
+
+        threadPool = new ThreadPoolExecutor(
+                1,
+                Integer.MAX_VALUE,
+                60L,
+                TimeUnit.SECONDS,
+                new LinkedBlockingQueue<Runnable>(),
+                tf,
+                new ThreadPoolExecutor.AbortPolicy());
+
+        filter = new ExecutorFilter(threadPool);
+    }
+
+    public void close() {
+        //
+        // FIXME: This causes some problems when a rsh client closes, like:
+        //
+        //        java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThread)
+        //
+
+        /*
+        List<Runnable> pending = threadPool.shutdownNow();
+
+        if (!pending.isEmpty()) {
+            log.warn("There were {} pending tasks which have not been run", pending.size());
+        }
+        */
+    }
+    
+    //
+    // ThreadModel
+    //
+
+    public void buildFilterChain(final IoFilterChain chain) throws Exception {
+        assert chain != null;
+        
+        chain.addFirst(getClass().getSimpleName(), filter);
+    }
+}
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/package-info.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/package-info.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/package-info.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * Session support.
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.whisper.session;
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/BogusSSLContextFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/BogusSSLContextFactory.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/BogusSSLContextFactory.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/BogusSSLContextFactory.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,197 @@
+/*
+ * 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.
+ */
+
+//
+// NOTE: Snatched and massaged from Apache Mina'a Examples
+//
+
+package org.apache.geronimo.gshell.whisper.ssl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.GeneralSecurityException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.Security;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.ManagerFactoryParameters;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactorySpi;
+import javax.net.ssl.X509TrustManager;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import org.codehaus.plexus.util.IOUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Factory to create a bougus SSLContext.
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=SSLContextFactory.class) // HACK: hint="bogus")
+public class BogusSSLContextFactory
+    implements SSLContextFactory, Initializable
+{
+    private static final String PROTOCOL = "TLS";
+
+    private static final String DEFAULT_KEY_MANAGER_FACTORY_ALGORITHM = "SunX509";
+
+    private static final String KEY_MANAGER_FACTORY_ALGORITHM;
+
+    static {
+        String algorithm = Security.getProperty("ssl.KeyManagerFactory.algorithm");
+        
+        if (algorithm == null) {
+            algorithm = DEFAULT_KEY_MANAGER_FACTORY_ALGORITHM;
+        }
+
+        KEY_MANAGER_FACTORY_ALGORITHM = algorithm;
+    }
+
+    //
+    // NOTE: The keystore was generated using keytool:
+    //   keytool -genkey -alias bogus -keysize 512 -validity 3650
+    //           -keyalg RSA -dname "CN=bogus.com, OU=XXX CA,
+    //               O=Bogus Inc, L=Stockholm, S=Stockholm, C=SE"
+    //           -keypass boguspw -storepass boguspw -keystore bogus.cert
+
+    private Logger log = LoggerFactory.getLogger(getClass());
+
+    // @Configuration
+    private boolean preload = true;
+
+    // @Configuration
+    private String keystoreResource = "bogus.cert";
+
+    // @Configuration
+    private char[] keystorePassword = { 'b', 'o', 'g', 'u', 's', 'p', 'w' };
+
+    private SSLContext serverInstance;
+
+    private SSLContext clientInstance;
+
+    public synchronized void initialize() throws InitializationException {
+        if (preload) {
+            log.debug("Preloading SSLContext instances");
+            
+            try {
+                createServerContext();
+                createClientContext();
+            }
+            catch (GeneralSecurityException e) {
+                throw new InitializationException("Failed to setup SSLContext instances", e);
+            }
+        }
+    }
+
+    //
+    // SSLContextFactory
+    //
+
+    public synchronized SSLContext createServerContext() throws GeneralSecurityException {
+        if (serverInstance == null) {
+            KeyStore keyStore;
+
+            try {
+                keyStore = KeyStore.getInstance("JKS");
+
+                InputStream in = getClass().getResourceAsStream(keystoreResource);
+                if (in == null) {
+                    throw new GeneralSecurityException("Failed to load bogus keystore from resource: " + keystoreResource);
+                }
+
+                try {
+                    keyStore.load(in, keystorePassword);
+                }
+                finally {
+                    IOUtil.close(in);
+                }
+            }
+            catch (IOException e) {
+                throw new GeneralSecurityException("Failed to load bogus keystore", e);
+            }
+
+            // Set up key manager factory to use our key store
+            KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KEY_MANAGER_FACTORY_ALGORITHM);
+            keyManagerFactory.init(keyStore, keystorePassword);
+
+            // Initialize the SSLContext to work with our key managers.
+            SSLContext context = SSLContext.getInstance(PROTOCOL);
+            context.init(keyManagerFactory.getKeyManagers(), BogusTrustManagerFactory.X509_MANAGERS, null);
+
+            serverInstance = context;
+
+            log.debug("Created server SSLContext: {}", serverInstance);
+        }
+
+        return serverInstance;
+    }
+
+    public synchronized SSLContext createClientContext() throws GeneralSecurityException {
+        if (clientInstance == null) {
+            SSLContext context = SSLContext.getInstance(PROTOCOL);
+            context.init(null, BogusTrustManagerFactory.X509_MANAGERS, null);
+
+            clientInstance = context;
+
+            log.debug("Created client SSLContext: {}", clientInstance);
+        }
+
+        return clientInstance;
+    }
+
+    //
+    // BogusTrustManagerFactory
+    //
+
+    private static class BogusTrustManagerFactory
+        extends TrustManagerFactorySpi
+    {
+        private static final X509TrustManager X509 = new X509TrustManager() {
+            public void checkClientTrusted(X509Certificate[] c, String s) throws CertificateException {}
+
+            public void checkServerTrusted(X509Certificate[] c, String s) throws CertificateException {}
+
+            public X509Certificate[] getAcceptedIssuers() {
+                return new X509Certificate[0];
+            }
+        };
+
+        private static final TrustManager[] X509_MANAGERS = { X509 };
+
+        @Override
+        protected TrustManager[] engineGetTrustManagers() {
+            return X509_MANAGERS;
+        }
+
+        @Override
+        protected void engineInit(KeyStore keystore) throws KeyStoreException {}
+
+        @Override
+        protected void engineInit(ManagerFactoryParameters managerFactoryParameters) throws InvalidAlgorithmParameterException {}
+    }
+}

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/SSLContextFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/SSLContextFactory.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/SSLContextFactory.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/SSLContextFactory.java Sun Sep 23 05:02:46 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.
+ */
+
+//
+// NOTE: Snatched from Apache Mina'a Examples
+//
+
+package org.apache.geronimo.gshell.whisper.ssl;
+
+import java.security.GeneralSecurityException;
+
+import javax.net.ssl.SSLContext;
+
+/**
+ * Provides an abstraction of client and server {@link SSLContext} creation.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SSLContextFactory
+{
+    /**
+     * Creates a {@link SSLContext} suiteable for server-side usage.
+     */
+    SSLContext createServerContext() throws GeneralSecurityException;
+
+    /**
+     * Creates a {@link SSLContext} suiteable for client-side usage.
+     */
+    SSLContext createClientContext() throws GeneralSecurityException;
+}
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/package-info.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/package-info.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/package-info.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * Support for SSL.
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.whisper.ssl;
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionInputStream.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionInputStream.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionInputStream.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionInputStream.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,198 @@
+/*
+ * 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.stream;
+
+//
+// NOTE: Snatched and massaged from Apache Mina
+//
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.geronimo.gshell.common.NestedIOException;
+import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
+import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
+import org.apache.geronimo.gshell.whisper.session.SessionAttributeBinder;
+import org.apache.mina.common.ByteBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An {@link InputStream} that buffers data read from {@link StreamMessage} messages.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SessionInputStream
+    extends InputStream
+{
+    public static final SessionAttributeBinder<SessionInputStream> BINDER = new SessionAttributeBinder<SessionInputStream>(SessionInputStream.class);
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private final Object mutex = new Object();
+
+    private final ByteBuffer buff;
+
+    private volatile boolean closed;
+
+    private volatile boolean released;
+
+    private IOException exception;
+
+    public SessionInputStream() {
+        buff = ByteBuffer.allocate(16);
+        buff.setAutoExpand(true);
+        buff.limit(0);
+    }
+
+    public String toString() {
+        return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
+    }
+
+    public int available() {
+        if (released) {
+            return 0;
+        }
+        else {
+            synchronized (mutex) {
+                return buff.remaining();
+            }
+        }
+    }
+
+    public void close() {
+        if (closed) {
+            return;
+        }
+
+        synchronized (mutex) {
+            closed = true;
+
+            releaseBuffer();
+
+            mutex.notifyAll();
+        }
+    }
+
+    public int read() throws IOException {
+        synchronized (mutex) {
+            if (!waitForData()) {
+                return -1;
+            }
+
+            return buff.get() & 0xff;
+        }
+    }
+
+    public int read(final byte[] b, final int off, final int len) throws IOException {
+        synchronized (mutex) {
+            if (!waitForData()) {
+                return -1;
+            }
+
+            int readBytes;
+
+            if (len > buff.remaining()) {
+                readBytes = buff.remaining();
+            }
+            else {
+                readBytes = len;
+            }
+
+            buff.get(b, off, readBytes);
+
+            return readBytes;
+        }
+    }
+
+    private boolean waitForData() throws IOException {
+        if (released) {
+            return false;
+        }
+
+        synchronized (mutex) {
+            while (!released && buff.remaining() == 0 && exception == null) {
+                try {
+                    mutex.wait();
+                }
+                catch (InterruptedException e) {
+                    throw new NestedIOException("Interrupted while waiting for more data");
+                }
+            }
+        }
+
+        if (exception != null) {
+            releaseBuffer();
+
+            throw exception;
+        }
+
+        if (closed && buff.remaining() == 0) {
+            releaseBuffer();
+
+            return false;
+        }
+
+        return true;
+    }
+
+    private void releaseBuffer() {
+        if (released) {
+            return;
+        }
+
+        released = true;
+    }
+
+    public void write(final StreamMessage msg) {
+        synchronized (mutex) {
+            if (closed) {
+                return;
+            }
+
+            ByteBuffer src = msg.getBuffer();
+
+            log.debug("Writing {} bytes", src.remaining());
+
+            if (buff.hasRemaining()) {
+                buff.compact();
+                buff.put(src);
+                buff.flip();
+            }
+            else {
+                buff.clear();
+                buff.put(src);
+                buff.flip();
+
+                mutex.notifyAll();
+            }
+        }
+    }
+
+    public void throwException(final IOException e) {
+        synchronized (mutex) {
+            if (exception == null) {
+                exception = e;
+
+                mutex.notifyAll();
+            }
+        }
+    }
+}
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionOutputStream.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionOutputStream.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionOutputStream.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionOutputStream.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,127 @@
+/*
+ * 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.stream;
+
+//
+// NOTE: Snatched and massaged from Apache Mina
+//
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
+import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
+import org.apache.geronimo.gshell.whisper.session.SessionAttributeBinder;
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.common.WriteFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An {@link OutputStream} that forwards all write operations as {@link StreamMessage} messages.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SessionOutputStream
+    extends OutputStream
+{
+    public static final SessionAttributeBinder<SessionOutputStream> BINDER = new SessionAttributeBinder<SessionOutputStream>(SessionOutputStream.class);
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+    
+    private final IoSession session;
+
+    private WriteFuture lastWriteFuture;
+
+    private volatile boolean opened;
+
+    public SessionOutputStream(final IoSession session) {
+        assert session != null;
+        
+        this.session = session;
+
+        this.opened = true;
+    }
+
+    public String toString() {
+        return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
+    }
+
+    public void close() throws IOException {
+        if (!opened) {
+            return;
+        }
+        
+        try {
+            flush();
+
+            opened = false;
+        }
+        finally {
+            super.close();
+        }
+    }
+
+    public void write(final byte[] b, final int off, final int len) throws IOException {
+        write(ByteBuffer.wrap(b.clone(), off, len));
+    }
+
+    public void write(final int b) throws IOException {
+        ByteBuffer buff = ByteBuffer.allocate(1);
+        buff.put((byte) b);
+        buff.flip();
+
+        write(buff);
+    }
+
+    private void ensureOpened() throws IOException {
+        if (!opened || !session.isConnected()) {
+            throw new IOException("The session has been closed.");
+        }
+    }
+    
+    private synchronized void write(final ByteBuffer buff) throws IOException {
+        ensureOpened();
+
+        log.debug("Writing {} bytes", buff.remaining());
+
+        WriteFuture wf = session.write(new StreamMessage(buff));
+
+        lastWriteFuture = wf;
+
+        wf.join();
+    }
+
+    public synchronized void flush() throws IOException {
+        ensureOpened();
+
+        if (lastWriteFuture == null) {
+            return;
+        }
+        
+        // Process the last write future and clear it
+        lastWriteFuture.join();
+
+        if (!lastWriteFuture.isWritten()) {
+            throw new IOException("Failed to fully write bytes to the session");
+        }
+    }
+}

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionStreamFilter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionStreamFilter.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionStreamFilter.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionStreamFilter.java Sun Sep 23 05:02:46 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.stream;
+
+import org.apache.mina.common.IoFilterAdapter;
+import org.apache.mina.common.IoSession;
+import org.codehaus.plexus.util.IOUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Provides stream I/O handling.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SessionStreamFilter
+    extends IoFilterAdapter
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    /**
+     * Setup the input and output streams for the session.
+     */
+    @Override
+    public void sessionCreated(final NextFilter nextFilter, final IoSession session) throws Exception {
+        SessionInputStream.BINDER.bind(session, new SessionInputStream());
+        SessionOutputStream.BINDER.bind(session, new SessionOutputStream(session));
+
+        nextFilter.sessionCreated(session);
+    }
+
+    /**
+     * Close the input and output streams for the session.
+     */
+    @Override
+    public void sessionClosed(final NextFilter nextFilter, final IoSession session) throws Exception {
+        IOUtil.close(SessionInputStream.BINDER.unbind(session));
+        IOUtil.close(SessionOutputStream.BINDER.unbind(session));
+
+        nextFilter.sessionClosed(session);
+    }
+
+    /**
+     * Handles write stream messages.
+     */
+    @Override
+    public void messageReceived(final NextFilter nextFilter, final IoSession session, final Object message) throws Exception {
+        if (message instanceof StreamMessage) {
+            StreamMessage msg = (StreamMessage) message;
+
+            SessionInputStream in = SessionInputStream.BINDER.lookup(session);
+
+            in.write(msg);
+
+            // There is no need to pass on this message to any other filters, they have no use for it...
+        }
+        else {
+            nextFilter.messageReceived(session, message);
+        }
+    }
+}
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamFeeder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamFeeder.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamFeeder.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamFeeder.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,98 @@
+/*
+ * 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.stream;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Feeds data from an input stream to an output stream.
+ *
+ * @version $Rev$ $Date$
+ */
+public class StreamFeeder
+    implements Runnable
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private final InputStream input;
+
+    private final OutputStream output;
+
+    private volatile boolean running;
+
+    public StreamFeeder(final InputStream input, final OutputStream output) {
+        assert input != null;
+        assert output != null;
+        
+        this.input = input;
+        this.output = output;
+    }
+
+    public void run() {
+        running = true;
+
+        log.debug("Running");
+
+        //
+        // TODO: Look into using a byte[] buffer here to read larger chunks at the same time?
+        //
+        
+        try {
+            int b;
+
+            while (running && ((b = input.read()) != -1)) {
+                output.write(b);
+            }
+        }
+        catch (Throwable e) {
+            log.error("Feed failure: " + e, e);
+        }
+        finally {
+            close();
+        }
+
+        log.debug("Stopped");
+    }
+
+    public boolean isRunning() {
+        return running;
+    }
+    
+    public void close() {
+        running = false;
+        
+        log.debug("Closed");
+    }
+
+    private static final AtomicInteger THREAD_COUNTER = new AtomicInteger(0);
+
+    public Thread createThread() {
+        Thread t = new Thread(this, getClass().getSimpleName() + "-" + THREAD_COUNTER.getAndIncrement());
+
+        t.setDaemon(true);
+        
+        return t;
+    }
+}
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamMessage.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamMessage.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamMessage.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamMessage.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,111 @@
+/*
+ * 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.stream;
+
+import java.io.IOException;
+
+import org.apache.geronimo.gshell.whisper.marshal.Marshaller;
+import org.apache.geronimo.gshell.whisper.message.Message;
+import org.apache.geronimo.gshell.whisper.message.MessageSupport;
+import org.apache.geronimo.gshell.whisper.message.MessageType;
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.RuntimeIOException;
+
+/**
+ * Write a buffer to a stream.
+ *
+ * @version $Rev$ $Date$
+ */
+public class StreamMessage
+    extends MessageSupport
+{
+    private ByteBuffer buffer;
+
+    public StreamMessage(final Type type, final ByteBuffer buffer) {
+        super(type);
+
+        if (buffer != null) {
+            ByteBuffer tmp = ByteBuffer.allocate(buffer.remaining());
+
+            tmp.put(buffer);
+            tmp.flip();
+
+            this.buffer = tmp;
+        }
+    }
+
+    public StreamMessage(final ByteBuffer buffer) {
+        this(Type.IN, buffer);
+    }
+    
+    public StreamMessage() {
+        this(null, null);
+    }
+
+    public ByteBuffer getBuffer() {
+        return buffer;
+    }
+
+    public void setBuffer(final ByteBuffer buffer) {
+        this.buffer = buffer;
+    }
+
+    public void readExternal(final ByteBuffer in) throws Exception {
+        assert in != null;
+
+        buffer = Marshaller.readBuffer(in);
+    }
+
+    public void writeExternal(final ByteBuffer out) throws Exception {
+        assert out != null;
+
+        Marshaller.writeBuffer(out, buffer);
+    }
+
+    public static enum Type
+        implements MessageType
+    {
+
+        IN,  // (local SYSOUT to remote SYSIN)
+        OUT, // ???
+        ERR  // ???
+        ;
+
+        public Class<? extends Message> getType() {
+            return StreamMessage.class;
+        }
+
+        // Dynamically fitgure out how bit we are, assumes each enum is sized the same
+        private volatile Integer size;
+
+        public int size() {
+            if (size == null) {
+                try {
+                    size = Marshaller.marshall(IN).length;
+                }
+                catch (IOException e) {
+                    throw new RuntimeIOException(e);
+                }
+            }
+
+            return size;
+        }
+    }
+}
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/package-info.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/package-info.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/package-info.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * Support for remote input and output streaming.
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.whisper.stream;
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ConnectException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ConnectException.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ConnectException.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ConnectException.java Sun Sep 23 05:02:46 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;
+
+/**
+ * Thrown to indicate a connection related failure has occured.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConnectException
+    extends TransportException
+{
+    private static final long serialVersionUID = 1;
+
+    public ConnectException(final String msg, final Throwable cause) {
+        super(msg, cause);
+    }
+
+    public ConnectException(final String msg) {
+        super(msg);
+    }
+
+    public ConnectException(final Throwable cause) {
+        super(cause);
+    }
+
+    public ConnectException() {
+        super();
+    }
+}
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/Transport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/Transport.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/Transport.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/Transport.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,65 @@
+/*
+ * 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.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.geronimo.gshell.common.Duration;
+import org.apache.geronimo.gshell.whisper.message.Message;
+import org.apache.mina.common.IoService;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.common.WriteFuture;
+
+/**
+ * Provides the client-side protocol interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Transport
+{
+    URI getRemoteLocation();
+
+    URI getLocalLocation();
+
+    IoService getService();
+
+    IoSession getSession();
+
+    void connect() throws Exception;
+
+    boolean isConnected();
+
+    void close();
+    
+    WriteFuture send(Object msg) throws Exception;
+
+    Message request(Message msg, Duration timeout) throws Exception;
+
+    Message request(Message msg, long timeout, TimeUnit unit) throws Exception;
+
+    Message request(Message msg) throws Exception;
+
+    InputStream getInputStream();
+
+    OutputStream getOutputStream();
+}
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportException.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportException.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportException.java Sun Sep 23 05:02:46 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;
+
+/**
+ * Thrown to indicate a transport failure has occured.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TransportException
+    extends RuntimeException
+{
+    private static final long serialVersionUID = 1;
+
+    public TransportException(final String msg, final Throwable cause) {
+        super(msg, cause);
+    }
+
+    public TransportException(final String msg) {
+        super(msg);
+    }
+
+    public TransportException(final Throwable cause) {
+        super(cause);
+    }
+
+    public TransportException() {
+        super();
+    }
+}
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportExceptionMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportExceptionMonitor.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportExceptionMonitor.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportExceptionMonitor.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,41 @@
+/*
+ * 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 org.apache.mina.common.ExceptionMonitor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class TransportExceptionMonitor
+    extends ExceptionMonitor
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    public void exceptionCaught(final Throwable cause) {
+        assert cause != null;
+
+        log.error("Unhandled exception: " + cause, cause);
+    }
+}
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportFactory.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportFactory.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportFactory.java Sun Sep 23 05:02:46 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;
+
+import java.net.URI;
+
+/**
+ * Factory for producing client and server transport implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface TransportFactory
+{
+    Transport connect(final URI remote, final URI local) throws Exception;
+
+    Transport connect(final URI remote) throws Exception;
+
+    TransportServer bind(final URI location) throws Exception;
+}
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocator.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocator.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocator.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,59 @@
+/*
+ * 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.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+/**
+ * Helper to locate a {@link TransportFactory} instance.
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=TransportFactoryLocator.class)
+public class TransportFactoryLocator
+{
+    @Requirement
+    private PlexusContainer container;
+
+    public TransportFactory locate(final URI location) throws MissingSchemeException, ComponentLookupException {
+        assert location != null;
+
+        String scheme = location.getScheme();
+
+        if (scheme == null) {
+            throw new MissingSchemeException(location);
+        }
+
+        return (TransportFactory) container.lookup(TransportFactory.class, scheme);
+    }
+
+    public static class MissingSchemeException
+        extends TransportException
+    {
+        public MissingSchemeException(final URI location) {
+            super("Invalid location; missing scheme: " + location);
+        }
+    }
+}
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportServer.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportServer.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportServer.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,42 @@
+/*
+ * 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.mina.common.IoService;
+
+/**
+ * Provides the server-side protocol interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface TransportServer
+{
+    URI getLocation();
+
+    IoService getService();
+
+    void bind() throws Exception;
+
+    boolean isBound();
+
+    void close();
+}
\ No newline at end of file

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

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

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

Added: 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/BaseCommon.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseCommon.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseCommon.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,256 @@
+/*
+ * 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 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.whisper.transport.Transport;
+import org.apache.geronimo.gshell.whisper.transport.TransportExceptionMonitor;
+import org.apache.geronimo.gshell.whisper.transport.TransportServer;
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.DefaultIoFilterChainBuilder;
+import org.apache.mina.common.ExceptionMonitor;
+import org.apache.mina.common.IoFilterChain;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoService;
+import org.apache.mina.common.IoServiceConfig;
+import org.apache.mina.common.IoServiceListener;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.common.SimpleByteBufferAllocator;
+import org.apache.mina.filter.LoggingFilter;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.codehaus.plexus.PlexusContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Common bits for {@link Transport} and {@link TransportServer} implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseCommon
+{
+    static {
+        // Setup our exception monitor
+        ExceptionMonitor.setInstance(new TransportExceptionMonitor());
+        
+        // Make sure that we use non-pooled fast buffers
+        ByteBuffer.setUseDirectBuffers(false);
+        ByteBuffer.setAllocator(new SimpleByteBufferAllocator());
+    }
+
+    protected final Logger log = LoggerFactory.getLogger(getClass());
+
+    private IoHandler handler;
+
+    private IoService service;
+
+    // private StatCollector statCollector;
+
+    public String toString() {
+        return ReflectionToStringBuilder.toString(this);
+    }
+
+    protected IoHandler getHandler() {
+        if (handler == null) {
+            throw new IllegalStateException("Handler not bound");
+        }
+        
+        return handler;
+    }
+
+    public IoService getService() {
+        return service;
+    }
+
+    //
+    // Configuration
+    //
+    
+    protected void configure(final IoService service) throws Exception {
+        assert service != null;
+
+        this.service = service;
+
+        service.addListener(new IoServiceListener() {
+            public void serviceActivated(final IoService service, final SocketAddress serviceAddress, final IoHandler handler, final IoServiceConfig config) {
+                log.info("Service activated: {}", service);
+
+                // log.info("Service activated: {}, {}, {}, {}", service, serviceAddress, handler, config);
+
+                logFilters(service);
+            }
+
+            public void serviceDeactivated(final IoService service, final SocketAddress serviceAddress, final IoHandler handler, final IoServiceConfig config) {
+                log.info("Service deactivated: {}", service);
+
+                // log.info("Service deactivated: {}, {}, {}, {}", service, serviceAddress, handler, config);
+            }
+
+            public void sessionCreated(final IoSession session) {
+                log.info("Session created: {}", session);
+
+                logFilters(session);
+            }
+
+            public void sessionDestroyed(final IoSession session) {
+                log.info("Session destroyed: {}", session);
+            }
+        });
+
+        // Setup the io handler
+        handler = getMessageHandler();
+
+        // Install the default set of filters
+        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;
+
+        // 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());
+
+        chain.addLast(SessionStreamFilter.class.getSimpleName(), new SessionStreamFilter());
+
+        chain.addLast(RequestResponseFilter.class.getSimpleName(), new RequestResponseFilter());
+    }
+
+    public void close() {
+        // statCollector.stop();
+    }
+
+    //
+    // Logging Helpers
+    //
+    
+    protected void logFilters(final IoService service) {
+        assert service != null;
+
+        log.debug("Service filters:");
+
+        for (IoFilterChain.Entry entry : service.getFilterChain().getAll()) {
+            log.debug("    {}", entry);
+        }
+    }
+
+    protected void logFilters(final IoSession session) {
+        assert session != null;
+        
+        log.debug("Session filters:");
+
+        for (IoFilterChain.Entry entry : session.getFilterChain().getAll()) {
+            log.debug("    {}", entry);
+        }
+    }
+
+    /*
+    protected void logStats(final IoSession session) {
+        assert session != null;
+
+        IoSessionStat stat = (IoSessionStat) session.getAttribute(StatCollector.KEY);
+
+        if (stat != null) {
+            log.debug("Stats: {}", ReflectionToStringBuilder.toString(stat, ToStringStyle.SHORT_PREFIX_STYLE));
+        }
+    }
+    */
+    
+    //
+    // AutoWire Support, Setters exposed to support Plexus autowire()  Getters exposed to handle state checking.
+    //
+
+    private PlexusContainer container;
+
+    private MessageProvider provider;
+
+    private MessageHandler messageHandler;
+
+    public void setMessageHandler(final MessageHandler messageHandler) {
+        assert messageHandler != null;
+
+        log.trace("Using message handler: {}", messageHandler);
+
+        this.messageHandler = messageHandler;
+    }
+
+    protected MessageHandler getMessageHandler() {
+        if (messageHandler == null) {
+            throw new IllegalStateException("Message handler not bound");
+        }
+
+        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");
+        }
+
+        return container;
+    }
+}
\ No newline at end of file



Mime
View raw message