geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r446519 [2/4] - in /geronimo/sandbox/gcache: ./ openwire/ openwire/src/ openwire/src/main/ openwire/src/main/java/ openwire/src/main/java/org/ openwire/src/main/java/org/apache/ openwire/src/main/java/org/apache/geronimo/ openwire/src/main/...
Date Fri, 15 Sep 2006 04:57:27 GMT
Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/MutexTransport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/MutexTransport.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/MutexTransport.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/MutexTransport.java Thu Sep 14 21:57:24 2006
@@ -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.openwire.transport;
+
+import java.io.IOException;
+
+import org.apache.activemq.command.Command;
+import org.apache.activemq.command.Response;
+
+
+/**
+ * @version $Revision$
+ */
+public class MutexTransport extends TransportFilter {
+
+    private final Object writeMutex = new Object();
+    
+    public MutexTransport(Transport next) {
+        super(next);
+    }
+
+    public FutureResponse asyncRequest(Command command, ResponseCallback responseCallback) throws IOException {
+        synchronized(writeMutex) {
+            return next.asyncRequest(command, null);
+        }
+    }
+
+    public void oneway(Command command) throws IOException {
+        synchronized(writeMutex) {
+            next.oneway(command);
+        }
+    }
+
+    public Response request(Command command) throws IOException {
+        synchronized(writeMutex) {
+            return next.request(command);
+        }
+    }
+    
+    public Response request(Command command,int timeout) throws IOException {
+        synchronized(writeMutex){
+            return next.request(command,timeout);
+        }
+    }
+    
+    public String toString() {
+        return next.toString();
+    }
+    
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/MutexTransport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/MutexTransport.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/MutexTransport.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/MutexTransport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCallback.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCallback.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCallback.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCallback.java Thu Sep 14 21:57:24 2006
@@ -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.
+ */
+package org.apache.geronimo.openwire.transport;
+
+/**
+ * @version $Revision$
+ */
+public interface ResponseCallback {
+    void onCompletion(FutureResponse resp);
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCallback.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCallback.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCallback.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCorrelator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCorrelator.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCorrelator.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCorrelator.java Thu Sep 14 21:57:24 2006
@@ -0,0 +1,122 @@
+/**
+ *
+ * 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.openwire.transport;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.openwire.command.Command;
+import org.apache.geronimo.openwire.command.Response;
+import org.apache.geronimo.openwire.command.ExceptionResponse;
+import org.apache.geronimo.openwire.util.IntSequenceGenerator;
+
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * Adds the incrementing sequence number to commands along with performing the corelation of
+ * responses to requests to create a blocking request-response semantics.
+ * 
+ * @version $Revision$
+ */
+public class ResponseCorrelator extends TransportFilter {
+    
+    private static final Log log = LogFactory.getLog(ResponseCorrelator.class);
+    
+    private final ConcurrentHashMap requestMap = new ConcurrentHashMap();
+    private IntSequenceGenerator sequenceGenerator;
+    
+    public ResponseCorrelator(Transport next) {
+        this(next, new IntSequenceGenerator());
+    }
+    
+    public ResponseCorrelator(Transport next, IntSequenceGenerator sequenceGenerator) {
+        super(next);
+        this.sequenceGenerator = sequenceGenerator;
+    }
+
+    public void oneway(Command command) throws IOException {
+        command.setCommandId(sequenceGenerator.getNextSequenceId());
+        command.setResponseRequired(false);
+        next.oneway(command);
+    }
+
+    public FutureResponse asyncRequest(Command command, ResponseCallback responseCallback) throws IOException {
+        command.setCommandId(sequenceGenerator.getNextSequenceId());
+        command.setResponseRequired(true);
+        FutureResponse future = new FutureResponse(responseCallback);
+        requestMap.put(new Integer(command.getCommandId()), future);
+        next.oneway(command);
+        return future;
+    }
+    
+    public Response request(Command command) throws IOException { 
+        FutureResponse response = asyncRequest(command, null);
+        return response.getResult();
+    }
+    
+    public Response request(Command command,int timeout) throws IOException {
+        FutureResponse response = asyncRequest(command, null);
+        return response.getResult(timeout);
+    }
+    
+    public void onCommand(Command command) {
+        boolean debug = log.isDebugEnabled();
+        if( command.isResponse() ) {
+            Response response = (Response) command;
+            FutureResponse future = (FutureResponse) requestMap.remove(new Integer(response.getCorrelationId()));
+            if( future!=null ) {
+                future.set(response);
+            } else {
+                if( debug ) log.debug("Received unexpected response for command id: "+response.getCorrelationId());
+            }
+        } else {
+            getTransportListener().onCommand(command);
+        }
+    }
+    
+    /**
+     * If an async exception occurs, then assume no responses will arrive for any of
+     * current requests.  Lets let them know of the problem.
+     */
+    public void onException(IOException error) {
+        
+        // Copy and Clear the request Map
+        ArrayList requests = new ArrayList(requestMap.values());
+        requestMap.clear();
+        
+        for (Iterator iter = requests.iterator(); iter.hasNext();) {
+            FutureResponse fr = (FutureResponse) iter.next();
+            fr.set(new ExceptionResponse(error));
+        }
+        
+        super.onException(error);
+    }
+    
+    public IntSequenceGenerator getSequenceGenerator() {
+        return sequenceGenerator;
+    }
+
+    public String toString() {
+        return next.toString();
+    }
+
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCorrelator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCorrelator.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCorrelator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/ResponseCorrelator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/Transport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/Transport.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/Transport.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/Transport.java Thu Sep 14 21:57:24 2006
@@ -0,0 +1,94 @@
+/**
+ *
+ * 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.openwire.transport;
+
+import org.apache.geronimo.openwire.command.Command;
+import org.apache.geronimo.openwire.command.Response;
+import org.apache.geronimo.openwire.Service;
+
+import java.io.IOException;
+
+/**
+ * Represents the client side of a transport allowing messages
+ * to be sent synchronously, asynchronously and consumed.
+ *
+ * @version $Revision$
+ */
+public interface Transport extends Service {
+
+    /**
+     * A one way asynchronous send
+     * @param command 
+     * @throws IOException 
+     */
+    public void oneway(Command command) throws IOException;
+
+    /**
+     * An asynchronous request response where the Receipt will be returned
+     * in the future.  If responseCallback is not null, then it will be called
+     * when the response has been completed.
+     * 
+     * @param command 
+     * @param responseCallback TODO
+     * @return the FutureResponse
+     * @throws IOException 
+     */
+    public FutureResponse asyncRequest(Command command, ResponseCallback responseCallback) throws IOException;
+    
+    /**
+     * A synchronous request response
+     * @param command 
+     * @return the response
+     * @throws IOException 
+     */
+    public Response request(Command command) throws IOException;
+
+    /**
+     * A synchronous request response
+     * @param command 
+     * @param timeout 
+     * @return the repsonse or null if timeout
+     * @throws IOException 
+     */
+    public Response request(Command command, int timeout) throws IOException;
+
+    /**
+     * Returns the current transport listener
+     * @return TransportListener
+     */
+    public TransportListener getTransportListener();
+
+    /**
+     * Registers an inbound command listener
+     * @param commandListener 
+     */
+    public void setTransportListener(TransportListener commandListener);
+    
+    /**
+     * @param target
+     * @return the target
+     */
+    public Object narrow(Class target);
+
+    /**
+     * @return the remote address for this connection
+     *  
+     */
+	public String getRemoteAddress();
+
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/Transport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/Transport.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/Transport.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

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

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportAcceptListener.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportAcceptListener.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportAcceptListener.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportAcceptListener.java Thu Sep 14 21:57:24 2006
@@ -0,0 +1,27 @@
+/**
+ *
+ * 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.openwire.transport;
+
+
+public interface TransportAcceptListener {
+    
+    void onAccept(Transport transport);
+    
+    void onAcceptError(Exception error);
+
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportAcceptListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportAcceptListener.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportAcceptListener.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportAcceptListener.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportDisposedIOException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportDisposedIOException.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportDisposedIOException.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportDisposedIOException.java Thu Sep 14 21:57:24 2006
@@ -0,0 +1,43 @@
+/**
+ *
+ * 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.openwire.transport;
+
+import java.io.IOException;
+
+/**
+ * This is exception is thrown when the transport is disposed
+ * 
+ * @version $Revision$
+ */
+public class TransportDisposedIOException extends IOException {
+
+    private static final long serialVersionUID=-7107323414439622596L;
+
+    public TransportDisposedIOException() {
+        super();
+    }
+
+    /**
+     * @param message
+     */
+    public TransportDisposedIOException(String message) {
+        super(message);
+    }
+
+
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportDisposedIOException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportDisposedIOException.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportDisposedIOException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFactory.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFactory.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFactory.java Thu Sep 14 21:57:24 2006
@@ -0,0 +1,235 @@
+/**
+ *
+ * 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.openwire.transport;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.geronimo.openwire.util.FactoryFinder;
+import org.apache.geronimo.openwire.util.URISupport;
+import org.apache.geronimo.openwire.util.IOExceptionSupport;
+import org.apache.geronimo.openwire.util.IntrospectionSupport;
+import org.apache.geronimo.openwire.wireformat.WireFormat;
+import org.apache.geronimo.openwire.wireformat.WireFormatFactory;
+
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+import edu.emory.mathcs.backport.java.util.concurrent.Executor;
+
+public abstract class TransportFactory {
+
+    public abstract TransportServer doBind(String brokerId, URI location) throws IOException;
+
+    public Transport doConnect(URI location, Executor ex) throws Exception {
+        return doConnect(location);
+    }
+
+    public Transport doCompositeConnect(URI location, Executor ex) throws Exception {
+        return doCompositeConnect(location);
+    }
+
+    static final private FactoryFinder transportFactoryFinder = new FactoryFinder("META-INF/services/org/apache/activemq/transport/");
+    static final private FactoryFinder wireFormatFactoryFinder = new FactoryFinder("META-INF/services/org/apache/activemq/wireformat/");
+
+    static final private ConcurrentHashMap transportFactorys = new ConcurrentHashMap();
+
+    /**
+     * Creates a normal transport.
+     * 
+     * @param location
+     * @return the transport
+     * @throws Exception
+     */
+    public static Transport connect(URI location) throws Exception {
+        TransportFactory tf = findTransportFactory(location);
+        return tf.doConnect(location);
+    }
+
+    /**
+     * Creates a normal transport.
+     * 
+     * @param location
+     * @param ex
+     * @return the transport
+     * @throws Exception
+     */
+    public static Transport connect(URI location, Executor ex) throws Exception {
+        TransportFactory tf = findTransportFactory(location);
+        return tf.doConnect(location, ex);
+    }
+
+    /**
+     * Creates a slimmed down transport that is more efficient so that it can be
+     * used by composite transports like reliable and HA.
+     * 
+     * @param location
+     * @return the Transport
+     * @throws Exception
+     */
+    public static Transport compositeConnect(URI location) throws Exception {
+        TransportFactory tf = findTransportFactory(location);
+        return tf.doCompositeConnect(location);
+    }
+
+    /**
+     * Creates a slimmed down transport that is more efficient so that it can be
+     * used by composite transports like reliable and HA.
+     * 
+     * @param location
+     * @param ex
+     * @return the Transport
+     * @throws Exception
+     */
+    public static Transport compositeConnect(URI location, Executor ex) throws Exception {
+        TransportFactory tf = findTransportFactory(location);
+        return tf.doCompositeConnect(location, ex);
+    }
+
+    public static TransportServer bind(String brokerId, URI location) throws IOException {
+        TransportFactory tf = findTransportFactory(location);
+        return tf.doBind(brokerId, location);
+    }
+
+    public Transport doConnect(URI location) throws Exception {
+        try {
+            Map options = new HashMap(URISupport.parseParamters(location));
+            WireFormat wf = createWireFormat(options);
+            Transport transport = createTransport(location, wf);
+            Transport rc = configure(transport, wf, options);
+            if (!options.isEmpty()) {
+                throw new IllegalArgumentException("Invalid connect parameters: " + options);
+            }
+            return rc;
+        }
+        catch (URISyntaxException e) {
+            throw IOExceptionSupport.create(e);
+        }
+    }
+
+    public Transport doCompositeConnect(URI location) throws Exception {
+        try {
+            Map options = new HashMap(URISupport.parseParamters(location));
+            WireFormat wf = createWireFormat(options);
+            Transport transport = createTransport(location, wf);
+            Transport rc = compositeConfigure(transport, wf, options);
+            if (!options.isEmpty()) {
+                throw new IllegalArgumentException("Invalid connect parameters: " + options);
+            }
+            return rc;
+
+        }
+        catch (URISyntaxException e) {
+            throw IOExceptionSupport.create(e);
+        }
+    }
+
+    /**
+     * Factory method to create a new transport
+     * @throws IOException 
+     * @throws UnknownHostException 
+     */
+    protected Transport createTransport(URI location, WireFormat wf) throws MalformedURLException, UnknownHostException, IOException {
+        throw new IOException("createTransport() method not implemented!");
+    }
+
+    /**
+     * @param location
+     * @return
+     * @throws IOException
+     */
+    private static TransportFactory findTransportFactory(URI location) throws IOException {
+        String scheme = location.getScheme();
+        if( scheme == null )
+            throw new IOException("Transport not scheme specified: [" + location + "]");
+        TransportFactory tf = (TransportFactory) transportFactorys.get(scheme);
+        if (tf == null) {
+            // Try to load if from a META-INF property.
+            try {
+                tf = (TransportFactory) transportFactoryFinder.newInstance(scheme);
+                transportFactorys.put(scheme, tf);
+            }
+            catch (Throwable e) {
+                throw IOExceptionSupport.create("Transport scheme NOT recognized: [" + scheme + "]", e);
+            }
+        }
+        return tf;
+    }
+
+    protected WireFormat createWireFormat(Map options) throws IOException {
+        WireFormatFactory factory = createWireFormatFactory(options);
+        WireFormat format = factory.createWireFormat();
+        return format;
+    }
+
+    protected WireFormatFactory createWireFormatFactory(Map options) throws IOException {
+        String wireFormat = (String) options.get("wireFormat");
+        if (wireFormat == null)
+            wireFormat = getDefaultWireFormatType();
+
+        try {
+            WireFormatFactory wff = (WireFormatFactory) wireFormatFactoryFinder.newInstance(wireFormat);
+            IntrospectionSupport.setProperties(wff, options, "wireFormat.");
+            return wff;
+        }
+        catch (Throwable e) {
+            throw IOExceptionSupport.create("Could not create wire format factory for: " + wireFormat + ", reason: " + e, e);
+        }
+    }
+
+    protected String getDefaultWireFormatType() {
+        return "default";
+    }
+
+    /**
+     * Fully configures and adds all need transport filters so that the transport
+     * can be used by the JMS client.
+     * 
+     * @param transport
+     * @param wf
+     * @param options
+     * @return
+     * @throws Exception
+     */
+    public Transport configure(Transport transport, WireFormat wf, Map options) throws Exception {
+    	transport = compositeConfigure(transport, wf, options);
+    	
+        transport = new MutexTransport(transport);
+        transport = new ResponseCorrelator(transport);
+        
+        return transport;
+    }
+
+    /**
+     * Similar to configure(...) but this avoid adding in the MutexTransport and ResponseCorrelator transport layers
+     * so that the resulting transport can more efficiently be used as part of a composite transport.
+     * 
+     * @param transport
+     * @param format
+     * @param options
+     * @return Transport
+     */
+    public Transport compositeConfigure(Transport transport, WireFormat format, Map options) {
+        IntrospectionSupport.setProperties(transport, options);
+        return transport;
+    }
+
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

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

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFilter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFilter.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFilter.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFilter.java Thu Sep 14 21:57:24 2006
@@ -0,0 +1,120 @@
+/**
+ *
+ * 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.openwire.transport;
+
+import java.io.IOException;
+import org.apache.geronimo.openwire.command.Command;
+import org.apache.geronimo.openwire.command.Response;
+
+/**
+ * @version $Revision$
+ */
+public class TransportFilter implements TransportListener,Transport{
+    final protected Transport next;
+    protected TransportListener transportListener;
+
+    public TransportFilter(Transport next){
+        this.next=next;
+    }
+
+    public TransportListener getTransportListener(){
+        return transportListener;
+    }
+
+    public void setTransportListener(TransportListener channelListener){
+        this.transportListener=channelListener;
+        if(channelListener==null)
+            next.setTransportListener(null);
+        else
+            next.setTransportListener(this);
+    }
+
+    /**
+     * @see org.apache.geronimo.openwire.Service#start()
+     * @throws IOException
+     *             if the next channel has not been set.
+     */
+    public void start() throws Exception{
+        if(next==null)
+            throw new IOException("The next channel has not been set.");
+        if(transportListener==null)
+            throw new IOException("The command listener has not been set.");
+        next.start();
+    }
+
+    /**
+     * @see org.apache.geronimo.openwire.Service#stop()
+     */
+    public void stop() throws Exception{
+        next.stop();
+    }
+
+    public void onCommand(Command command){
+        transportListener.onCommand(command);
+    }
+
+    /**
+     * @return Returns the next.
+     */
+    public Transport getNext(){
+        return next;
+    }
+
+    public String toString(){
+        return next.toString();
+    }
+
+    public void oneway(Command command) throws IOException{
+        next.oneway(command);
+    }
+
+    public FutureResponse asyncRequest(Command command,ResponseCallback responseCallback) throws IOException{
+        return next.asyncRequest(command,null);
+    }
+
+    public Response request(Command command) throws IOException{
+        return next.request(command);
+    }
+
+    public Response request(Command command,int timeout) throws IOException{
+        return next.request(command,timeout);
+    }
+
+    public void onException(IOException error){
+        transportListener.onException(error);
+    }
+
+    public void transportInterupted(){
+        transportListener.transportInterupted();
+    }
+
+    public void transportResumed(){
+        transportListener.transportResumed();
+    }
+
+    public Object narrow(Class target){
+        if(target.isAssignableFrom(getClass())){
+            return this;
+        }
+        return next.narrow(target);
+    }
+
+    public String getRemoteAddress() {
+        return next.getRemoteAddress();
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFilter.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFilter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportListener.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportListener.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportListener.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportListener.java Thu Sep 14 21:57:24 2006
@@ -0,0 +1,55 @@
+/**
+ *
+ * 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.openwire.transport;
+
+import java.io.IOException;
+
+import org.apache.geronimo.openwire.command.Command;
+
+/**
+ * An asynchronous listener of commands
+ *
+ * @version $Revision$
+ */
+public interface TransportListener {
+
+    /**
+     * called to process a command
+     * @param command
+     */
+    public void onCommand(Command command);
+    /**
+     * An unrecoverable exception has occured on the transport
+     * @param error
+     */
+    public void onException(IOException error);
+
+    /**
+     * The transport has suffered an interuption from which it hopes to recover
+     *
+     */
+    public void transportInterupted();
+
+
+    /**
+     * The transport has resumed after an interuption
+     *
+     */
+    public void transportResumed();
+
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportListener.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportListener.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportListener.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportLogger.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportLogger.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportLogger.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportLogger.java Thu Sep 14 21:57:24 2006
@@ -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.openwire.transport;
+
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.openwire.command.Response;
+import org.apache.geronimo.openwire.command.Command;
+
+
+/**
+ * @version $Revision$
+ */
+public class TransportLogger extends TransportFilter {
+
+    private static int lastId=0;
+    private final Log log;
+
+    public TransportLogger(Transport next) {
+        this( next, LogFactory.getLog(TransportLogger.class.getName()+".Connection:"+getNextId()));
+    }
+
+    synchronized private static int getNextId() {
+        return ++lastId;
+    }
+
+    public TransportLogger(Transport next, Log log) {
+        super(next);
+        this.log = log;
+    }
+
+    public Response request(Command command) throws IOException {
+        log.debug("SENDING REQUEST: "+command);
+        Response rc = super.request(command);
+        log.debug("GOT RESPONSE: "+rc);
+        return rc;
+    }
+
+    public Response request(Command command, int timeout) throws IOException {
+        log.debug("SENDING REQUEST: "+command);
+        Response rc = super.request(command, timeout);
+        log.debug("GOT RESPONSE: "+rc);
+        return rc;
+    }
+
+    public FutureResponse asyncRequest(Command command, ResponseCallback responseCallback) throws IOException {
+        log.debug("SENDING ASNYC REQUEST: "+command);
+        FutureResponse rc = next.asyncRequest(command, responseCallback);
+        return rc;
+    }
+
+    public void oneway(Command command) throws IOException {
+        if( log.isDebugEnabled() ) {
+            log.debug("SENDING: "+command);
+        }
+        next.oneway(command);
+    }
+
+    public void onCommand(Command command) {
+        if( log.isDebugEnabled() ) {
+            if( command.getFrom()!=null ) {
+                log.debug("RECEIVED: from: "+ command.getFrom() + " : " + command);
+            } else {
+                log.debug("RECEIVED: " + command);
+            }
+        }
+        getTransportListener().onCommand(command);
+    }
+
+    public void onException(IOException error) {
+        if( log.isDebugEnabled() ) {
+            log.debug("RECEIVED Exception: "+error, error);
+        }
+        getTransportListener().onException(error);
+    }
+
+    public String toString() {
+        return next.toString();
+    }
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportLogger.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportLogger.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportLogger.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServer.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServer.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServer.java Thu Sep 14 21:57:24 2006
@@ -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.openwire.transport;
+
+import java.net.InetSocketAddress;
+import java.net.URI;
+
+import org.apache.activemq.command.BrokerInfo;
+import org.apache.geronimo.openwire.Service;
+
+
+/**
+ * A TransportServer asynchronously accepts {@see Transport} objects
+ * and then delivers those objects to a {@see TransportAcceptListener}.
+ * 
+ * @version $Revision$
+ */
+public interface TransportServer extends Service {
+
+    /**
+     * Registers an {@see TransportAcceptListener} which is notified of accepted channels.
+     *
+     * @param acceptListener
+     */
+    public void setAcceptListener(TransportAcceptListener acceptListener);
+
+    /**
+     * Associates a broker info with the transport server so that the transport can do
+     * discovery advertisements of the broker.
+     * 
+     * @param brokerInfo
+     */
+    public void setBrokerInfo(BrokerInfo brokerInfo);
+
+    public URI getConnectURI();
+
+
+    /**
+     * @return The socket address that this transport is accepting connections on or null if 
+     * this does not or is not currently accepting connections on a socket.
+     */
+    public InetSocketAddress getSocketAddress();
+
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServer.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

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

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerFilter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerFilter.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerFilter.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerFilter.java Thu Sep 14 21:57:24 2006
@@ -0,0 +1,60 @@
+/**
+ *
+ * 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.openwire.transport;
+
+import java.net.InetSocketAddress;
+import java.net.URI;
+
+import org.apache.activemq.command.BrokerInfo;
+
+public class TransportServerFilter implements TransportServer {
+
+    protected final TransportServer next;
+    
+    /**
+     * @param next
+     */
+    public TransportServerFilter(TransportServer next) {
+        this.next = next;
+    }
+
+    public URI getConnectURI() {
+        return next.getConnectURI();
+    }
+
+    public void setAcceptListener(TransportAcceptListener acceptListener) {
+        next.setAcceptListener(acceptListener);
+    }
+
+    public void setBrokerInfo(BrokerInfo brokerInfo) {
+        next.setBrokerInfo(brokerInfo);
+    }
+
+    public void start() throws Exception {
+        next.start();
+    }
+
+    public void stop() throws Exception {
+        next.stop();
+    }
+
+    public InetSocketAddress getSocketAddress() {
+        return next.getSocketAddress();
+    }
+    
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerFilter.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerFilter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerSupport.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerSupport.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerSupport.java Thu Sep 14 21:57:24 2006
@@ -0,0 +1,87 @@
+/**
+ *
+ * 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.openwire.transport;
+
+import org.apache.geronimo.openwire.util.ServiceSupport;
+
+import java.net.URI;
+
+/**
+ * A useful base class for implementations of {@link TransportServer}
+ * 
+ * @version $Revision$
+ */
+public abstract class TransportServerSupport extends ServiceSupport implements TransportServer {
+
+    private URI connectURI;
+	private URI bindLocation;
+    private TransportAcceptListener acceptListener;
+
+    public TransportServerSupport() {
+    }
+
+    public TransportServerSupport(URI location) {
+        this.connectURI = location;
+        this.bindLocation = location;
+    }
+
+    /**
+     * @return Returns the acceptListener.
+     */
+    public TransportAcceptListener getAcceptListener() {
+        return acceptListener;
+    }
+
+    /**
+     * Registers an accept listener
+     * 
+     * @param acceptListener
+     */
+    public void setAcceptListener(TransportAcceptListener acceptListener) {
+        this.acceptListener = acceptListener;
+    }
+
+    /**
+     * @return Returns the location.
+     */
+    public URI getConnectURI() {
+        return connectURI;
+    }
+
+    /**
+     * @param location
+     *            The location to set.
+     */
+    public void setConnectURI(URI location) {
+        this.connectURI = location;
+    }
+
+    protected void onAcceptError(Exception e) {
+        if (acceptListener != null) {
+            acceptListener.onAcceptError(e);
+        }
+    }
+
+	public URI getBindLocation() {
+		return bindLocation;
+	}
+
+	public void setBindLocation(URI bindLocation) {
+		this.bindLocation = bindLocation;
+	}
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerThreadSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerThreadSupport.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerThreadSupport.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerThreadSupport.java Thu Sep 14 21:57:24 2006
@@ -0,0 +1,85 @@
+/**
+ *
+ * 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.openwire.transport;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.openwire.util.ServiceStopper;
+import org.apache.geronimo.openwire.ThreadPriorities;
+
+import java.net.URI;
+
+/**
+ * A useful base class for implementations of {@link TransportServer} which uses
+ * a background thread to accept new connections.
+ * 
+ * @version $Revision$
+ */
+public abstract class TransportServerThreadSupport extends TransportServerSupport implements Runnable {
+    private static final Log log = LogFactory.getLog(TransportServerThreadSupport.class);
+
+    private boolean daemon = true;
+    private boolean joinOnStop = true;
+    private Thread runner;
+
+    public TransportServerThreadSupport() {
+    }
+
+    public TransportServerThreadSupport(URI location) {
+        super(location);
+    }
+
+    public boolean isDaemon() {
+        return daemon;
+    }
+
+    /**
+     * Sets whether the background read thread is a daemon thread or not
+     */
+    public void setDaemon(boolean daemon) {
+        this.daemon = daemon;
+    }
+
+    
+    public boolean isJoinOnStop() {
+        return joinOnStop;
+    }
+
+    /**
+     * Sets whether the background read thread is joined with (waited for) on a stop
+     */
+    public void setJoinOnStop(boolean joinOnStop) {
+        this.joinOnStop = joinOnStop;
+    }
+
+    protected void doStart() throws Exception {
+        log.info("Listening for connections at: " + getConnectURI());
+        runner = new Thread(this, "ActiveMQ Transport Server: "+toString());
+        runner.setDaemon(daemon);
+        runner.setPriority(ThreadPriorities.MANAGEMENT);
+        runner.start();
+    }
+
+    protected void doStop(ServiceStopper stopper) throws Exception {
+        if (runner != null && joinOnStop) {
+            runner.join();
+            runner = null;
+        }
+    }
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerThreadSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerThreadSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportServerThreadSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportSupport.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportSupport.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportSupport.java Thu Sep 14 21:57:24 2006
@@ -0,0 +1,109 @@
+/**
+ *
+ * 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.openwire.transport;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.openwire.util.ServiceSupport;
+import org.apache.geronimo.openwire.command.Command;
+import org.apache.geronimo.openwire.command.Response;
+
+import java.io.IOException;
+
+/**
+ * A useful base class for transport implementations.
+ * 
+ * @version $Revision$
+ */
+public abstract class TransportSupport extends ServiceSupport implements Transport {
+    private static final Log log = LogFactory.getLog(TransportSupport.class);
+
+    TransportListener transportListener;
+
+    /**
+     * Returns the current transport listener
+     */
+    public TransportListener getTransportListener() {
+        return transportListener;
+    }
+
+    /**
+     * Registers an inbound command listener
+     * 
+     * @param commandListener
+     */
+    public void setTransportListener(TransportListener commandListener) {
+        this.transportListener = commandListener;
+    }
+
+    /**
+     * narrow acceptance
+     * 
+     * @param target
+     * @return 'this' if assignable
+     */
+    public Object narrow(Class target) {
+        boolean assignableFrom = target.isAssignableFrom(getClass());
+        if (assignableFrom) {
+            return this;
+        }
+        return null;
+    }
+
+    public FutureResponse asyncRequest(Command command, ResponseCallback responseCallback) throws IOException {
+        throw new AssertionError("Unsupported Method");
+    }
+
+    public Response request(Command command) throws IOException {
+        throw new AssertionError("Unsupported Method");
+    }
+    
+    public Response request(Command command,int timeout) throws IOException {
+        throw new AssertionError("Unsupported Method");
+    }
+
+    /**
+     * Process the inbound command
+     */
+    public void doConsume(Command command) {
+        if (command != null) {
+            if (transportListener != null) {
+                transportListener.onCommand(command);
+            }
+            else {
+                log.error("No transportListener available to process inbound command: " + command);
+            }
+        }
+    }
+
+    /**
+     * Passes any IO exceptions into the transport listener
+     */
+    public void onException(IOException e) {
+        if (transportListener != null) {
+            transportListener.onException(e);
+        }
+    }
+
+    protected void checkStarted(Command command) throws IOException {
+        if (!isStarted()) {
+			throw new IOException("The transport is not running.");
+        }
+    }
+
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportThreadSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportThreadSupport.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportThreadSupport.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportThreadSupport.java Thu Sep 14 21:57:24 2006
@@ -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.openwire.transport;
+
+
+
+/**
+ * A useful base class for a transport implementation which has a background
+ * reading thread.
+ * 
+ * @version $Revision$
+ */
+public abstract class TransportThreadSupport extends TransportSupport implements Runnable {
+
+    private boolean daemon = false;
+    private Thread runner;
+
+    public boolean isDaemon() {
+        return daemon;
+    }
+
+    public void setDaemon(boolean daemon) {
+        this.daemon = daemon;
+    }
+
+    protected void doStart() throws Exception {
+        runner = new Thread(this, "ActiveMQ Transport: "+toString());
+        runner.setDaemon(daemon);
+        runner.start();
+    }
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportThreadSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportThreadSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/TransportThreadSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/WireFormatNegotiator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/WireFormatNegotiator.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/WireFormatNegotiator.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/WireFormatNegotiator.java Thu Sep 14 21:57:24 2006
@@ -0,0 +1,152 @@
+/**
+ *
+ * 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.openwire.transport;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+
+import org.apache.activemq.openwire.OpenWireFormat;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.openwire.command.WireFormatInfo;
+import org.apache.geronimo.openwire.command.Command;
+
+import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
+import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
+import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
+
+
+public class WireFormatNegotiator extends TransportFilter {
+
+    private static final Log log = LogFactory.getLog(WireFormatNegotiator.class);
+    
+    private OpenWireFormat wireFormat;
+    private final int minimumVersion;
+    private long negotiateTimeout=15000;
+    
+    private final AtomicBoolean firstStart=new AtomicBoolean(true);
+    private final CountDownLatch readyCountDownLatch = new CountDownLatch(1);
+    private final CountDownLatch wireInfoSentDownLatch = new CountDownLatch(1);
+    
+    /**
+     * Negotiator
+     * 
+     * @param next
+     * @param wireFormat
+     */
+    public WireFormatNegotiator(Transport next, OpenWireFormat wireFormat, int minimumVersion) {
+        super(next);
+        this.wireFormat = wireFormat;
+        this.minimumVersion = minimumVersion;
+    }
+
+    
+    public void start() throws Exception {
+        super.start();
+        if( firstStart.compareAndSet(true, false) ) {
+        	try {
+        		WireFormatInfo info = wireFormat.getPreferedWireFormatInfo();
+                if (log.isDebugEnabled()) {
+                    log.debug("Sending: " + info);
+                }
+	            sendWireFormat(info);
+        	} finally {
+        		wireInfoSentDownLatch.countDown();
+        	}
+        }
+    }
+    
+    public void stop() throws Exception {
+    	super.stop();
+        readyCountDownLatch.countDown();
+    }
+    
+    public void oneway(Command command) throws IOException {
+        try {
+            if( !readyCountDownLatch.await(negotiateTimeout, TimeUnit.MILLISECONDS) ) 
+            	throw new IOException("Wire format negociation timeout: peer did not send his wire format.");
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            throw new InterruptedIOException();
+        }
+        super.oneway(command);
+    }
+
+ 
+    public void onCommand(Command command) {
+        if( command.isWireFormatInfo() ) {
+            WireFormatInfo info = (WireFormatInfo) command;
+            if (log.isDebugEnabled()) {
+                log.debug("Received WireFormat: " + info);
+            }
+            
+            try {
+                wireInfoSentDownLatch.await();
+                
+                if (log.isDebugEnabled()) {
+                    log.debug(this + " before negotiation: " + wireFormat);
+                }
+                if( !info.isValid() ) {
+                    onException(new IOException("Remote wire format magic is invalid"));
+                } else if( info.getVersion() < minimumVersion ) {
+                    onException(new IOException("Remote wire format ("+info.getVersion()+") is lower the minimum version required ("+minimumVersion+")"));
+                }
+                
+                wireFormat.renegotiateWireFormat(info);
+                
+                if (log.isDebugEnabled()) {
+                    log.debug(this + " after negotiation: " + wireFormat);
+                }
+	
+            } catch (IOException e) {
+                onException(e);
+            } catch (InterruptedException e) {
+                onException((IOException) new InterruptedIOException().initCause(e));
+			}
+            readyCountDownLatch.countDown();
+            onWireFormatNegotiated(info);
+        }
+        getTransportListener().onCommand(command);
+    }
+
+
+    public void onException(IOException error) {
+        readyCountDownLatch.countDown();
+    	super.onException(error);
+    }
+    
+    public String toString() {
+        return next.toString();
+    }
+
+    protected void sendWireFormat(WireFormatInfo info) throws IOException {
+        next.oneway(info);
+    }
+    
+    protected void onWireFormatNegotiated(WireFormatInfo info) {
+    }
+
+
+	public long getNegotiateTimeout() {
+		return negotiateTimeout;
+	}
+
+	public void setNegotiateTimeout(long negotiateTimeout) {
+		this.negotiateTimeout = negotiateTimeout;
+	}
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/WireFormatNegotiator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/WireFormatNegotiator.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/WireFormatNegotiator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/WireFormatNegotiator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/ResponseHolder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/ResponseHolder.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/ResponseHolder.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/ResponseHolder.java Thu Sep 14 21:57:24 2006
@@ -0,0 +1,89 @@
+/**
+ *
+ * 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.openwire.transport.tcp;
+
+import org.apache.activemq.command.Response;
+
+/**
+ * ResponseHolder utility
+ * 
+ * @version $Revision$
+ */
+public class ResponseHolder {
+    protected Response response;
+    protected Object lock = new Object();
+    protected boolean notified;
+
+    /**
+     * Construct a receipt holder
+     */
+    public ResponseHolder() {
+    }
+
+    /**
+     * Set the Response for this holder
+     *
+     * @param r
+     */
+    public void setResponse(Response r) {
+        synchronized (lock) {
+            this.response = r;
+            notified = true;
+            lock.notify();
+        }
+    }
+
+    /**
+     * Get the Response
+     * 
+     * @return the Response or null if it is closed
+     */
+    public Response getResponse() {
+        return getResponse(0);
+    }
+
+    /**
+     * wait upto <Code>timeout</Code> timeout ms to get a receipt
+     *
+     * @param timeout
+     * @return
+     */
+    public Response getResponse(int timeout) {
+        synchronized (lock) {
+            if (!notified) {
+                try {
+                    lock.wait(timeout);
+                }
+                catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
+                }
+            }
+        }
+        return this.response;
+    }
+
+    /**
+     * close this holder
+     */
+    public void close() {
+        synchronized (lock) {
+            notified = true;
+            lock.notifyAll();
+        }
+    }
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/ResponseHolder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/ResponseHolder.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/ResponseHolder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/ResponseHolder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/SslTransportFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/SslTransportFactory.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/SslTransportFactory.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/SslTransportFactory.java Thu Sep 14 21:57:24 2006
@@ -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.openwire.transport.tcp;
+
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+
+/**
+ * An implementation of the TCP Transport using SSL
+ * 
+ * @version $Revision$
+ */
+public class SslTransportFactory extends TcpTransportFactory {
+
+    public SslTransportFactory() {
+    }
+
+    protected ServerSocketFactory createServerSocketFactory() {
+        return SSLServerSocketFactory.getDefault();
+    }
+
+    protected SocketFactory createSocketFactory() {
+        return SSLSocketFactory.getDefault();
+    }
+    
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/SslTransportFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/SslTransportFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/SslTransportFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/TcpBufferedInputStream.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/TcpBufferedInputStream.java?view=auto&rev=446519
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/TcpBufferedInputStream.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/TcpBufferedInputStream.java Thu Sep 14 21:57:24 2006
@@ -0,0 +1,126 @@
+/**
+ *
+ * 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.openwire.transport.tcp;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+/**
+ * An optimized buffered input stream for Tcp
+ * 
+ * @version $Revision$
+ */
+public class TcpBufferedInputStream extends FilterInputStream{
+    private static final int DEFAULT_BUFFER_SIZE=8192;
+    protected byte internalBuffer[];
+    protected int count;
+    protected int position;
+
+    public TcpBufferedInputStream(InputStream in){
+        this(in,DEFAULT_BUFFER_SIZE);
+    }
+
+    public TcpBufferedInputStream(InputStream in,int size){
+        super(in);
+        if(size<=0){
+            throw new IllegalArgumentException("Buffer size <= 0");
+        }
+        internalBuffer=new byte[size];
+    }
+
+    private void fill() throws IOException{
+        byte[] buffer=internalBuffer;
+        count=position=0;
+        int n=in.read(buffer,position,buffer.length-position);
+        if(n>0)
+            count=n+position;
+    }
+
+    public int read() throws IOException{
+        if(position>=count){
+            fill();
+            if(position>=count)
+                return -1;
+        }
+        return internalBuffer[position++]&0xff;
+    }
+
+    private int readStream(byte[] b,int off,int len) throws IOException{
+        int avail=count-position;
+        if(avail<=0){
+            if(len>=internalBuffer.length){
+                return in.read(b,off,len);
+            }
+            fill();
+            avail=count-position;
+            if(avail<=0)
+                return -1;
+        }
+        int cnt=(avail<len)?avail:len;
+        System.arraycopy(internalBuffer,position,b,off,cnt);
+        position+=cnt;
+        return cnt;
+    }
+
+    public int read(byte b[],int off,int len) throws IOException{
+        if((off|len|(off+len)|(b.length-(off+len)))<0){
+            throw new IndexOutOfBoundsException();
+        }else if(len==0){
+            return 0;
+        }
+        int n=0;
+        for(;;){
+            int nread=readStream(b,off+n,len-n);
+            if(nread<=0)
+                return (n==0)?nread:n;
+            n+=nread;
+            if(n>=len)
+                return n;
+            // if not closed but no bytes available, return
+            InputStream input=in;
+            if(input!=null&&input.available()<=0)
+                return n;
+        }
+    }
+
+    public long skip(long n) throws IOException{
+        if(n<=0){
+            return 0;
+        }
+        long avail=count-position;
+        if(avail<=0){
+            return in.skip(n);
+        }
+        long skipped=(avail<n)?avail:n;
+        position+=skipped;
+        return skipped;
+    }
+
+    public int available() throws IOException{
+        return in.available()+(count-position);
+    }
+
+    public boolean markSupported(){
+        return false;
+    }
+
+    public void close() throws IOException{
+        if(in!=null)
+            in.close();
+    }
+}

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/TcpBufferedInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/TcpBufferedInputStream.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/TcpBufferedInputStream.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/tcp/TcpBufferedInputStream.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message