In this patch you will find several new
classes/packages that will allow geronimo containers
to be access remotely.  A quick descriptions of what
is in each new package:

org.apache.geronimo.proxy
=========================
- Holds some Simple implementations of Component,
Container, RPCContainer.  These implementations do not
depend on JMX.  These will be useful if you are
creating client side containers.
- Implements a ProxyContainer that is invoked via a
Dyanamic Proxy.  This lets you create simple client
side containers with and interceptor stack that could
potentially just be calling a POJO.

org.apache.geronimo.remoting
============================
- Holds a bunch of interceptors related to remoting. 
Interceptors that Marshall Invocations, Interceptors
that demarshal Invocation, Interceptors that change
the next interceptor to force Marshalling or to avoid
Marshalling.  You get the Idea.  
- It also defines the interface of a transport
interceptor.

org.apache.geronimo.remoting.transport
======================================
- Provides a couple of transport interceptors and the
defines what a �transport� is.  
- A transport is un-aware of the �Invocation�.  You
could use it to transport other types of messages.
- The transport is responsible for: 
  - providing the MarshalledObject implementation that
is used for the transport.  Different transports (like
SOAP) will want to marshal their data differently.  
  - Moving a marshalled request or datagram to a
target URI.  
- java.net.URI is used to define a the transport
destination.

org.apache.geronimo.remoting.transport.async
============================================
- An implementation of a remoting transport.
- NIO Socket Based.
- Supports Asynchronous requests.  A request over a
socket does not block the socket from being used to
send additional requests.
- Establishes connection Pools to remote servers.  If
all sockets are in use additional sockets get created.
- Inbound sockets and outbound sockets to and from the
same remote server go into the same socket pool.  A
new request can go over inbound socket!
- Since requests can be sent over and inbound socket,
the server can do callbacks to a client established
socket that does not have access to bind a
ServerSocket.  (think doing a callback to an Applet)
- Supports doing either Blocking socket calls or
NonBlocking socket calls.  Right now It is defaulted
to NonBlocking socket calls.  This allows you to
reduce the number so socket �reader� threads.  You can
go down from needing n reader threads per n sockets
down to 1 reader thread per n sockets. (Helps
scalability).
======================


The current patch as it stands will build OK but the
unit tests for the remoting will fail because the mock
app that it tests against is not built by MAVEN.  I�m
not a MAVEN guru so I�m not going to try to figure it
out.  I�m sure somebody out there can give me a hand
with this.  The mock app has to be compiled to a
location outside of the CLASSPATH that is used by
junit.  The remoting Tests will create URLClassLoaders
to load the mock app to simulate 2 applications and
the marshalling issues they face when they try to
communicate with each other.


I hope this patch can be integrated soon into CVS!

Regards,
Hiram Chirino

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/log4j.properties 
incubator-geronimo/modules/core/src/java/log4j.properties
7c7
< log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
---
> log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%-40t] 
> [%c{1}] %m%n
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/common/AbstractRPCContainer.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/common/AbstractRPCContainer.java
3d2
< import java.util.Iterator;
6d4
< import java.util.ListIterator;
7a6
> 
74,75c73,74
< 
<         super.addComponent(interceptor);
---
>         if( interceptor instanceof Component)
>             super.addComponent((Component) interceptor);
90a90,93
>     /**
>      * @deprecated
>      * @see 
> org.apache.geronimo.common.RPCContainer#getPluginObject(java.lang.String)
>      */
94a98,101
>     /**
>      * @deprecated
>      * @see 
> org.apache.geronimo.common.RPCContainer#putPluginObject(java.lang.String, 
> java.lang.Object)
>      */
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/common/Component.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/common/Component.java
57d56
< import org.apache.geronimo.management.StateManageable;
66c65
< public interface Component extends StateManageable
---
> public interface Component 
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/common/Interceptor.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/common/Interceptor.java
65c65
< public interface Interceptor extends Component {
---
> public interface Interceptor {
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/common/SimpleInvocation.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/common/SimpleInvocation.java
57a58,61
> import java.io.Externalizable;
> import java.io.IOException;
> import java.io.ObjectInput;
> import java.io.ObjectOutput;
67c71,72
< public class SimpleInvocation implements Invocation {
---
> public class SimpleInvocation implements Invocation, Externalizable {
>     
93a99,115
>     }
> 
>     /* (non-Javadoc)
>      * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
>      */
>     public void writeExternal(ObjectOutput out) throws IOException {
>         out.writeObject(marshalMap);
>         out.writeObject(asIsMap);        
>     }
> 
>     /* (non-Javadoc)
>      * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
>      */
>     public void readExternal(ObjectInput in) throws IOException, 
> ClassNotFoundException {
>         marshalMap = (Map) in.readObject();
>         asIsMap = (Map) in.readObject();
>         transientMap = new HashMap();        
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/common/SimpleInvocationResult.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/common/SimpleInvocationResult.java
57a58,59
> import java.io.Serializable;
> 
64c66
< public class SimpleInvocationResult implements InvocationResult {
---
> public class SimpleInvocationResult implements InvocationResult, Serializable 
> {
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/core/util/ClassUtil.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/core/util/ClassUtil.java
57a58,59
> import java.io.IOException;
> import java.lang.reflect.Array;
80a83,94
>     static HashMap vmPrimitives = new HashMap();
>     static {
>         primitives.put("B", byte.class);
>         primitives.put("C", char.class);
>         primitives.put("D", double.class);
>         primitives.put("F", float.class);
>         primitives.put("I", int.class);
>         primitives.put("J", long.class);
>         primitives.put("S", short.class);
>         primitives.put("Z", boolean.class);
>     }
> 
91a106,139
>     
> 
>     /**
>      * @see java.io.ObjectInputStream#resolveClass(java.io.ObjectStreamClass)
>      */
>     static public Class resolveObjectStreamClass(ClassLoader loader, String 
> className) throws IOException, ClassNotFoundException {
>         
>         // Is it a normal class??
>         if (!className.startsWith("[")) 
>             return loader.loadClass(className);        
>         
>         // Is it an array class??
>         Class type;             
>         int arrayDimension = className.lastIndexOf('[')+1;             
> 
>         // Is the array type a primitive?
>         if (className.charAt(arrayDimension) != 'L') {
>             if (className.length() != arrayDimension + 1) 
>                 throw new ClassNotFoundException(className);                
>             type = (Class) 
> vmPrimitives.get(className.substring(arrayDimension,1));
>         } else {           
>             String cn = className.substring(arrayDimension + 1, 
> className.length() - 1);
>             type = loader.loadClass(cn);
>         }
>         
>         // This kinda sucks.. there must be an easier way at getting
>         // to Class of an array.. 
>         int dim[] = new int[arrayDimension];
>         for (int i = 0; i < arrayDimension; i++) 
>             dim[i] = 0;        
>         Object o = Array.newInstance(type, dim);
>         return o.getClass();
>     }
>     
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/ejb/context/TransactionInterceptor.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/ejb/context/TransactionInterceptor.java
74c74
<     private Interceptor transactionInterceptor;
---
>     private ExecutionContextInterceptor transactionInterceptor;
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/proxy/ProxyContainer.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/proxy/ProxyContainer.java
0a1,101
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.proxy;
> 
> import java.lang.reflect.InvocationHandler;
> import java.lang.reflect.Method;
> import java.lang.reflect.Proxy;
> 
> import org.apache.geronimo.common.Invocation;
> import org.apache.geronimo.common.InvocationResult;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class ProxyContainer extends SimpleRPCContainer implements 
> InvocationHandler {
> 
>     /* (non-Javadoc)
>      * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, 
> java.lang.reflect.Method, java.lang.Object[])
>      */
>     public Object invoke(Object proxy, Method method, Object[] args) throws 
> Throwable {
>         Invocation invocation = new ProxyInvocation();
>         ProxyInvocation.putMethod(invocation, method);
>         ProxyInvocation.putArguments(invocation, args);
>         InvocationResult result = this.invoke(invocation);
>         return result.getResult();
>     }
> 
>     static public Object createProxy(Object target) throws Exception {
>         ProxyContainer container = new ProxyContainer();
>         container.addInterceptor(new ReflexiveInterceptor(target));
>         return container.createProxy(target.getClass());
>     }
> 
>     public Object createProxy(Class likeClass) {
>         return createProxy(likeClass.getClassLoader(), 
> likeClass.getInterfaces());
>     }
> 
>     public Object createProxy(ClassLoader cl, Class[] interfaces) {
>         return Proxy.newProxyInstance(cl, interfaces, this);
>     }
> 
>     public static ProxyContainer getContainer(Object proxy) {
>         if (Proxy.isProxyClass(proxy.getClass()))
>             throw new IllegalArgumentException("Not a proxy.");
>         return (ProxyContainer) Proxy.getInvocationHandler(proxy);
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/proxy/ProxyInvocation.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/proxy/ProxyInvocation.java
0a1,116
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.proxy;
> 
> import java.io.IOException;
> import java.io.ObjectInput;
> import java.io.ObjectOutput;
> import java.lang.reflect.Method;
> 
> import org.apache.geronimo.common.Invocation;
> import org.apache.geronimo.common.SimpleInvocation;
> import org.apache.geronimo.remoting.*;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class ProxyInvocation extends SimpleInvocation {
> 
>     Method method;
>     Object args[];
>     Object proxy;
> 
>     /* (non-Javadoc)
>      * @see 
> org.apache.geronimo.common.SimpleInvocation#writeExternal(java.io.ObjectOutput)
>      */
>     public void writeExternal(ObjectOutput out) throws IOException {
>         super.writeExternal(out);
>         out.writeObject(args);
>         out.writeObject(new MarshalledMethod(method));
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.common.SimpleInvocation#readExternal(java.io.ObjectInput)
>      */
>     public void readExternal(ObjectInput in) throws IOException, 
> ClassNotFoundException {
>         super.readExternal(in);
>         args = (Object[]) in.readObject();
>         method = ((MarshalledMethod) in.readObject()).getMethod();
>     }
> 
>     public static Method getMethod(Invocation invocation) {
>         return (Method) ((ProxyInvocation) invocation).method;
>     }
>     public static void putMethod(Invocation invocation, Method method) {
>         ((ProxyInvocation) invocation).method = method;
>     }
> 
>     public static Object getProxy(Invocation invocation) {
>         return ((ProxyInvocation) invocation).proxy;
>     }
>     public static void putProxy(Invocation invocation, Object proxy) {
>         ((ProxyInvocation) invocation).proxy = proxy;
>     }
> 
>     public static Object[] getArguments(Invocation invocation) {
>         return ((ProxyInvocation) invocation).args;
>     }
> 
>     public static void putArguments(Invocation invocation, Object[] 
> arguments) {
>         ((ProxyInvocation) invocation).args = arguments;
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/proxy/ReflexiveInterceptor.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/proxy/ReflexiveInterceptor.java
0a1,100
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.proxy;
> 
> import java.lang.reflect.InvocationTargetException;
> import java.lang.reflect.Method;
> 
> import org.apache.geronimo.common.AbstractInterceptor;
> import org.apache.geronimo.common.Invocation;
> import org.apache.geronimo.common.InvocationResult;
> import org.apache.geronimo.common.SimpleInvocationResult;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> final public class ReflexiveInterceptor extends AbstractInterceptor {
> 
>     Object target;
> 
>     public ReflexiveInterceptor(Object target) {
>         this.target = target;
>     }
> 
>     /* (non-Javadoc)
>      * @see 
> org.apache.geronimo.common.AbstractInterceptor#invoke(org.apache.geronimo.common.Invocation)
>      */
>     public InvocationResult invoke(Invocation invocation) throws Exception {
>         try {
> 
>             Method m = ProxyInvocation.getMethod(invocation);
>             Object args[] = ProxyInvocation.getArguments(invocation);
>             Object rc = m.invoke(target, args);
>             return new SimpleInvocationResult(rc);
> 
>         } catch (InvocationTargetException e) {
>             Throwable t = e.getTargetException();
>             if (t instanceof Exception) {
>                 throw (Exception) t;
>             } else if (t instanceof Error) {
>                 throw (Error) t;
>             } else {
>                 throw new Error("Unexpected Throwable", t);
>             }
>         }
>     }
> 
> }
\ No newline at end of file
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/proxy/SimpleComponent.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/proxy/SimpleComponent.java
0a1,100
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.proxy;
> 
> import java.io.Serializable;
> 
> import org.apache.geronimo.common.Component;
> import org.apache.geronimo.common.Container;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class SimpleComponent implements Component, Serializable {
> 
>     private Container container;
>     private String objectName;
> 
>     /**
>      * @see org.apache.geronimo.common.Component#getContainer()
>      */
>     public Container getContainer() {
>         return container;
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.common.Component#setContainer(org.apache.geronimo.common.Container)
>      */
>     public void setContainer(Container container) throws 
> IllegalStateException, IllegalArgumentException {
>         this.container = container;
> 
>     }
> 
>     /**
>      * @see org.apache.geronimo.common.Component#getObjectName()
>      */
>     public String getObjectName() {
>         return objectName;
>     }
> 
>     /**
>      * @param objectName
>      */
>     public void setObjectName(String objectName) {
>         this.objectName = objectName;
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/proxy/SimpleContainer.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/proxy/SimpleContainer.java
0a1,100
> 
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.proxy;
> 
> import java.util.ArrayList;
> import java.util.Collections;
> import java.util.List;
> 
> import org.apache.geronimo.common.Component;
> import org.apache.geronimo.common.Container;
> import org.apache.geronimo.common.NullArgumentException;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class SimpleContainer extends SimpleComponent implements Container {
> 
>     private ArrayList components = new ArrayList();
> 
>     /**
>      * @see 
> org.apache.geronimo.common.Container#addComponent(org.apache.geronimo.common.Component)
>      */
>     public void addComponent(Component component) {
>         if (component == null)
>             throw new NullArgumentException("component");
> 
>         components.add(component);
>     }
> 
>     /**
>      * @see org.apache.geronimo.common.Container#getComponents()
>      */
>     public List getComponents() {
>         return Collections.unmodifiableList(components);
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.common.Container#removeComponent(org.apache.geronimo.common.Component)
>      */
>     public void removeComponent(Component component) throws Exception {
>         if (component == null)
>             throw new NullArgumentException("component");
>         components.remove(component);
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/proxy/SimpleRPCContainer.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/proxy/SimpleRPCContainer.java
0a1,127
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.proxy;
> 
> import java.util.LinkedHashMap;
> import java.util.LinkedList;
> import java.util.Map;
> 
> import javax.management.ObjectName;
> 
> import org.apache.geronimo.common.Component;
> import org.apache.geronimo.common.Interceptor;
> import org.apache.geronimo.common.Invocation;
> import org.apache.geronimo.common.InvocationResult;
> import org.apache.geronimo.common.RPCContainer;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class SimpleRPCContainer extends SimpleContainer implements 
> RPCContainer {
> 
>     private final Map plugins = new LinkedHashMap();
>     private final Map pluginObjects = new LinkedHashMap();
>     private final LinkedList interceptors = new LinkedList();
>     private Interceptor firstInterceptor;
> 
>     /**
>     * @see 
> org.apache.geronimo.common.RPCContainer#invoke(org.apache.geronimo.common.Invocation)
>     */
>     public final InvocationResult invoke(Invocation invocation) throws 
> Exception {
>         return firstInterceptor.invoke(invocation);
>     }
> 
>     /**
>      * Add an Interceptor to the end of the Interceptor list.
>      *
>      * @param interceptor
>      */
>     public final void addInterceptor(Interceptor interceptor) {
>         if (firstInterceptor == null) {
>             firstInterceptor = interceptor;
>             interceptors.addLast(interceptor);
>         } else {
>             Interceptor lastInterceptor = (Interceptor) 
> interceptors.getLast();
>             lastInterceptor.setNext(interceptor);
>             interceptors.addLast(interceptor);
>         }
>         if (interceptor instanceof Component)
>             addComponent((Component) interceptor);
>     }
> 
>     public final ObjectName getPlugin(String logicalPluginName) {
>         return (ObjectName) plugins.get(logicalPluginName);
>     }
> 
>     public final void putPlugin(String logicalPluginName, ObjectName 
> objectName) {
>         plugins.put(logicalPluginName, objectName);
>     }
> 
>     /**
>      * @deprecated
>      */
>     public final Object getPluginObject(String logicalPluginName) {
>         return pluginObjects.get(logicalPluginName);
>     }
> 
>     /**
>      * @deprecated
>      */
>     public final void putPluginObject(String logicalPluginName, Object 
> plugin) {
>         pluginObjects.put(logicalPluginName, plugin);
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/DeMarshalingInterceptor.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/DeMarshalingInterceptor.java
0a1,135
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting;
> 
> import java.io.Serializable;
> 
> import org.apache.geronimo.common.Interceptor;
> import org.apache.geronimo.common.Invocation;
> import org.apache.geronimo.common.InvocationResult;
> import org.apache.geronimo.common.SimpleInvocationResult;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class DeMarshalingInterceptor implements Interceptor {
> 
>     private ClassLoader classloader;
>     private Interceptor next;
> 
>     public static class ExceptionWrapper implements Serializable {
>         ExceptionWrapper(Exception exception) {
>             this.exception = exception;
>         }
>         public Exception exception;
>     }
> 
>     /**
>      * @return
>      */
>     public ClassLoader getClassloader() {
>         return classloader;
>     }
> 
>     /**
>      * @param classloader
>      */
>     public void setClassloader(ClassLoader classloader) {
>         this.classloader = classloader;
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.common.AbstractInterceptor#invoke(org.apache.geronimo.common.Invocation)
>      */
>     public InvocationResult invoke(Invocation invocation) throws Exception {
>         Thread currentThread = Thread.currentThread();
>         ClassLoader orig = currentThread.getContextClassLoader();
>         try {
>             currentThread.setContextClassLoader(classloader);
> 
>             MarshalledObject mo = 
> InvocationSupport.getMarshaledValue(invocation);
>             Invocation marshalledInvocation = (Invocation) mo.get();
> 
>             try {
>                 InvocationResult rc = getNext().invoke(marshalledInvocation);
>                 mo.set(rc.getResult());
>                 return new SimpleInvocationResult(mo);
>             } catch (Exception e) {
>                 mo.set(new ExceptionWrapper(e));
>                 return new SimpleInvocationResult(mo);
>             }
> 
>         } finally {
>             currentThread.setContextClassLoader(orig);
>         }
> 
>     }
> 
>     /* (non-Javadoc)
>      * @see org.apache.geronimo.common.Interceptor#getNext()
>      */
>     public Interceptor getNext() {
>         return next;
>     }
> 
>     /* (non-Javadoc)
>      * @see 
> org.apache.geronimo.common.Interceptor#setNext(org.apache.geronimo.common.Interceptor)
>      */
>     public void setNext(Interceptor interceptor) throws IllegalStateException 
> {
>         next = interceptor;
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/InterVMRoutingInterceptor.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/InterVMRoutingInterceptor.java
0a1,169
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting;
> 
> import java.io.Externalizable;
> import java.io.IOException;
> import java.io.ObjectInput;
> import java.io.ObjectOutput;
> 
> import org.apache.geronimo.common.Interceptor;
> import org.apache.geronimo.common.Invocation;
> import org.apache.geronimo.common.InvocationResult;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class InterVMRoutingInterceptor implements Interceptor, Externalizable 
> {
> 
>     String targetVMID = getLocalVMID();
>     transient Interceptor next;
>     Interceptor remotingInterceptor;
>     Interceptor localInterceptor;
> 
>     /**
>      * @see 
> org.apache.geronimo.common.AbstractInterceptor#invoke(org.apache.geronimo.common.Invocation)
>      */
>     public InvocationResult invoke(Invocation invocation) throws Exception {
>         return next.invoke(invocation);
>     }
> 
>     /**
>      * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
>      */
>     public void writeExternal(ObjectOutput out) throws IOException {
>         out.writeUTF(targetVMID);
>         out.writeObject(remotingInterceptor);
>         out.writeObject(localInterceptor);
>     }
> 
>     /**
>      * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
>      */
>     public void readExternal(ObjectInput in) throws IOException, 
> ClassNotFoundException {
>         targetVMID = in.readUTF();
>         remotingInterceptor = (Interceptor) in.readObject();
>         localInterceptor = (Interceptor) in.readObject();
> 
>         if (getLocalVMID().equals(targetVMID)) {
>             next.setNext(localInterceptor);
>         } else {
>             next.setNext(remotingInterceptor);
>         }
>     }
> 
>     public static String getLocalVMID() {
>         // TODO: generate a GUID here and return it.
>         return "";
>     }
> 
>     /**
>      * @return
>      */
>     public Interceptor getLocalInterceptor() {
>         return localInterceptor;
>     }
> 
>     /**
>      * @param localInterceptor
>      */
>     public void setLocalInterceptor(Interceptor localInterceptor) {
>         this.localInterceptor = localInterceptor;
>     }
> 
>     /**
>      * @return
>      */
>     public Interceptor getRemotingInterceptor() {
>         return remotingInterceptor;
>     }
> 
>     /**
>      * @param remotingInterceptor
>      */
>     public void setRemotingInterceptor(Interceptor remotingInterceptor) {
>         this.remotingInterceptor = remotingInterceptor;
>     }
> 
>     /**
>      * @return
>      */
>     public String getTargetVMID() {
>         return targetVMID;
>     }
> 
>     /**
>      * @param targetVMID
>      */
>     public void setTargetVMID(String targetVMID) {
>         this.targetVMID = targetVMID;
>     }
> 
>     /**
>      * @see org.apache.geronimo.common.Interceptor#getNext()
>      */
>     public Interceptor getNext() {
>         return next;
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.common.Interceptor#setNext(org.apache.geronimo.common.Interceptor)
>      */
>     public void setNext(Interceptor interceptor) throws IllegalStateException 
> {
>         this.next = interceptor;
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/InterceptorRegistry.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/InterceptorRegistry.java
0a1,99
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting;
> 
> import java.util.HashMap;
> 
> import org.apache.geronimo.common.Interceptor;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class InterceptorRegistry {
> 
>     static final public InterceptorRegistry instance = new 
> InterceptorRegistry();
> 
>     private InterceptorRegistry() {
> 
>     }
> 
>     long nextID = 0;
>     private synchronized long getNextID() {
>         return nextID++;
>     }
>     HashMap map = new HashMap();
> 
>     public Long register(Interceptor o) {
>         Long id = new Long(getNextID());
>         synchronized (map) {
>             map.put(id, o);
>         }
>         return id;
>     }
> 
>     public Interceptor unregister(Long id) {
>         synchronized (map) {
>             return (Interceptor) map.remove(id);
>         }
>     }
> 
>     public Interceptor lookup(Long id) {
>         synchronized (map) {
>             return (Interceptor) map.get(id);
>         }
>     }
> 
> }
\ No newline at end of file
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/IntraVMRoutingInterceptor.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/IntraVMRoutingInterceptor.java
0a1,158
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting;
> 
> import java.io.Externalizable;
> import java.io.IOException;
> import java.io.ObjectInput;
> import java.io.ObjectOutput;
> 
> import org.apache.geronimo.common.Interceptor;
> import org.apache.geronimo.common.Invocation;
> import org.apache.geronimo.common.InvocationResult;
> import org.apache.geronimo.remoting.transport.NullTransportInterceptor;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class IntraVMRoutingInterceptor implements Interceptor, Externalizable 
> {
> 
>     Long deMarshalingInterceptorID;
>     transient Interceptor next;
> 
>     /**
>      * @see 
> org.apache.geronimo.common.AbstractInterceptor#invoke(org.apache.geronimo.common.Invocation)
>      */
>     public InvocationResult invoke(Invocation invocation) throws Exception {
>         if (next == null)
>             resolveNext();
>         return next.invoke(invocation);
>     }
> 
>     /**
>      * 
>      */
>     synchronized private void resolveNext() {
>         // Get the demarshaling interceptor to find out the classloader scope 
> that the target
>         // app is in.
>         DeMarshalingInterceptor deMarshalingInterceptor =
>             (DeMarshalingInterceptor) 
> InterceptorRegistry.instance.lookup(deMarshalingInterceptorID);
>         ClassLoader parent = deMarshalingInterceptor.getClassloader();
>         ClassLoader child = Thread.currentThread().getContextClassLoader();
> 
>         // Did we deserialize with the same app classloader that
>         // the target belongs to??  
>         if (InvocationSupport.isAncestor(parent, child)) {
>             // Then we can avoid demarshalling/marshalling
>             next = deMarshalingInterceptor.getNext();
>         } else {
> 
>             // We have to marshall first..
>             next = new MarshalingInterceptor();
> 
>             // Then transport...
>             NullTransportInterceptor tansport = new 
> NullTransportInterceptor();
>             next.setNext(tansport);
> 
>             // then demarshall
>             tansport.setNext(deMarshalingInterceptor);
>         }
>     }
> 
>     /**
>      * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
>      */
>     public void writeExternal(ObjectOutput out) throws IOException {
>         out.writeLong(deMarshalingInterceptorID.longValue());
>     }
> 
>     /**
>      * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
>      */
>     public void readExternal(ObjectInput in) throws IOException, 
> ClassNotFoundException {
>         deMarshalingInterceptorID = new Long(in.readLong());
> 
>     }
> 
>     /**
>      * @see org.apache.geronimo.common.Interceptor#getNext()
>      */
>     public Interceptor getNext() {
>         return next;
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.common.Interceptor#setNext(org.apache.geronimo.common.Interceptor)
>      */
>     public void setNext(Interceptor interceptor) throws IllegalStateException 
> {
>         this.next = interceptor;
>     }
> 
>     /**
>      * @return
>      */
>     public Long getDeMarshalingInterceptorID() {
>         return deMarshalingInterceptorID;
>     }
> 
>     /**
>      * @param deMarshalingInterceptorID
>      */
>     public void setDeMarshalingInterceptorID(Long deMarshalingInterceptorID) {
>         this.deMarshalingInterceptorID = deMarshalingInterceptorID;
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/InvocationSupport.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/InvocationSupport.java
0a1,126
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting;
> import java.io.ObjectStreamException;
> import java.io.Serializable;
> import java.net.URI;
> import org.apache.geronimo.common.Invocation;
> /**
>  * @version $Revision$ $Date$
>  */
> public final class InvocationSupport implements Serializable {
> 
>     // Be careful here.  If you change the oridnals, this class must be 
> changed on evey client.
>     private static int MAX_ORIDNAL = 3;
>     private static final InvocationSupport[] values = new 
> InvocationSupport[MAX_ORIDNAL + 1];
>     private static final InvocationSupport MARSAHLLED_VALUE = new 
> InvocationSupport("MARSHALED_VALUE", 0);
>     private static final InvocationSupport REMOTE_URI = new 
> InvocationSupport("REMOTE_URI", 1);
>     private static final InvocationSupport INVOCATION_TYPE = new 
> InvocationSupport("INVOCATION_TYPE", 2);
> 
>     public static MarshalledObject getMarshaledValue(Invocation invocation) {
>         return (MarshalledObject) invocation.getTransient(MARSAHLLED_VALUE);
>     }
>     public static void putMarshaledValue(Invocation invocation, 
> MarshalledObject mo) {
>         invocation.putTransient(MARSAHLLED_VALUE, mo);
>     }
>     public static URI getRemoteURI(Invocation invocation) {
>         return (URI) invocation.getTransient(REMOTE_URI);
>     }
>     public static void putRemoteURI(Invocation invocation, URI remoteURI) {
>         invocation.putTransient(REMOTE_URI, remoteURI);
>     }
>     public static InvocationType getInvocationType(Invocation invocation) {
>         return (InvocationType) invocation.getTransient(INVOCATION_TYPE);
>     }
>     public static void putInvocationType(Invocation invocation, 
> InvocationType type) {
>         invocation.putTransient(INVOCATION_TYPE, type);
>     }
>     private final transient String name;
>     private final int ordinal;
> 
>     private InvocationSupport(String name, int ordinal) {
>         assert(ordinal < MAX_ORIDNAL);
>         assert(values[ordinal] == null);
>         this.name = name;
>         this.ordinal = ordinal;
>         values[ordinal] = this;
>     }
> 
>     public String toString() {
>         return name;
>     }
> 
>     Object readResolve() throws ObjectStreamException {
>         return values[ordinal];
>     }
> 
>     static public boolean isAncestor(ClassLoader parent, ClassLoader child) {
>         // Root child? ancestor must be root too.
>         if (child == null)
>             return parent == null;
>         // Root parent is the ancestor of all classloaders.
>         if (parent == null)
>             return true;
> 
>         while (child != null) {
>             if (child.equals(parent))
>                 return true;
>             child = child.getParent();
>         }
>         return false;
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/InvocationType.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/InvocationType.java
0a1,88
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting;
> import java.io.ObjectStreamException;
> import java.io.Serializable;
> /**
>  * @version $Revision$ $Date$
>  */
> public final class InvocationType implements Serializable {
> 
>     // Be careful here.  If you change the oridnals, this class must be 
> changed on evey client.
>     private static int MAX_ORIDNAL = 2;
>     private static final InvocationType[] values = new 
> InvocationType[MAX_ORIDNAL + 1];
>     public static final InvocationType REQUEST = new 
> InvocationType("REQUEST", 0);
>     public static final InvocationType DATAGRAM = new 
> InvocationType("DATAGRAM", 1);
> 
>     private final transient String name;
>     private final int ordinal;
> 
>     private InvocationType(String name, int ordinal) {
>         assert(ordinal < MAX_ORIDNAL);
>         assert(values[ordinal] == null);
>         this.name = name;
>         this.ordinal = ordinal;
>         values[ordinal] = this;
>     }
> 
>     public String toString() {
>         return name;
>     }
> 
>     Object readResolve() throws ObjectStreamException {
>         return values[ordinal];
>     }
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/MarshalingInterceptor.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/MarshalingInterceptor.java
0a1,109
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting;
> 
> import java.io.Serializable;
> 
> import org.apache.geronimo.common.Interceptor;
> import org.apache.geronimo.common.Invocation;
> import org.apache.geronimo.common.InvocationResult;
> import org.apache.geronimo.common.SimpleInvocationResult;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class MarshalingInterceptor implements Interceptor, Serializable {
>     TransportInterceptor next;
> 
>     /**
>      * @see 
> org.apache.geronimo.common.AbstractInterceptor#invoke(org.apache.geronimo.common.Invocation)
>      */
>     public InvocationResult invoke(Invocation invocation) throws Exception {
> 
>         // Marshall the invocation and store it.
>         MarshalledObject mo = next.createMarshalledObject();
>         mo.set(invocation);
>         InvocationSupport.putMarshaledValue(invocation, mo);
> 
>         InvocationResult rc = next.invoke(invocation);
> 
>         // Demarshal the result.
>         mo = (MarshalledObject) rc.getResult();
>         Object result = mo.get();
> 
>         // Are we demarshalling a thrown exception.
>         if (result instanceof DeMarshalingInterceptor.ExceptionWrapper) {
>             throw ((DeMarshalingInterceptor.ExceptionWrapper) 
> result).exception;
>         }
> 
>         return new SimpleInvocationResult(result);
> 
>     }
> 
>     /**
>      * @see org.apache.geronimo.common.Interceptor#getNext()
>      */
>     public Interceptor getNext() {
>         return next;
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.common.Interceptor#setNext(org.apache.geronimo.common.Interceptor)
>      */
>     public void setNext(Interceptor interceptor) throws IllegalStateException 
> {
>         this.next = (TransportInterceptor) interceptor;
>     }
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/MarshalledMethod.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/MarshalledMethod.java
0a1,132
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting;
> 
> import java.io.Serializable;
> import java.lang.reflect.Method;
> import java.util.Collections;
> import java.util.Map;
> import java.util.WeakHashMap;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class MarshalledMethod implements Serializable {
> 
>     String declaringClass;
>     short methodIndex;
>     short methodHash;
> 
>     /**
>      * 
>      */
>     public MarshalledMethod() {
>     }
> 
>     /**
>      * @param method
>      */
>     public MarshalledMethod(Method method) {
>         Class owner = method.getDeclaringClass();
>         declaringClass = owner.getName();
>         methodHash = hashCode(method);
>         Method[] methods = owner.getMethods();
>         methodIndex = -1;
>         for (short i = 0; i < methods.length; i++) {
>             if (methods[i].equals(method)) {
>                 methodIndex = i;
>                 break;
>             }
>         }
>         // I don't thing this will EVER happen.
>         if (methodIndex == -1)
>             throw new RuntimeException("Could not find method in declaring 
> class!");
>     }
> 
>     /**
>      * TODO: figure out a better hashcode algorithim for the method.
>      * 
>      * @param method
>      * @return
>      */
>     private static short hashCode(Method method) {
>         return (short) method.getName().hashCode();
>     }
> 
>     /**
>      * @return
>      */
>     public Method getMethod() throws ClassNotFoundException {
>         Class c = 
> Thread.currentThread().getContextClassLoader().loadClass(declaringClass);
>         Method rc = c.getMethods()[methodIndex];
>         short lhc = hashCode(rc);
>         if (lhc != methodHash)
>             throw new ClassNotFoundException("The '" + declaringClass + "' 
> class is incompatible. ");
>         return rc;
>     }
> 
>     private static Map methodCache = Collections.synchronizedMap(new 
> WeakHashMap());
>     public static MarshalledMethod getMarshalledMethod(Method method) {
>         Integer cacheKey = new Integer(method.hashCode());
>         MarshalledMethod rc = (MarshalledMethod) methodCache.get(cacheKey);
>         if (rc == null) {
>             rc = new MarshalledMethod(method);
>             methodCache.put(cacheKey, rc);
>         }
>         return rc;
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/MarshalledObject.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/MarshalledObject.java
0a1,75
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting;
> 
> import java.io.IOException;
> 
> /**
>  * Interface to a marshalled form of an object.  This is an interface because
>  * there might be multiple marshalled forms we want to support based on 
> transport.
>  * Example: 
>  *    - XML or SOAP based marshalled format
>  *    - byte[] based marshalled format
>  * 
>  * @version $Revision$ $Date$
>  */
> public interface MarshalledObject {
> 
>     public void set(Object object) throws IOException;
>     public Object get() throws IOException, ClassNotFoundException;
>     public Object get(ClassLoader classloader) throws IOException, 
> ClassNotFoundException;
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/TransportInterceptor.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/TransportInterceptor.java
0a1,68
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting;
> 
> import org.apache.geronimo.common.Interceptor;
> 
> /**
>  * You can ask a TransportInterceptor what what type of
>  * MarshalledObject the transport would like.
>  * 
>  * @version $Revision$ $Date$
>  */
> public interface TransportInterceptor extends Interceptor {
>     MarshalledObject createMarshalledObject();
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/BytesMarshalledObject.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/BytesMarshalledObject.java
0a1,183
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.Externalizable;
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.ObjectInput;
> import java.io.ObjectInputStream;
> import java.io.ObjectOutput;
> import java.io.ObjectOutputStream;
> import java.io.ObjectStreamClass;
> import java.io.OutputStream;
> import java.lang.reflect.Proxy;
> 
> import org.apache.geronimo.core.util.ClassUtil;
> import org.apache.geronimo.remoting.MarshalledObject;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class BytesMarshalledObject implements MarshalledObject, 
> Externalizable {
> 
>     public class ObjectInputStreamExt extends ObjectInputStream {
> 
>         private ClassLoader classloader;
> 
>         public ObjectInputStreamExt(InputStream in, ClassLoader loader) 
> throws IOException {
>             super(in);
>             this.classloader = loader;
>         }
> 
>         /**
>          * @see 
> java.io.ObjectInputStream#resolveClass(java.io.ObjectStreamClass)
>          */
>         protected Class resolveClass(ObjectStreamClass classDesc) throws 
> IOException, ClassNotFoundException {
>             return ClassUtil.resolveObjectStreamClass(classloader, 
> classDesc.getName());
>         }
> 
>         /**
>          * @see 
> java.io.ObjectInputStream#resolveProxyClass(java.lang.String[])
>          */
>         protected Class resolveProxyClass(String[] interfaces) throws 
> IOException, ClassNotFoundException {
>             Class[] cinterfaces = new Class[interfaces.length];
>             for (int i = 0; i < interfaces.length; i++)
>                 cinterfaces[i] = classloader.loadClass(interfaces[i]);
> 
>             try {
>                 return Proxy.getProxyClass(classloader, cinterfaces);
>             } catch (IllegalArgumentException e) {
>                 throw new ClassNotFoundException(null, e);
>             }
> 
>         }
> 
>     }
> 
>     static class ObjectOutputStreamExt extends ObjectOutputStream {
> 
>         /**
>          * @param out
>          * @throws IOException
>          */
>         public ObjectOutputStreamExt(OutputStream out) throws IOException {
>             super(out);
>             // TODO Auto-generated constructor stub
>         }
> 
>     }
> 
>     private byte data[];
> 
>     public BytesMarshalledObject() {
>     }
> 
>     public BytesMarshalledObject(Object value) throws IOException {
>         set(value);
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.MarshalledObject#set(java.lang.Object)
>      */
>     public void set(Object value) throws IOException {
>         ByteArrayOutputStream baos = new ByteArrayOutputStream();
>         ObjectOutputStreamExt os = new ObjectOutputStreamExt(baos);
>         os.writeObject(value);
>         os.close();
>         data = baos.toByteArray();
>     }
> 
>     public byte[] getBytes() {
>         return data;
>     }
> 
>     public void setBytes(byte[] data) {
>         this.data = data;
>     }
> 
>     public Object get() throws IOException, ClassNotFoundException {
>         return get(Thread.currentThread().getContextClassLoader());
>     }
> 
>     public Object get(ClassLoader classloader) throws IOException, 
> ClassNotFoundException {
>         ByteArrayInputStream bais = new ByteArrayInputStream(data);
>         ObjectInputStreamExt is = new ObjectInputStreamExt(bais, classloader);
>         Object rc = is.readObject();
>         is.close();
>         return rc;
>     }
> 
>     /* (non-Javadoc)
>      * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
>      */
>     public void writeExternal(ObjectOutput out) throws IOException {
>         out.writeInt(data.length);
>         out.write(data);
>     }
> 
>     /* (non-Javadoc)
>      * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
>      */
>     public void readExternal(ObjectInput in) throws IOException, 
> ClassNotFoundException {
>         int size = in.readInt();
>         data = new byte[size];
>         in.readFully(data);
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/BytesMsg.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/BytesMsg.java
0a1,117
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> import java.io.DataInput;
> import java.io.DataOutput;
> import java.io.IOException;
> import java.util.ArrayList;
> 
> import org.apache.geronimo.remoting.MarshalledObject;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class BytesMsg implements Msg {
> 
>     ArrayList objectStack = new ArrayList(5);
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.transport.Msg#pushMarshaledObject(org.apache.geronimo.remoting.MarshalledObject)
>      */
>     public void pushMarshaledObject(MarshalledObject mo) throws IOException {
>         objectStack.add((BytesMarshalledObject) mo);
>     }
> 
>     /**
>      * @see org.apache.geronimo.remoting.transport.Msg#popMarshaledObject()
>      */
>     public MarshalledObject popMarshaledObject() throws IOException {
>         if (objectStack.size() == 0)
>             throw new ArrayIndexOutOfBoundsException("Object stack is 
> empty.");
>         return (MarshalledObject) objectStack.remove(objectStack.size() - 1);
>     }
> 
>     /**
>      * @see org.apache.geronimo.remoting.transport.Msg#createMsg()
>      */
>     public Msg createMsg() {
>         return new BytesMsg();
>     }
> 
>     public void writeExternal(DataOutput out) throws IOException {
>         out.writeByte(objectStack.size());
>         for (int i = 0; i < objectStack.size(); i++) {
>             BytesMarshalledObject mo = (BytesMarshalledObject) 
> objectStack.get(i);
>             byte[] bs = mo.getBytes();
>             out.writeInt(bs.length);
>             out.write(bs);
>         }
>     }
> 
>     public void readExternal(DataInput in) throws IOException {
>         objectStack.clear();
>         int s = in.readByte();
>         for (int i = 0; i < s; i++) {
>             int l = in.readInt();
>             byte t[] = new byte[l];
>             in.readFully(t);
>             BytesMarshalledObject mo = new BytesMarshalledObject();
>             mo.setBytes(t);
>             objectStack.add(mo);
>         }
>     }
> }
\ No newline at end of file
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/ConnectionFailedException.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/ConnectionFailedException.java
0a1,76
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class ConnectionFailedException extends TransportException {
>     /**
>      * 
>      */
>     public ConnectionFailedException() {
>         super();
>     }
> 
>     /**
>      * @param s
>      */
>     public ConnectionFailedException(String s) {
>         super(s);
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/FragmentBasedInterceptorRouter.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/FragmentBasedInterceptorRouter.java
0a1,124
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> import java.net.URI;
> 
> import org.apache.geronimo.common.Interceptor;
> import org.apache.geronimo.common.InvocationResult;
> import org.apache.geronimo.common.SimpleInvocation;
> import org.apache.geronimo.remoting.InterceptorRegistry;
> import org.apache.geronimo.remoting.InvocationSupport;
> import org.apache.geronimo.remoting.MarshalledObject;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class FragmentBasedInterceptorRouter implements Router {
> 
>     /**
>      *
>      *
>      * @see 
> org.apache.geronimo.remoting.transport.Router#sendRequest(java.net.URI, 
> org.apache.geronimo.remoting.transport.Msg)
>      */
>     public Msg sendRequest(URI to, Msg msg) throws TransportException {
>         Interceptor interceptor = lookupInterceptorFrom(to);
> 
>         try {
>             SimpleInvocation invocation = new SimpleInvocation();
>             InvocationSupport.putMarshaledValue(invocation, 
> msg.popMarshaledObject());
>             InvocationSupport.putRemoteURI(invocation, to);
> 
>             InvocationResult result = interceptor.invoke(invocation);
> 
>             msg = msg.createMsg();
>             msg.pushMarshaledObject((MarshalledObject) result.getResult());
>             return msg;
> 
>         } catch (Exception e) {
>             e.printStackTrace();
>             throw new TransportException(e.getMessage());
>         }
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.transport.Router#sendDatagram(java.net.URI, 
> org.apache.geronimo.remoting.transport.Msg)
>      */
>     public void sendDatagram(URI to, Msg msg) throws TransportException {
>         Interceptor interceptor = lookupInterceptorFrom(to);
> 
>         try {
>             SimpleInvocation invocation = new SimpleInvocation();
>             InvocationSupport.putMarshaledValue(invocation, 
> msg.popMarshaledObject());
>             InvocationSupport.putRemoteURI(invocation, to);
> 
>             InvocationResult result = interceptor.invoke(invocation);
> 
>         } catch (Exception e) {
>             throw new TransportException(e.getMessage());
>         }
>     }
> 
>     /**
>      * @param string
>      * @return
>      */
>     private Interceptor lookupInterceptorFrom(URI to) {
>         Long x = new Long(to.getFragment());
>         return InterceptorRegistry.instance.lookup(x);
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/Msg.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/Msg.java
0a1,71
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> import java.io.IOException;
> 
> import org.apache.geronimo.remoting.MarshalledObject;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public interface Msg {
> 
>     public void pushMarshaledObject(MarshalledObject mo) throws IOException;
>     public MarshalledObject popMarshaledObject() throws IOException;
>     Msg createMsg();
> 
> }
\ No newline at end of file
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/NullTransportInterceptor.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/NullTransportInterceptor.java
0a1,99
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> import org.apache.geronimo.common.Interceptor;
> import org.apache.geronimo.common.Invocation;
> import org.apache.geronimo.common.InvocationResult;
> import org.apache.geronimo.remoting.MarshalledObject;
> import org.apache.geronimo.remoting.TransportInterceptor;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class NullTransportInterceptor implements TransportInterceptor {
> 
>     private Interceptor next;
> 
>     /**
>      * @see 
> org.apache.geronimo.common.AbstractInterceptor#invoke(org.apache.geronimo.common.Invocation)
>      */
>     public InvocationResult invoke(Invocation invocation) throws Exception {
>         return getNext().invoke(invocation);
>     }
> 
>     /**
>      * @see org.apache.geronimo.common.Interceptor#getNext()
>      */
>     public Interceptor getNext() {
>         return next;
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.common.Interceptor#setNext(org.apache.geronimo.common.Interceptor)
>      */
>     public void setNext(Interceptor interceptor) throws IllegalStateException 
> {
>         next = interceptor;
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.TransportInterceptor#createMarshalledObject()
>      */
>     public MarshalledObject createMarshalledObject() {
>         return new BytesMarshalledObject();
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/RemoteTransportInterceptor.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/RemoteTransportInterceptor.java
0a1,163
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> import java.io.Externalizable;
> import java.io.IOException;
> import java.io.ObjectInput;
> import java.io.ObjectOutput;
> import java.io.StreamCorruptedException;
> import java.net.URI;
> import java.net.URISyntaxException;
> 
> import org.apache.geronimo.common.Interceptor;
> import org.apache.geronimo.common.Invocation;
> import org.apache.geronimo.common.InvocationResult;
> import org.apache.geronimo.common.SimpleInvocationResult;
> import org.apache.geronimo.remoting.InvocationSupport;
> import org.apache.geronimo.remoting.InvocationType;
> import org.apache.geronimo.remoting.MarshalledObject;
> import org.apache.geronimo.remoting.TransportInterceptor;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class RemoteTransportInterceptor implements TransportInterceptor, 
> Externalizable {
> 
>     URI remoteURI;
>     transient TransportClient transportClient;
> 
>     /**
>      * @see 
> org.apache.geronimo.common.AbstractInterceptor#invoke(org.apache.geronimo.common.Invocation)
>      */
>     public InvocationResult invoke(Invocation invocation) throws Exception {
> 
>         MarshalledObject mo = InvocationSupport.getMarshaledValue(invocation);
>         // URI remoteURI = InvocationSupport.getRemoteURI(invocation);
>         InvocationType type = InvocationSupport.getInvocationType(invocation);
>         if (type == null)
>             type = InvocationType.REQUEST;
> 
>         Msg msg = transportClient.createMsg();
>         msg.pushMarshaledObject(mo);
>         if (type == InvocationType.REQUEST) {
>             msg = transportClient.sendRequest(remoteURI, msg);
>             return new SimpleInvocationResult(msg.popMarshaledObject());
>         } else {
>             transportClient.sendDatagram(remoteURI, msg);
>             MarshalledObject rcmo = transportClient.createMarshalledObject();
>             rcmo.set(null);
>             return new SimpleInvocationResult(rcmo);
>         }
>     }
> 
>     /**
>      * @see org.apache.geronimo.common.Interceptor#getNext()
>      */
>     public Interceptor getNext() {
>         return null;
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.common.Interceptor#setNext(org.apache.geronimo.common.Interceptor)
>      */
>     public void setNext(Interceptor interceptor) throws IllegalStateException 
> {
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.TransportInterceptor#createMarshalledObject()
>      */
>     public MarshalledObject createMarshalledObject() {
>         return transportClient.createMarshalledObject();
>     }
> 
>     /**
>      * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
>      */
>     public void writeExternal(ObjectOutput out) throws IOException {
>         out.writeUTF(remoteURI.toString());
>     }
> 
>     /**
>      * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
>      */
>     public void readExternal(ObjectInput in) throws IOException, 
> ClassNotFoundException {
>         try {
>             remoteURI = new URI(in.readUTF());
>             TransportFactory tf = 
> TransportFactory.getTransportFactory(remoteURI);
>             transportClient = tf.createClient();
>         } catch (URISyntaxException e) {
>             throw new StreamCorruptedException(e.getMessage());
>         }
>     }
> 
>     /**
>      * @return
>      */
>     public URI getRemoteURI() {
>         return remoteURI;
>     }
> 
>     /**
>      * @param remoteURI
>      */
>     public void setRemoteURI(URI remoteURI) {
>         this.remoteURI = remoteURI;
>         TransportFactory tf = TransportFactory.getTransportFactory(remoteURI);
>         transportClient = tf.createClient();
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/Router.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/Router.java
0a1,81
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> import java.net.URI;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public interface Router {
> 
>     /**
>      * Sends a request message to the other end.
>      * 
>      * @param request
>      * @return
>      */
>     Msg sendRequest(URI to, Msg request) throws TransportException;
> 
>     /**
>      * Sends a datagram message.  No response is expected.   
>      * 
>      * @param request
>      * @return
>      */
>     void sendDatagram(URI to, Msg request) throws TransportException;
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/StreamCorruptedException.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/StreamCorruptedException.java
0a1,76
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class StreamCorruptedException extends TransportException {
>     /**
>      * 
>      */
>     public StreamCorruptedException() {
>         super();
>     }
> 
>     /**
>      * @param s
>      */
>     public StreamCorruptedException(String s) {
>         super(s);
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportClient.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportClient.java
0a1,68
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> import org.apache.geronimo.remoting.MarshalledObject;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public interface TransportClient extends Router {
> 
>     Msg createMsg();
>     MarshalledObject createMarshalledObject();
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportException.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportException.java
0a1,76
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class TransportException extends Exception {
>     /**
>      * 
>      */
>     public TransportException() {
>         super();
>     }
> 
>     /**
>      * @param s
>      */
>     public TransportException(String s) {
>         super(s);
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportFactory.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportFactory.java
0a1,102
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> import java.net.URI;
> import java.util.ArrayList;
> import java.util.Iterator;
> 
> import org.apache.geronimo.remoting.transport.async.AsyncTransportFactory;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public abstract class TransportFactory {
> 
>     private static ArrayList factories = new ArrayList();
>     static {
>         // Try our best to add a few known TransportFactory objects.
>         // We may not be able to load due to ClassNotFound problems.
>         try {
>             addFactory(AsyncTransportFactory.instance);
>         } catch (Throwable ignore) {
>         }
>     }
> 
>     public static TransportFactory getTransportFactory(URI uri) {
>         Iterator iterator = factories.iterator();
>         while (iterator.hasNext()) {
>             TransportFactory i = (TransportFactory) iterator.next();
>             if (i.handles(uri))
>                 return i;
>         }
>         return null;
> 
>     }
> 
>     static public void addFactory(TransportFactory tf) {
>         factories.add(tf);
>     }
> 
>     static public void removeFactory(TransportFactory tf) {
>         factories.remove(tf);
>     }
> 
>     abstract protected boolean handles(URI uri);
>     abstract public TransportClient createClient();
>     abstract public TransportServer createSever();
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportLoader.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportLoader.java
0a1,124
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> import java.net.URI;
> 
> import org.apache.geronimo.common.AbstractComponent;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class TransportLoader extends AbstractComponent implements 
> TransportLoaderMBean {
> 
>     URI bindURI;
>     TransportServer server;
>     Router dispatchingRouter;
> 
>     /**
>      * @see org.apache.geronimo.common.AbstractComponent#doStart()
>      */
>     protected void doStart() throws Exception {
>         TransportFactory tf = TransportFactory.getTransportFactory(bindURI);
>         server = tf.createSever();
>         server.bind(bindURI, dispatchingRouter);
>         server.start();
>     }
> 
>     /**
>      * @see org.apache.geronimo.common.AbstractComponent#doStop()
>      */
>     protected void doStop() throws Exception {
>         server.stop();
>         server.dispose();
>         server = null;
>     }
>     /**
>      * @return
>      */
>     public URI getBindURI() {
>         return bindURI;
>     }
> 
>     /**
>      * @param bindURI
>      */
>     public void setBindURI(URI bindURI) {
>         this.bindURI = bindURI;
>     }
> 
>     /**
>      * @return
>      */
>     public Router getDispatchingRouter() {
>         return dispatchingRouter;
>     }
> 
>     /**
>      * @param dispatchingRouter
>      */
>     public void setDispatchingRouter(Router dispatchingRouter) {
>         this.dispatchingRouter = dispatchingRouter;
>     }
> 
>     /**
>      * @return
>      */
>     public URI getClientConnectURI() {
>         return server.getClientConnectURI();
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportLoaderMBean.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportLoaderMBean.java
0a1,84
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> import java.net.URI;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public interface TransportLoaderMBean {
>     /**
>      * @return
>      */
>     public abstract URI getBindURI();
>     /**
>      * @param bindURI
>      */
>     public abstract void setBindURI(URI bindURI);
>     /**
>      * @return
>      */
>     public abstract Router getDispatchingRouter();
>     /**
>      * @param dispatchingRouter
>      */
>     public abstract void setDispatchingRouter(Router dispatchingRouter);
>     /**
>      * @return
>      */
>     public abstract URI getClientConnectURI();
> }
\ No newline at end of file
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportServer.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportServer.java
0a1,113
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport;
> 
> import java.net.URI;
> 
> import org.apache.geronimo.common.Component;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public interface TransportServer extends Component {
> 
>     /**
>      * Configures and otatains any resources needed to
>      * start accepting client requests.  The bindURI argument
>      * will configure the interface/port etc. that the server 
>      * will use to service requests.
>      * 
>      * The sever should pass all requests and datagrams to the 
>      * dispatcher.
>      * 
>      * @param bindURI
>      * @throws Exception
>      */
>     void bind(URI bindURI, Router dispatcher) throws Exception;
> 
>     /**
>      * Once the bind() call has been done, this method will 
>      * return a URI that can be used by a client to connect 
>      * to the server.
>      * 
>      * @return null if server has not been bound.
>      */
>     URI getClientConnectURI();
> 
>     /**
>      * Enables the server to start accepting new client requests.
>      * @throws Exception
>      */
>     void start() throws Exception;
> 
>     /**
>      * Stops the server from accepting new client requests.
>      * start() may be called at a later time to start processing
>      * requests again.
>      * 
>      * @throws Exception
>      */
>     void stop() throws Exception;
> 
>     /**
>      * Rleases all resources that were obtained during the life of
>      * the server.  Once disposed, the sever instance cannot be used 
>      * again.
>      * @throws Exception
>      */
>     void dispose() throws Exception;
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/URISupport.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/URISupport.java
0a1,94
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport;
> import java.net.URI;
> import java.net.URISyntaxException;
> import java.util.Properties;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public final class URISupport {
> 
>     static public Properties parseQueryParameters(URI uri) {
>         Properties rc = new Properties();
>         if (uri.getQuery() == null)
>             return rc;
> 
>         // TODO: parse the queryString and populate the properties object
>         return rc;
>     }
> 
>     /**
>      * @param queryParams
>      */
>     static public String toQueryString(Properties queryParams) {
>         // TODO Auto-generated method stub
>         return null;
>     }
> 
>     static public URI setFragment(URI uri, String fragment) throws 
> URISyntaxException {
>         return new URI(
>             uri.getScheme(),
>             uri.getUserInfo(),
>             uri.getHost(),
>             uri.getPort(),
>             uri.getPath(),
>             uri.getQuery(),
>             fragment);
>     }
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/AbstractServer.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/AbstractServer.java
0a1,197
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async;
> import java.net.URI;
> import java.util.HashMap;
> import java.util.Iterator;
> 
> import org.apache.geronimo.proxy.SimpleContainer;
> import org.apache.geronimo.remoting.transport.Router;
> import org.apache.geronimo.remoting.transport.TransportServer;
> 
> import EDU.oswego.cs.dl.util.concurrent.ClockDaemon;
> 
> /**
>  * Provides a Blocking implemenation of the AsynchChannelServer interface.
>  * 
>  * Sets up a blocking ServerSocket to accept blocking client connections.
>  * 
>  * @version $Revision$ $Date$
>  */
> abstract public class AbstractServer extends SimpleContainer implements 
> TransportServer {
> 
>     /** 
>      * The amount of time that must pass before an idle connection is closed. 
>      */
>     public final long CONNECTION_TIMEOUT =
>         
> Long.parseLong(System.getProperty("org.apache.geronimo.remoting.transport.async.connection_timeout",
>  "300000"));
>     // 5 min.
> 
>     private HashMap channelPools = new HashMap();
> 
>     /**
>      * Used as the key into the channelPools Map.
>      * 
>      * The ipaddress and port are the only needed fields
>      * to locate a channel pool. 
>      */
>     private class URIKey {
> 
>         String ipaddress;
>         int port;
> 
>         URIKey(URI uri) {
>             ipaddress = uri.getHost();
>             port = uri.getPort();
>         }
> 
>         /*
>          * The key is used in a homogenous map.  We can cheat. 
>          */
>         public boolean equals(Object obj) {
>             return ((URIKey) obj).port == port && ((URIKey) 
> obj).ipaddress.equals(ipaddress);
>         }
>         public int hashCode() {
>             return ipaddress.hashCode() + port;
>         }
>     }
> 
>     /**
>      * Keeps a map of uri->ChannelPool objects.  Creates the 
>      * ChannelPool if it the first time you access the uri.
>      * 
>      * TODO: think of way to remove ChannelPool objects that are not being 
> used.
>      * 
>      * @param server
>      */
>     public ChannelPool getChannelPool(URI uri) {
> 
>         URIKey key = new URIKey(uri);
>         synchronized (channelPools) {
>             ChannelPool rc = (ChannelPool) channelPools.get(key);
>             if (rc == null) {
>                 rc = new ChannelPool(uri, getNextRouter());
>                 channelPools.put(key, rc);
>                 ChannelPoolMonitor pm = new ChannelPoolMonitor(key, rc);
>                 pm.clockTicket = 
> Registry.instance.getClockDaemon().executePeriodically(CONNECTION_TIMEOUT, 
> pm, true);
>             }
>             return rc;
>         }
>     }
> 
>     /**
>      * This class periodically checks one channel pool. 
>      */
>     class ChannelPoolMonitor implements Runnable {
>         long age = System.currentTimeMillis();
>         URIKey key;
>         ChannelPool channelPool;
>         Object clockTicket;
>         ChannelPoolMonitor(URIKey key, ChannelPool cp) {
>             this.key = key;
>             this.channelPool = cp;
>         }
>         public void run() {
>             channelPool.expireIdleConnections(CONNECTION_TIMEOUT);
> 
>             // Should we start thinking bout aging out the whole pool??
>             if ((System.currentTimeMillis() - age) < CONNECTION_TIMEOUT)
>                 return;
> 
>             synchronized (channelPools) {
>                 // Should we remove the channel pool??
>                 if (channelPool.getCreatedChannelCount() == 0) {
>                     ClockDaemon.cancel(clockTicket);
>                 }
>                 channelPools.remove(key);
>             }
>         }
>     }
> 
>     /**
>      * @see org.apache.geronimo.remoting.transport.TransportServer#dispose()
>      */
>     public void dispose() throws Exception {
>         synchronized (channelPools) {
>             Iterator iterator = channelPools.values().iterator();
>             while (iterator.hasNext()) {
>                 ChannelPool pool = (ChannelPool) iterator.next();
>                 pool.dispose();
>                 iterator.remove();
>             }
>         }
>     }
> 
>     abstract public Router getNextRouter();
> 
>     /**
>      * @see org.apache.geronimo.remoting.transport.TransportServer#start()
>      */
>     public void start() throws Exception {
>         if (Registry.instance.getDefaultServer() == null)
>             Registry.instance.setDefaultServer(this);
>     }
> 
>     /**
>      * @see org.apache.geronimo.remoting.transport.TransportServer#stop()
>      */
>     public void stop() throws Exception {
>         if (Registry.instance.getDefaultServer() == this)
>             Registry.instance.setDefaultServer(null);
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/AsyncClient.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/AsyncClient.java
0a1,119
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async;
> 
> import java.net.URI;
> 
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.geronimo.remoting.MarshalledObject;
> import org.apache.geronimo.remoting.transport.BytesMarshalledObject;
> import org.apache.geronimo.remoting.transport.Msg;
> import org.apache.geronimo.remoting.transport.TransportClient;
> import org.apache.geronimo.remoting.transport.TransportException;
> 
> /**
>  * AsyncClientInvoker uses sockets to remotely connect to the 
>  * a remote AsyncServerInvoker.  Requests are sent asynchronously 
>  * to allow more concurrent requests to be sent to the server
>  * while using fewer sockets.  This is also known as the 'async'
>  * protocol.
>  * 
>  * TODO:
>  * If you are running on Java 1.4, this transport
>  * transport will take advantage of the NIO 
>  * classes to further reduce the resources used on the server.
>  *
>  * @version $Revision$ $Date$
>  */
> public class AsyncClient implements TransportClient {
> 
>     static final Log log = LogFactory.getLog(AsyncClient.class);
> 
>     /**
>      * @see 
> org.apache.j2ee.remoting.transport.TransportClient#sendRequest(org.apache.j2ee.remoting.URI,
>  byte[])
>      */
>     public Msg sendRequest(URI to, Msg request) throws TransportException {
>         AbstractServer server = Registry.instance.getServerForClientRequest();
>         ChannelPool pool = server.getChannelPool(to);
>         return pool.sendRequest(to, request);
>     }
> 
>     /**
>      * @see 
> org.apache.j2ee.remoting.transport.TransportClient#sendDatagram(org.apache.j2ee.remoting.URI,
>  byte[])
>      */
>     public void sendDatagram(URI to, Msg request) throws TransportException {
>         AbstractServer server = Registry.instance.getServerForClientRequest();
>         ChannelPool pool = server.getChannelPool(to);
>         pool.sendDatagram(to, request);
>     }
> 
>     /**
>      * @see org.apache.geronimo.remoting.transport.TransportClient#createMsg()
>      */
>     public Msg createMsg() {
>         return new AsyncMsg();
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.transport.TransportClient#createMarshalledObject()
>      */
>     public MarshalledObject createMarshalledObject() {
>         return new BytesMarshalledObject();
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/AsyncMsg.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/AsyncMsg.java
0a1,130
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport.async;
> 
> import java.io.DataInput;
> import java.io.DataOutput;
> import java.io.IOException;
> import java.io.StreamCorruptedException;
> 
> import org.apache.geronimo.remoting.transport.BytesMsg;
> import org.apache.geronimo.remoting.transport.Msg;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class AsyncMsg extends BytesMsg {
> 
>     public static final byte DATAGRAM_TYPE = 0;
>     public static final byte REQUEST_TYPE = 1;
>     public static final byte RESPONE_TYPE = 2;
> 
>     byte type = REQUEST_TYPE;
>     int requestId;
>     String to;
> 
>     /**
>      * @see org.apache.geronimo.remoting.transport.BytesMsg#createMsg()
>      */
>     public Msg createMsg() {
>         return new AsyncMsg();
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.transport.BytesMsg#writeExternal(java.io.DataOutput)
>      */
>     public void writeExternal(DataOutput out) throws IOException {
>         super.writeExternal(out);
>         out.writeByte(type);
>         switch (type) {
>             case DATAGRAM_TYPE :
>                 out.writeUTF(to);
>                 break;
>             case REQUEST_TYPE :
>                 out.writeInt(requestId);
>                 out.writeUTF(to);
>                 break;
>             case RESPONE_TYPE :
>                 out.writeInt(requestId);
>                 break;
>             default :
>                 throw new StreamCorruptedException("Unknow type: " + type);
>         }
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.transport.BytesMsg#readExternal(java.io.DataInput)
>      */
>     public void readExternal(DataInput in) throws IOException {
>         super.readExternal(in);
>         type = in.readByte();
>         requestId = 0;
>         switch (type) {
>             case DATAGRAM_TYPE :
>                 to = in.readUTF();
>                 break;
>             case REQUEST_TYPE :
>                 requestId = in.readInt();
>                 to = in.readUTF();
>                 break;
>             case RESPONE_TYPE :
>                 requestId = in.readInt();
>                 break;
>             default :
>                 throw new StreamCorruptedException("Unknow type: " + type);
>         }
>     }    
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/AsyncTransportFactory.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/AsyncTransportFactory.java
0a1,118
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async;
> 
> import java.net.URI;
> 
> import org.apache.geronimo.remoting.transport.TransportClient;
> import org.apache.geronimo.remoting.transport.TransportFactory;
> import org.apache.geronimo.remoting.transport.TransportServer;
> import org.apache.geronimo.remoting.transport.async.bio.BlockingChannel;
> import org.apache.geronimo.remoting.transport.async.bio.BlockingServer;
> import org.apache.geronimo.remoting.transport.async.nio.NonBlockingChannel;
> import org.apache.geronimo.remoting.transport.async.nio.NonBlockingServer;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class AsyncTransportFactory extends TransportFactory {
> 
>     /** 
>      * Should we used Blocking IO instead of Non-blocking IO.  We default
>      *  to using Non-blocking IO
>      */
>     static public final boolean USE_BLOCKING_IO =
>         new 
> Boolean(System.getProperty("org.apache.geronimo.remoting.transport.async.use_blocking_io",
>  "false"))
>             .booleanValue();
> 
>     static final public AsyncTransportFactory instance = new 
> AsyncTransportFactory();
>     private AsyncTransportFactory() {
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.transport.TransportFactory#handles(java.net.URI)
>      */
>     protected boolean handles(URI uri) {
>         return "async".equals(uri.getScheme());
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.transport.TransportFactory#createClient()
>      */
>     public TransportClient createClient() {
>         return new AsyncClient();
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.transport.TransportFactory#createSever()
>      */
>     public TransportServer createSever() {
>         if (USE_BLOCKING_IO)
>             return new BlockingServer();
>         return new NonBlockingServer();
>     }
> 
>     /**
>      * Factory method to create AsynchChannel instances.
>      */
>     public Channel createAsynchChannel() {
>         if (USE_BLOCKING_IO)
>             return new BlockingChannel();
>         return new NonBlockingChannel();
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/BackChannelServer.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/BackChannelServer.java
0a1,91
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting.transport.async;
> 
> import java.net.URI;
> 
> import org.apache.geronimo.remoting.transport.Router;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class BackChannelServer extends AbstractServer {
> 
>     private Router dispatcher;
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.transport.TransportServer#bind(java.net.URI, 
> org.apache.geronimo.remoting.transport.Router)
>      */
>     public void bind(URI bindURI, Router dispatcher) throws Exception {
>         this.dispatcher = dispatcher;
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.transport.TransportServer#getClientConnectURI()
>      */
>     public URI getClientConnectURI() {
>         return null;
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.transport.async.AbstractServer#getNextRouter()
>      */
>     public Router getNextRouter() {
>         // TODO Auto-generated method stub
>         return null;
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/Channel.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/Channel.java
0a1,102
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async;
> 
> import java.net.URI;
> 
> import org.apache.geronimo.remoting.transport.TransportException;
> 
> /**
>  * An AsynchChannel allows you to transport bytes of data
>  * back and forth between a client and a server in a async 
>  * manner.
>  * 
>  * This interace abstraction is here so that it can be implemented 
>  * using both the Blocking and Non-blocking IO APIs.
>  * 
>  * @version $Revision$ $Date$
>  */
> public interface Channel {
> 
>     /**
>      * opens a connection to another server.
>      * 
>      * @param uri
>      * @param localURI
>      * @param listner
>      * @throws IOException
>      * @throws ConnectionFailedException
>      */
>     public void open(URI uri, ChannelListner listner) throws 
> TransportException;
> 
>     /**
>      * starts an accepted connection.
>      * 
>      * @param listner
>      * @throws IOException
>      */
>     public void open(ChannelListner listner) throws TransportException;
> 
>     public void close() throws TransportException;
> 
>     /**
>      * Sends an asynch packet of data down the channel.  It does not 
>      * wait wait for a response if possible.
>      */
>     public void send(AsyncMsg data) throws TransportException;
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/ChannelListner.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/ChannelListner.java
0a1,80
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async;
> 
> 
> /**
>  * This interface should be implemented by objects that wants to 
>  * receive Channel events.
>  * 
>  * @version $Revision$ $Date$
>  */
> public interface ChannelListner {
>     
>     /**
>      * Sends an asynch packet of data down the channel.  It does not 
>      * wait wait for a response if possible.
>      */
>     public void receiveEvent(AsyncMsg data);
> 
>     /**
>       * The remote end closed the connection.  The receiver of this event
>       * should close() the channel.
>       */
>     public void closeEvent();
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/ChannelPool.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/ChannelPool.java
0a1,486
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async;
> 
> import java.net.URI;
> import java.net.URISyntaxException;
> import java.util.ArrayList;
> import java.util.Iterator;
> import java.util.List;
> 
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.geronimo.remoting.transport.Msg;
> import org.apache.geronimo.remoting.transport.Router;
> import org.apache.geronimo.remoting.transport.TransportException;
> import org.apache.geronimo.remoting.transport.async.Correlator.FutureResult;
> 
> import EDU.oswego.cs.dl.util.concurrent.Executor;
> import EDU.oswego.cs.dl.util.concurrent.Semaphore;
> /**
>  * a ChannelPool represents a logical connection to a remote uri.
>  * - It handles decomposing synchronous requests into async requests.
>  * - It pools AsychChannel connections to be able concurrently do multiple
>  * asyc sends. 
>  *   
>  * @version $Revision$ $Date$
>  */
> public class ChannelPool implements Router {
> 
>     private static final Log log = LogFactory.getLog(ChannelPool.class);
> 
>     private final URI uri;
>     private final List available = new ArrayList();
>     private final Correlator responseManager = new Correlator();
>     private Router dispatcher;
>     private int createdChannelCount = 0;
>     private Executor workManager = Registry.instance.getWorkManager();
> 
>     private Semaphore maxOpenConnections = new 
> Semaphore(Registry.MAX_CONNECTION_POOL_SIZE);
> 
>     /**
>      * @param uri
>      */
>     public ChannelPool(URI uri, Router dispatcher) {
>         this.uri = uri;
>         this.dispatcher = dispatcher;
>     }
> 
>     public void dispose() {
>         Iterator iterator;
>         synchronized (available) {
>             ArrayList al = new ArrayList();
>             al.addAll(available);
>             iterator = al.iterator();
>         }
>         while (iterator.hasNext()) {
>             PooledAsynchChannel c = (PooledAsynchChannel) iterator.next();
>             try {
>                 c.closeInternal();
>             } catch (Exception e) {
>             }
>         }
>     }
> 
>     /**
>      * An PooledAsynchChannel wraps an AsynchChannel.
>      * The PooledAsynchChannel will trap the close() call to 
>      * return the channel to the pool or potentialy close it.
>      * 
>      * It also maintains usage data to be able to allow
>      * the pool to expire old AsynchChannels.   
>      *
>      * Communication errors will flag the connection to be
>      * removed from the pool. 
>      */
>     private class PooledAsynchChannel implements ChannelListner {
> 
>         private Channel next;
>         boolean doCloseInternal;
>         long lastUsed = System.currentTimeMillis();
> 
>         PooledAsynchChannel(Channel next) {
>             this.next = next;
>             createdChannelCount++;
>         }
> 
>         public void open(URI uri) throws TransportException, 
> TransportException {
>             try {
>                 next.open(uri, this);
>             } catch (TransportException e) {
>                 doCloseInternal = true;
>                 throw e;
>             }
>         }
> 
>         public void open() throws TransportException {
>             try {
>                 next.open(this);
>             } catch (TransportException e) {
>                 doCloseInternal = true;
>                 throw e;
>             }
>         }
> 
>         public void close() throws TransportException {
>             if (doCloseInternal) {
>                 // Don't return. really close it out
>                 closeInternal();
>             } else {
>                 returnToPool(this);
>             }
>         }
> 
>         public void closeInternal() throws TransportException {
>             createdChannelCount--;
>             next.close();
>             maxOpenConnections.release();
>         }
> 
>         public void send(AsyncMsg data) throws TransportException {
>             try {
>                 lastUsed = System.currentTimeMillis();
>                 next.send(data);
>             } catch (TransportException e) {
>                 doCloseInternal = true;
>                 throw e;
>             }
>         }
> 
>         /*
>          * Fail safe in case connections are not being closed 
>          * normally. 
>          */
>         protected void finalize() throws Throwable {
>             try {
>                 closeInternal();
>             } catch (TransportException ignore) {
>             }
>             super.finalize();
>         }
> 
>         public void receiveEvent(AsyncMsg data) {
>             lastUsed = System.currentTimeMillis();
>             dispatch(data);
>         }
> 
>         /* 
>          * Connection was closed by the remote end.
>          */
>         public void closeEvent() {
>             doCloseInternal = true;
>             // If it was still the pool remove it.
>             synchronized (available) {
>                 available.remove(this);
>             }
>             try {
>                 close();
>             } catch (TransportException ignore) {
>             }
>         }
>     }
> 
>     /**
>      * Associate a channel to the pool.
>      * When a AsynchChannelServer accepts a new channel it will
>      * associate the existing AsynchChannel with the pool.
>      * 
>      * TODO: Add some logic to age out old idle connections.
>      */
>     public void associate(Channel c) throws TransportException {
>         synchronized (available) {
>             PooledAsynchChannel channel = new PooledAsynchChannel(c);
>             channel.open();
>             available.add(channel);
>         }
>     }
> 
>     private void returnToPool(PooledAsynchChannel c) {
>         synchronized (available) {
>             available.add(c);
>         }
>     }
> 
>     /**
>      * Expires idle connections
>      * 
>      * @return
>      */
>     public void expireIdleConnections(long connectionTimeout) {
>         synchronized (available) {
>             if (available.isEmpty())
>                 return;
>             long limit = System.currentTimeMillis() - connectionTimeout;
>             for (int i = 0; i < available.size(); i++) {
>                 PooledAsynchChannel pc = (PooledAsynchChannel) 
> available.get(i);
>                 // is it too old??
>                 if (pc.lastUsed < limit) {
>                     available.remove(i);
>                     try {
>                         pc.closeInternal();
>                     } catch (TransportException e) {
>                         log.trace("Could not close out a channel correctly.", 
> e);
>                     }
>                 } else {
>                     // no need to check the rest because they are in LRU 
> order.
>                     break;
>                 }
>             }
>         }
>     }
> 
>     /**
>      * Return the next available AsynchChannel object for a given invocation 
> session.
>      * It will automatically allocate a new AsynchChannel if none are 
> available.
>      *
>      * @return
>      * @throws RemotingException
>      */
>     synchronized public PooledAsynchChannel getNextAvailable() throws 
> TransportException {
> 
>         try {
>             do {
> 
>                 synchronized (available) {
>                     if (available.isEmpty() == false) {
>                         // Remove last to avoid array copy.
>                         return (PooledAsynchChannel) 
> available.remove(available.size() - 1);
>                     }
>                 }
> 
>                 // We fall out of the loop once we aquire a permit to open a 
> connection to the server.  
>             } while (!maxOpenConnections.attempt(100));
> 
>         } catch (InterruptedException e1) {
>             throw new TransportException("(" + uri + "): " + e1);
>         }
> 
>         // not available, make one on demand
>         try {
> 
>             log.debug("channel connecting to: " + uri);
>             PooledAsynchChannel c = new 
> PooledAsynchChannel(AsyncTransportFactory.instance.createAsynchChannel());
>             c.open(uri);
> 
>             return c;
>         } catch (Exception e) {
>             // return the aquired permit.
>             maxOpenConnections.release();
>             log.debug("Connect Failed: ", e);
>             if (log.isDebugEnabled()) {
>                 log.debug("channel connection to: " + uri + " failed", e);
>             }
>             throw new TransportException("(" + uri + "): " + e);
>         }
>     }
> 
>     /**
>      * Used by a PooledAsynchChannel object to dispatch a message.  
>      * 
>      * @param data
>      */
>     private void dispatch(AsyncMsg message) {
>         boolean trace = log.isTraceEnabled();
>         try {
>             switch (message.type) {
>                 case AsyncMsg.DATAGRAM_TYPE :
>                     if (trace)
>                         log.trace("received datagram request data.");
>                     dispatchDatagram(new URI(message.to), message, this);
>                     return;
>                 case AsyncMsg.REQUEST_TYPE :
>                     if (trace)
>                         log.trace("received request data for request: " + 
> message.requestId);
>                     dispatchRequest(new URI(message.to), message, this);
>                     return;
>                 case AsyncMsg.RESPONE_TYPE :
>                     if (trace)
>                         log.trace("received response data for request: " + 
> message.requestId);
>                     responseManager.dispatchResponse(message.requestId, 
> message);
>                     return;
>                 default :
>                     log.warn("Protocol Error: unknown message type: " + 
> message.type);
>                     return;
>             }
>         } catch (URISyntaxException e) {
>             log.debug("Bad request: ", e);
>         }
>     }
> 
>     /**
>      * A ChannelPool will receive data from a Channel and if it is 
>      * new request, it will forward it to the AsynchChannelServer
>      * for it to dispatch the work the appropriate subsystem.
>      *
>      * This a datagram that does not require a response message
>      * to be sent back. 
>      * 
>      * @param data
>      * @param source - the channel pool that the datagram came over.
>      */
>     public void dispatchDatagram(final URI to, final Msg data, final 
> ChannelPool source) {
> 
>         if (dispatcher == null) {
>             log.warn("Received a datagram but the dispatcher has not been 
> registed.");
>             return;
>         }
> 
>         Runnable work = new Runnable() {
>             public void run() {
>                 try {
>                     dispatcher.sendDatagram(to, data);
>                 } catch (Throwable e) {
>                     log.trace("Request Failed.", e);
>                 }
>             }
>         };
>         try {
>             workManager.execute(work);
>         } catch (InterruptedException e) {
>             Thread.currentThread().interrupt();
>         }
>     }
> 
>     /**
>      * A ChannelPool will receive data from a Channel and if it is 
>      * new request, it will forward it to the AsynchChannelServer
>      * for it to dispatch the work the appropriate subsystem.
>      * 
>      * This a request and requires a response message
>      * to be sent back. 
>      * 
>      * @param data
>      * @param source - the channel pool that the request came over.
>      * @param requestId - the requestid of the message.
>      */
>     public void dispatchRequest(final URI to, final AsyncMsg data, final 
> ChannelPool source) {
> 
>         if (dispatcher == null) {
>             log.warn("Received a request but the dispatcher has not been 
> registed.");
>             return;
>         }
> 
>         Runnable work = new Runnable() {
>             public void run() {
>                 try {
>                     Msg result = dispatcher.sendRequest(to, data);
>                     source.sendResponse(result, data.requestId);
>                 } catch (Throwable e) {
>                     log.trace("Request failed.", e);
>                 }
>             }
>         };
>         try {
>             workManager.execute(work);
>         } catch (InterruptedException e) {
>             Thread.currentThread().interrupt();
>         }
>     }
> 
>     private void safeClose(PooledAsynchChannel c) {
>         if (c == null)
>             return;
>         try {
>             c.close();
>         } catch (TransportException e) {
> 
>         }
>     }
> 
>     public void sendDatagram(URI to, Msg data) throws TransportException {
>         AsyncMsg d = (AsyncMsg) data;
>         PooledAsynchChannel c = getNextAvailable();
>         try {
>             d.type = AsyncMsg.DATAGRAM_TYPE;
>             d.to = to.toString();
>             c.send(d);
>         } finally {
>             safeClose(c);
>         }
>     }
> 
>     public Msg sendRequest(URI to, Msg data) throws TransportException {
>         AsyncMsg d = (AsyncMsg) data;
>         PooledAsynchChannel c = getNextAvailable();
>         FutureResult requestId = responseManager.getNextFutureResult();
> 
>         try {
>             d.type = AsyncMsg.REQUEST_TYPE;
>             d.to = to.toString();
>             d.requestId = requestId.getID();
> 
>             if (log.isTraceEnabled())
>                 log.trace("sending request data for request: " + 
> requestId.getID());
>             c.send(d);
> 
>         } finally {
>             safeClose(c);
>         }
> 
>         try {
>             Msg result = (AsyncMsg) requestId.poll(Registry.REQUEST_TIMEOUT);
>             if (log.isTraceEnabled())
>                 log.trace("response data was corelated for request: " + 
> requestId.getID());
>             if (result == null)
>                 throw new TransportException("Request time out.");
>             return result;
>         } catch (InterruptedException e) {
>             throw new TransportException(e.getMessage());
>         }
> 
>     }
> 
>     public void sendResponse(Msg data, int requestId) throws 
> TransportException {
>         AsyncMsg d = (AsyncMsg) data;
>         PooledAsynchChannel c = getNextAvailable();
> 
>         try {
>             d.type = AsyncMsg.RESPONE_TYPE;
>             d.requestId = requestId;
>             if (log.isTraceEnabled())
>                 log.trace("sending response data for request: " + requestId);
>             c.send(d);
>         } finally {
>             safeClose(c);
>         }
>     }
> 
>     public int getCreatedChannelCount() {
>         return createdChannelCount;
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/Compression.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/Compression.java
0a1,131
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async;
> 
> import java.io.IOException;
> import java.util.zip.DataFormatException;
> import java.util.zip.Deflater;
> import java.util.zip.Inflater;
> 
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> 
> /**
>  * Used to add compression at the transport level.
>  *
>  * @version $Revision$ $Date$
>  */
> public class Compression {
> 
>     private static final Log log = LogFactory.getLog(Compression.class);
> 
>     /**
>      * Compresses the input data.
>      * @returns null if compression results in larger output.
>      */
>     static public byte[] compress(byte[] input, int compressionLevel) {
>         Deflater deflater = new Deflater(compressionLevel);
>         deflater.setInput(input, 0, input.length);
>         deflater.finish();
>         byte[] buff = new byte[input.length + 50];
>         int wsize = deflater.deflate(buff);
> 
>         int compressedSize = deflater.getTotalOut();
> 
>         // Did this data compress well?
>         if (deflater.getTotalIn() != input.length)
>             return null;
>         if (compressedSize >= input.length - 4)
>             return null;
> 
>         byte[] output = new byte[compressedSize + 4];
>         System.arraycopy(buff, 0, output, 4, compressedSize);
>         output[0] = (byte) (input.length >> 24);
>         output[1] = (byte) (input.length >> 16);
>         output[2] = (byte) (input.length >> 8);
>         output[3] = (byte) (input.length);
>         return output;
>     }
> 
>     /**
>      * Un-compresses the input data.
>      * @throws IOException if the input is not valid.
>      */
>     static public byte[] uncompress(byte[] input) throws IOException {
>         try {
>             int uncompressedSize =
>                 (((input[0] & 0xff) << 24)
>                     + ((input[1] & 0xff) << 16)
>                     + ((input[2] & 0xff) << 8)
>                     + ((input[3] & 0xff)));
> 
>             Inflater inflater = new Inflater();
>             inflater.setInput(input, 4, input.length - 4);
>             inflater.finished();
> 
>             byte[] out = new byte[uncompressedSize];
>             inflater.inflate(out);
> 
>             inflater.reset();
>             return out;
> 
>         } catch (DataFormatException e) {
>             throw new IOException("Input Stream is corrupt: " + e);
>         }
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/Correlator.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/Correlator.java
0a1,160
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async;
> 
> import java.util.Map;
> import java.util.WeakHashMap;
> 
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> 
> import EDU.oswego.cs.dl.util.concurrent.Slot;
> 
> /**
>  * Allows you to create a request to which
>  * you can at a later time wait for the response to 
>  * arrive asynchrously.
>  * 
>  * @version $Revision$ $Date$
>  */
> public class Correlator {
> 
>     static public class FutureResult extends Slot {
>         private final HashKey key;
> 
>         FutureResult(HashKey key) {
>             this.key = key;
>         }
> 
>         public int getID() {
>             return key.value;
>         }
>     }
> 
>     Log log = LogFactory.getLog(Correlator.class);
> 
>     /**
>      * Since a incrementing int is used as a key to a HashMap,
>      * this class is used to calculate a hashCode that is more 
>      * spred to get better hashing. 
>      */
>     private static class HashKey {
>         final int value;
>         final int hashCode;
> 
>         public HashKey(int value) {
>             this.value = value;
>             long rc = value;
>             if ((value % 2) == 1)
>                 rc *= -1;
>             rc *= Integer.MAX_VALUE / 7;
>             hashCode = (int) (rc % Integer.MAX_VALUE);
>         }
>         /**
>          * Not a very proper equals since it takes
>          * shortcuts, but since this class is not used
>          * in a general case, it's ok. 
>          */
>         public boolean equals(Object obj) {
>             return ((HashKey) obj).value == value;
>         }
>         public int hashCode() {
>             return hashCode;
>         }
>     }
> 
>     private Map slots = new WeakHashMap(100);
>     private int nextFutureResultID = 0;
>     private Object nextFutureResultIDLock = new Object();
> 
>     private int getNextFutureResultID() {
>         synchronized (nextFutureResultIDLock) {
>             return nextFutureResultID++;
>         }
>     }
> 
>     public FutureResult getNextFutureResult() {
>         HashKey key = new HashKey(getNextFutureResultID());
>         FutureResult s = new FutureResult(key);
>         synchronized (slots) {
>             slots.put(key, s);
>         }
>         if (log.isTraceEnabled())
>             log.trace("Created Request: " + key.value);
>         return s;
>     }
> 
>     public void dispatchResponse(int id, Object data) {
>         if (log.isTraceEnabled())
>             log.trace("Received resposne for request: " + id);
> 
>         FutureResult s;
>         synchronized (slots) {
>             s = (FutureResult) slots.get(new HashKey(id));
>         }
>         if (s != null) {
>             try {
>                 s.put(data);
>             } catch (InterruptedException e) {
>                 Thread.currentThread().interrupt();
>             }
>         } else {
>             log.trace("The request may have timed out.  Request slot was not 
> found");
>         }
> 
>     }
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/Registry.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/Registry.java
0a1,210
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async;
> 
> import java.net.URI;
> 
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> 
> import EDU.oswego.cs.dl.util.concurrent.ClockDaemon;
> import EDU.oswego.cs.dl.util.concurrent.Executor;
> import EDU.oswego.cs.dl.util.concurrent.PooledExecutor;
> import EDU.oswego.cs.dl.util.concurrent.ThreadFactory;
> 
> /**
>  * An application wide registry to hold objects that
>  * must be shared accross application components. 
>  * 
>  * @version $Revision$ $Date$
>  */
> public class Registry {
> 
>     /** The amount of time that must pass before a request is considered 
> timedout. */
>     static public final long REQUEST_TIMEOUT =
>         
> Long.parseLong(System.getProperty("org.apache.geronimo.remoting.transport.async.request_timeout",
>  "60000"));  // 1 min.
>     /** The maximum number of open connections that are allowed per pool.  A 
> new pool is allocated to each sever this vm connects to. */
>     static public final int MAX_CONNECTION_POOL_SIZE =
>         
> Integer.parseInt(System.getProperty("org.apache.geronimo.remoting.transport.async.max_connection_per_pool",
>  "25"));
> 
>     static private final Log log = LogFactory.getLog(Registry.class);
>     static public final Registry instance = new Registry();
> 
>     private AbstractServer dynamicServer;
>     private AbstractServer defaultServer;
>     private PooledExecutor workManager;
> 
>     /**
>      * Manages the thread that can used to schedule short 
>      * running tasks in the future.
>      */
>     protected ClockDaemon clockDaemon;
>     public boolean MOCK_APPLET_SECURITY = false;
> 
> 
>     private int nextWorkerID = 0;
>     private int getNextWorkerID() {
>         return nextWorkerID++;
>     }
>     /**
>      * Provides a thread pool that can be shared accros components.
>      */
>     synchronized public Executor getWorkManager() {
>         if (workManager != null)
>             return workManager;
> 
>         PooledExecutor p = new PooledExecutor();
>         p.setKeepAliveTime(1000 * 30);
>         p.setMinimumPoolSize(5);
>         p.setMaximumPoolSize(Integer.MAX_VALUE);
>         p.setThreadFactory(new ThreadFactory() {
>             public Thread newThread(Runnable arg0) {
>                 return new Thread(arg0, "Remoting 'async' protocol worker " + 
> getNextWorkerID());
>             }
>         });
> 
>         workManager = p;
>         return workManager;
>     }
> 
>     /**
>      * @return
>      */
>     public ClockDaemon getClockDaemon() {
>         if (clockDaemon != null)
>             return clockDaemon;
>         clockDaemon = new ClockDaemon();
>         clockDaemon.setThreadFactory(new ThreadFactory() {
>             public Thread newThread(Runnable r) {
>                 Thread t = new Thread(r, "Remoting 'async' protocol monitor");
>                 t.setDaemon(true);
>                 return t;
>             }
>         });
>         return clockDaemon;
>     }
> 
>     /**
>      * Gets the system wide AbstractServer.  If a AbstractServer
>      * has not been registed explicitly,
>      * It attempts to create an AsynchChannelServer that listens on an 
>      * annonymous port.  Returns a BackChannelServer if a normal
>      * server could not be bound.
>      */
>     synchronized public AbstractServer getServerForClientRequest() {
>         if (defaultServer != null)
>             return defaultServer;
>         if (dynamicServer != null)
>             return dynamicServer;
> 
>         // This jvm did not have a server running.  try to start the
>         // server on a dynamic port.
>         try {
> 
>             if (MOCK_APPLET_SECURITY) {
>                 dynamicServer = createBackChannelServer();
>                 return dynamicServer;
>             }
> 
>             dynamicServer = (AbstractServer) 
> AsyncTransportFactory.instance.createSever();
> 
>             // TODO: find a way to get a dispatcher to pass to the bind call.
>             dynamicServer.bind(new URI("async://0.0.0.0:0"), null);
>             dynamicServer.start();
>             return dynamicServer;
> 
>         } catch (Throwable e) {
>             dynamicServer = createBackChannelServer();
>             return dynamicServer;
>         }
>     }
> 
>     /**
>      * @return
>      */
>     private AbstractServer createBackChannelServer() {
>         try {
>             BackChannelServer server = new BackChannelServer();
>             server.bind(new URI("async://0.0.0.0:0"), null);
>             server.start();
>             return server;
>         } catch (Exception e) {
>             // wont happen!
>             throw new RuntimeException(e.getMessage());
>         }
>     }
> 
>     /**
>      * Sets the application wide server.  This gets called when running
>      * in the sever and the server is explicity configured.
>      * 
>      * @param server
>      */
>     synchronized public void setDefaultServer(AbstractServer server) {
>         defaultServer = server;
>     }
> 
>     /**
>      * Sets the application wide server.  This gets called when running
>      * in the sever and the server is explicity configured.
>      * 
>      * @param server
>      */
>     synchronized public AbstractServer getDefaultServer() {
>         return defaultServer;
>     }
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/bio/BlockingChannel.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/bio/BlockingChannel.java
0a1,396
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async.bio;
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.DataInputStream;
> import java.io.DataOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.OutputStream;
> import java.io.StreamCorruptedException;
> import java.net.InetAddress;
> import java.net.InetSocketAddress;
> import java.net.URI;
> import java.net.URISyntaxException;
> import java.nio.ByteBuffer;
> import java.nio.channels.SocketChannel;
> import java.util.Properties;
> import java.util.zip.Deflater;
> import java.util.zip.DeflaterOutputStream;
> import java.util.zip.Inflater;
> import java.util.zip.InflaterInputStream;
> 
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.geronimo.proxy.SimpleComponent;
> import org.apache.geronimo.remoting.transport.ConnectionFailedException;
> import org.apache.geronimo.remoting.transport.TransportException;
> import org.apache.geronimo.remoting.transport.URISupport;
> import org.apache.geronimo.remoting.transport.async.AsyncMsg;
> import org.apache.geronimo.remoting.transport.async.Channel;
> import org.apache.geronimo.remoting.transport.async.ChannelListner;
> import org.apache.geronimo.remoting.transport.async.Registry;
> /**
>  * The Blocking implementation of the AsynchChannel interface.  
>  * 
>  * This implemenation uses the standard Java 1.3 blocking socket IO.
>  *
>  * @version $Revision$ $Date$
>  */
> public class BlockingChannel extends SimpleComponent implements Runnable, 
> Channel {
> 
>     static final private Log log = LogFactory.getLog(BlockingChannel.class);
> 
>     private ChannelListner listner;
>     private Thread worker;
>     private SocketChannel socketChannel;
>     private URI remoteURI;
>     private boolean closing = false;
> 
>     private Inflater inflator;
>     private Deflater deflater;
> 
>     public void open(URI remoteURI, ChannelListner listner) throws 
> TransportException {
> 
>         if (log.isTraceEnabled())
>             log.trace("Connecting to : " + remoteURI);
> 
>         this.listner = listner;
>         this.remoteURI = remoteURI;
>         int port = remoteURI.getPort();
>         boolean enableTcpNoDelay = true;
> 
>         Properties params = URISupport.parseQueryParameters(remoteURI);
>         enableTcpNoDelay = params.getProperty("tcp.nodelay", 
> "true").equals("true");
>         int compression = Integer.parseInt(params.getProperty("compression", 
> "-1"));
> 
>         try {
>             InetAddress addr = InetAddress.getByName(remoteURI.getHost());
>             socketChannel = SocketChannel.open();
>             socketChannel.configureBlocking(true);
>             socketChannel.connect(new InetSocketAddress(addr, port));
>         } catch (Exception e) {
>             throw new ConnectionFailedException("" + e);
>         }
>         try {
>             socketChannel.socket().setTcpNoDelay(enableTcpNoDelay);
> 
>             DataOutputStream out = new 
> DataOutputStream(socketChannel.socket().getOutputStream());
>             out.writeUTF(remoteURI.toString());
>             if (Registry.instance.getServerForClientRequest() == null)
>                 out.writeUTF("async://" + 
> socketChannel.socket().getLocalAddress().getHostAddress() + ":0");
>             else
>                 
> out.writeUTF(Registry.instance.getServerForClientRequest().getClientConnectURI().toString());
>             out.flush();
>             
>             if (compression != -1) {
>                 inflator = new Inflater(true);
>                 deflater = new Deflater(compression, true);
>             }
>             
>         } catch (Exception e) {
>             throw new TransportException("Connection handshake failed: " + e);
>         }
> 
>         worker = new Thread(this, "Channel -> " + remoteURI);
>         worker.setDaemon(true);
>         worker.start();
>     }
> 
>     public void init(URI localURI, SocketChannel socketChannel) throws 
> IOException, URISyntaxException {
>         this.socketChannel = socketChannel;
> 
>         DataOutputStream out = new 
> DataOutputStream(socketChannel.socket().getOutputStream());
>         out.flush();
> 
>         DataInputStream in = new 
> DataInputStream(socketChannel.socket().getInputStream());
>         // Use to get connection options.
>         String destURI = in.readUTF();
>         // Use in case we need to establish new connections back to 
>         // the source vm.  Could be null.
>         String sourceURI = in.readUTF();
>         this.remoteURI = new URI(sourceURI);
>         if (log.isTraceEnabled()) {
>             log.trace("Connected from : " + remoteURI);
>             log.trace("Request URI    : " + destURI);
>         }
> 
>         // What options did the client want to use with this connection?      
>         
>         URI rruri = new URI(destURI);
>         boolean enableTcpNoDelay = true;
>         Properties params = URISupport.parseQueryParameters(rruri);
>         enableTcpNoDelay = params.getProperty("tcp.nodelay", 
> "true").equals("true");
>         int compression = Integer.parseInt((String) 
> params.getProperty("compression", "-1"));
> 
>         if (compression != -1) {
>             inflator = new Inflater(true);
>             deflater = new Deflater(compression, true);
>         }
> 
>         /*
>         */
>         socketChannel.socket().setTcpNoDelay(enableTcpNoDelay);
>         if (log.isTraceEnabled()) {
>             log.trace("Compression level : " + compression);
>             log.trace("tcp no delay : " + enableTcpNoDelay);
>         }
>     }
> 
>     public void open(ChannelListner listner) throws TransportException {
>         this.listner = listner;
>         worker = new Thread(this, "Channel <- " + remoteURI);
>         worker.setDaemon(true);
>         worker.start();
>     }
> 
>     static int nextId = 0;
>     /**
>      * @return
>      */
>     synchronized private int getNextID() {
>         return nextId++;
>     }
> 
>     private Object sendMutex = new Object();
>     public void send(AsyncMsg data) throws TransportException {
>         try {
>             ByteBuffer buffers[] = serialize(data);
>             synchronized (sendMutex) {
>                 if (closing)
>                     throw new TransportException("connection has been 
> closed.");
>                 // should block. 
>                 socketChannel.write(buffers);
>             }
>         } catch (IOException e) {
>             throw new TransportException("" + e);
>         }
>     }
> 
>     /**
>      * @param data
>      * @return
>      */
>     private ByteBuffer[] serialize(AsyncMsg data) throws IOException {
>         ByteBuffer rc[] = new ByteBuffer[2];
>         rc[0] = ByteBuffer.allocate(4);
> 
>         ByteArrayOutputStream baos = new ByteArrayOutputStream();
>         OutputStream t=baos;
>         if (deflater!=null) 
>             t = new DeflaterOutputStream(t, deflater);
>         DataOutputStream out = new DataOutputStream(t);
> 
>         data.writeExternal(out);
>         out.close();
>         rc[1] = ByteBuffer.wrap(baos.toByteArray());
>         rc[0].putInt(rc[1].limit());
>         
>         rc[0].rewind();        
>         rc[1].rewind();        
>         return rc;
>     }
> 
>     /**
>      * @param buffer
>      */
>     public AsyncMsg deserialize(ByteBuffer[] message) throws IOException  {
>         AsyncMsg asyncMsg = new AsyncMsg();
> 
>         InputStream t=new ByteArrayInputStream( message[1].array());
>         if (inflator!=null) 
>             t = new InflaterInputStream(t, inflator);
>         DataInputStream in = new DataInputStream( t );
> 
>         asyncMsg.readExternal(in);
>         in.close();
>         return asyncMsg;        
>     }
> 
> 
>     /* (non-Javadoc)
>      * @see java.lang.Runnable#run()
>      */
>     public void run() {
>         
>         ByteBuffer message[] = new ByteBuffer[]{
>                 ByteBuffer.allocate(4), 
>                 ByteBuffer.allocate(1024*10) 
>                 };
>         
>         try {
>             while (true) {
>                 
>                 log.trace("Waiting for message");
>                 message[0].clear();
>                 socketChannel.read(message[0]);
>                 if( message[0].position()!=4 ) 
>                     throw new StreamCorruptedException("Did not receive the 
> full message header.");
>                 message[0].flip();
>                 int size = message[0].getInt();
>                 
>                 // Signal from remote that the socket is being closed.
>                 if( size==-1 )
>                     break;
> 
>                 // Do we need a bigger buffer?
>                 // TODO: should we have a max size the buffer can grow to?    
>                  
>                 if( size > message[1].capacity() )
>                     message[1] = ByteBuffer.allocate(size);
>                     
>                 // Load the body.                     
>                 message[1].clear();
>                 message[1].limit(size);
>                 socketChannel.read(message[1]);
>                 if( message[1].position()!=size ) 
>                     throw new StreamCorruptedException("Did not receive the 
> full message body.");
>                 message[1].flip();                
>                 listner.receiveEvent(deserialize(message));
>             }
>         } catch (IOException e) {
>             // The remote end died on us.
>         } finally {
>             asyncClose();
>         }
>         log.trace("Stopped");
>     }
> 
>     /**
>      * Starts to terminate the connection.  Lets the remote end
>      * know that we are closing.
>      * 
>      * The server side calls this close.  Could be called in response to
>      * 2 events:
>      * - we initiated the close() (so we finish the close)
>      * - An asynch error initiated the close(). (so we start the close 
> process)
>      * We keep state to know if we started the socket close().  
>      */
>     synchronized private void asyncClose() {
>         // socket is null when we finish close()
>         if (socketChannel == null)
>             return;
>         try {
>             socketChannel.socket().shutdownInput();
>             // were we allready closing??             
>             if (closing) {
>                 // both side should be shutdown now.  finish close.
>                 socketChannel.close();
>             } else {
>                 closing = true;
>                 listner.closeEvent();
>             }
>         } catch (IOException e) {
>             // If the 'nice' shutdown fails at any point,
>             // then do the forced shutdown.
>             forcedClose();
>         }
>     }
> 
>     /**
>      * Starts to terminate the connection.  Lets the remote end
>      * know that we are closing.
>      * 
>      * The client side calls this close.  Could be called in response to
>      * 2 events:
>      * - the remote sever initiated the close(). (so we finish the close)
>      * - we initiated the close() (so we wait for the remote side to finish 
> the close)
>      * We keep state to know if we started the socket close().  
>      *   
>      */
>     synchronized public void close() {
>         // socket is null when we finish close()
>         if (socketChannel == null)
>             return;
>         try {
>             ByteBuffer buffer = ByteBuffer.allocate(4);
>             buffer.asIntBuffer().put(-1);
>             synchronized (sendMutex) {
>                 socketChannel.write(buffer);
>                 socketChannel.socket().shutdownOutput();
>             }
>             // were we allready closing??             
>             if (closing) {
>                 // both side should be shutdown now.  finish close.
>                 socketChannel.close();
>                 socketChannel = null;
>             } else {
>                 closing = true;
>             }
>         } catch (IOException e) {
>             forcedClose();
>         }
>     }
> 
>     /**
>      * forcibly terminates the connection without telling the remote end 
>      * that the connection is being closed. 
>      */
>     private void forcedClose() {
>         try {
>             socketChannel.close();
>         } catch (Throwable e) {
>         }
>         socketChannel = null;
>     }
> 
>     /**
>      * @return
>      */
>     public URI getRemoteURI() {
>         return remoteURI;
>     }
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/bio/BlockingServer.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/bio/BlockingServer.java
0a1,248
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async.bio;
> import java.io.IOException;
> import java.net.InetAddress;
> import java.net.InetSocketAddress;
> import java.net.SocketException;
> import java.net.URI;
> import java.net.URISyntaxException;
> import java.nio.channels.ServerSocketChannel;
> import java.nio.channels.SocketChannel;
> import java.util.Properties;
> 
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.geronimo.remoting.transport.Router;
> import org.apache.geronimo.remoting.transport.TransportException;
> import org.apache.geronimo.remoting.transport.URISupport;
> import org.apache.geronimo.remoting.transport.async.AbstractServer;
> import org.apache.geronimo.remoting.transport.async.ChannelPool;
> /**
>  * Provides a Blocking implemenation of the AsynchChannelServer interface.
>  * 
>  * Sets up a blocking ServerSocket to accept blocking client connections.
>  * 
>  * @version $Revision$ $Date$
>  */
> public final class BlockingServer extends AbstractServer implements Runnable {
>     final static private Log log = LogFactory.getLog(BlockingServer.class);
> 
>     /**
>      * The default timeout for the server socket. This is
>      * set so the socket will periodically return to check
>      * the running flag.
>      */
>     private final static int SO_TIMEOUT = 5000;
>     private ServerSocketChannel serverSocketChannel;
>     private URI uri;
>     private URI connectURI;
>     private Thread worker;
>     private boolean running;
>     private int compression = -1;
>     private boolean enableTcpNoDelay;
>     private Router nextRouter;
> 
>     public void bind(URI localURI, Router dispatcher) throws IOException, 
> URISyntaxException {
>         this.uri = localURI;
>         this.nextRouter = dispatcher;
> 
>         String serverBindAddress = uri.getHost();
>         String clientConnectAddress = null;
>         int serverBindPort = uri.getPort();
>         int clientConnectPort = serverBindPort;
>         int connectBackLog = 50;
>         enableTcpNoDelay = true;
> 
>         Properties params = URISupport.parseQueryParameters(uri);
>         enableTcpNoDelay = params.getProperty("tcp.nodelay", 
> "true").equals("true");
>         connectBackLog = Integer.parseInt(params.getProperty("tcp.backlog", 
> "50"));
>         clientConnectAddress = params.getProperty("client.host");
>         clientConnectPort = 
> Integer.parseInt(params.getProperty("client.port", "0"));
>         clientConnectPort = 
> Integer.parseInt(params.getProperty("compression", "-1"));
> 
>         compression = Math.min(compression, 9);
>         compression = Math.max(compression, -1);
> 
>         serverSocketChannel = ServerSocketChannel.open();
>         serverSocketChannel.socket().bind(new 
> InetSocketAddress(InetAddress.getByName(serverBindAddress), 
> serverBindPort),connectBackLog);
>         serverSocketChannel.socket().setSoTimeout(SO_TIMEOUT);
> 
>         // Lookup the local host name if needed.
>         clientConnectAddress =
>             (clientConnectAddress == null || clientConnectAddress.length() == 
> 0)
>                 ? InetAddress.getLocalHost().getHostName()
>                 : clientConnectAddress;
>         clientConnectPort = (clientConnectPort <= 0) ? 
> serverSocketChannel.socket().getLocalPort() : clientConnectPort;
> 
>         // Create the client URI:
>         Properties clientParms = new Properties();
>         clientParms.put("tcp.nodelay", enableTcpNoDelay ? "true" : "false");
>         clientParms.put("compression", "" + compression);
>         this.connectURI =
>             new URI(
>                 "async",
>                 null,
>                 clientConnectAddress,
>                 clientConnectPort,
>                 "",
>                 URISupport.toQueryString(clientParms),
>                 null);
>         log.info(
>             "Remoting 'async' protocol available at: "
>                 + serverSocketChannel.socket().getInetAddress()
>                 + ":"
>                 + serverSocketChannel.socket().getLocalPort());
>         log.info("Remoting 'async' protocol clients will connect to: " + 
> connectURI);
>     }
> 
>     synchronized public void start() throws Exception {
>         if (running)
>             return;
>         running = true;
>         worker = new Thread(this, "Acceptor " + getClientConnectURI());
>         worker.setDaemon(true);
>         worker.start();
>         super.start();
>     }
> 
>     public void stop() throws Exception {
>         if (!running)
>             return;
>         running = false;
>         try {
>             worker.interrupt();
>             worker.join();
>         } catch (InterruptedException e) {
>         }
>         super.stop();
>     }
> 
>     /**
>      * @see java.lang.Runnable#run()
>      */
>     public void run() {
>         try {
>             while (running) {
>                 SocketChannel socket = null;
>                 try {
>                     socket = serverSocketChannel.accept();
>                     if (log.isTraceEnabled())
>                         log.trace("Accepted connection: " + socket);
>                 } catch (java.io.InterruptedIOException e) {
>                     // It's ok, this is due to the SO_TIME_OUT
>                     continue;
>                 }
>                 try {
>                     socket.socket().setTcpNoDelay(enableTcpNoDelay);
>                     BlockingChannel channel = new BlockingChannel();
>                     channel.init(connectURI, socket);
>                     ChannelPool pool = getChannelPool(channel.getRemoteURI());
>                     pool.associate(channel);
>                 } catch (TransportException ie) {
>                     log.debug("Client connection could not be accepted: ", 
> ie);
>                 } catch (IOException ie) {
>                     log.debug("Client connection could not be accepted: ", 
> ie);
>                 } catch (URISyntaxException e) {
>                     log.debug("Client connection could not be accepted: ", e);
>                 }
>             }
>         } catch (SocketException e) {
>             // There is no easy way (other than string comparison) to
>             // determine if the socket exception is caused by connection
>             // reset by peer. In this case, it's okay to ignore both
>             // SocketException and IOException.
> 
>             if (running) // We may have been stopped.
>                 log.warn(
>                     "SocketException occured (Connection reset by peer?). 
> Shutting down remoting 'async' protocol.");
>         } catch (IOException e) {
>             if (running) // We may have been stopped.
>                 log.warn("IOException occured. Shutting down remoting 'async' 
> protocol.");
>         }
>     }
> 
>     /**
>      * @see 
> org.apache.j2ee.remoting.transport.TransportServer#getClientConnectURI()
>      */
>     public URI getClientConnectURI() {
>         return connectURI;
>     }
> 
>     /**
>      * @see org.apache.j2ee.remoting.transport.TransportServer#dispose()
>      */
>     public void dispose() throws Exception {
> 
>         if (running) {
>             // we were disposed before a stop!  Shutdown QUICK.
>             running = false;
>             worker.interrupt();
>         }
>         serverSocketChannel.close();
> 
>         super.dispose();
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.transport.async.AbstractServer#getNextRouter()
>      */
>     public Router getNextRouter() {
>         return nextRouter;
>     }
> }
> // vim:expandtab:tabstop=3:shiftwidth=3
\ No newline at end of file
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/nio/NonBlockingChannel.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/nio/NonBlockingChannel.java
0a1,473
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async.nio;
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.DataInputStream;
> import java.io.DataOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.OutputStream;
> import java.net.InetAddress;
> import java.net.InetSocketAddress;
> import java.net.URI;
> import java.net.URISyntaxException;
> import java.nio.ByteBuffer;
> import java.nio.channels.SelectionKey;
> import java.nio.channels.SocketChannel;
> import java.util.Properties;
> import java.util.zip.Deflater;
> import java.util.zip.DeflaterOutputStream;
> import java.util.zip.Inflater;
> import java.util.zip.InflaterInputStream;
> 
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.geronimo.proxy.SimpleComponent;
> import org.apache.geronimo.remoting.transport.ConnectionFailedException;
> import org.apache.geronimo.remoting.transport.TransportException;
> import org.apache.geronimo.remoting.transport.URISupport;
> import org.apache.geronimo.remoting.transport.async.AsyncMsg;
> import org.apache.geronimo.remoting.transport.async.Channel;
> import org.apache.geronimo.remoting.transport.async.ChannelListner;
> import org.apache.geronimo.remoting.transport.async.Registry;
> 
> import EDU.oswego.cs.dl.util.concurrent.Mutex;
> /**
>  * The Blocking implementation of the AsynchChannel interface.  
>  * 
>  * This implemenation uses the standard Java 1.3 blocking socket IO.
>  *
>  * @version $Revision$ $Date$
>  */
> public class NonBlockingChannel extends SimpleComponent implements Channel, 
> SelectionEventListner {
> 
>     static final private Log log = 
> LogFactory.getLog(NonBlockingChannel.class);
> 
>     private ChannelListner listner;
>     private Thread worker;
>     private SocketChannel socketChannel;
>     private URI remoteURI;
>     private boolean closing = false;
> 
>     private Inflater inflator;
>     private Deflater deflater;
> 
>     private SelectorManager selectorManager;
>     private SelectionKey selectionKey;
> 
>     public void open(URI remoteURI, ChannelListner listner) throws 
> TransportException {
> 
>         if (log.isTraceEnabled())
>             log.trace("Connecting to : " + remoteURI);
> 
>         this.listner = listner;
>         this.remoteURI = remoteURI;
>         int port = remoteURI.getPort();
>         boolean enableTcpNoDelay = true;
> 
>         Properties params = URISupport.parseQueryParameters(remoteURI);
>         enableTcpNoDelay = params.getProperty("tcp.nodelay", 
> "true").equals("true");
>         int compression = Integer.parseInt(params.getProperty("compression", 
> "-1"));
> 
>         try {
>             InetAddress addr = InetAddress.getByName(remoteURI.getHost());
>             socketChannel = SocketChannel.open();
>             socketChannel.configureBlocking(true);
>             socketChannel.connect(new InetSocketAddress(addr, port));
>         } catch (Exception e) {
>             throw new ConnectionFailedException("" + e);
>         }
>         try {
>             socketChannel.socket().setTcpNoDelay(enableTcpNoDelay);
> 
>             DataOutputStream out = new 
> DataOutputStream(socketChannel.socket().getOutputStream());
>             out.writeUTF(remoteURI.toString());
>             if (Registry.instance.getServerForClientRequest() == null)
>                 out.writeUTF("async://" + 
> socketChannel.socket().getLocalAddress().getHostAddress() + ":0");
>             else
>                 
> out.writeUTF(Registry.instance.getServerForClientRequest().getClientConnectURI().toString());
>             out.flush();
> 
>             if (compression != -1) {
>                 inflator = new Inflater(true);
>                 deflater = new Deflater(compression, true);
>             }
> 
>             // Setup the selector            
>             socketChannel.configureBlocking(false); // Make the connect be 
> non-blocking.
>             selectorManager = SelectorManager.getInstance();
>             selectorManager.start();
>             selectionKey = selectorManager.register( socketChannel, 
> SelectionKey.OP_READ, this);
> 
>         } catch (Exception e) {
>             throw new TransportException("Connection handshake failed: " + e);
>         }
> 
>     }
> 
>     public void init(URI localURI, SocketChannel socketChannel) throws 
> IOException, URISyntaxException {
>         this.socketChannel = socketChannel;
> 
>         DataOutputStream out = new 
> DataOutputStream(socketChannel.socket().getOutputStream());
>         out.flush();
> 
>         DataInputStream in = new 
> DataInputStream(socketChannel.socket().getInputStream());
>         // Use to get connection options.
>         String destURI = in.readUTF();
>         // Use in case we need to establish new connections back to 
>         // the source vm.  Could be null.
>         String sourceURI = in.readUTF();
>         this.remoteURI = new URI(sourceURI);
>         if (log.isTraceEnabled()) {
>             log.trace("Connected from : " + remoteURI);
>             log.trace("Request URI    : " + destURI);
>         }
> 
>         // What options did the client want to use with this connection?      
>         
>         URI rruri = new URI(destURI);
>         boolean enableTcpNoDelay = true;
>         Properties params = URISupport.parseQueryParameters(rruri);
>         enableTcpNoDelay = params.getProperty("tcp.nodelay", 
> "true").equals("true");
>         int compression = Integer.parseInt((String) 
> params.getProperty("compression", "-1"));
> 
>         if (compression != -1) {
>             inflator = new Inflater(true);
>             deflater = new Deflater(compression, true);
>         }
> 
>         /*
>         */
>         socketChannel.socket().setTcpNoDelay(enableTcpNoDelay);
>         if (log.isTraceEnabled()) {
>             log.trace("Compression level : " + compression);
>             log.trace("tcp no delay : " + enableTcpNoDelay);
>         }
>     }
> 
>     public void open(ChannelListner listner) throws TransportException {
>         try {
>             this.listner = listner;
>             
>             // Setup the selector            
>             socketChannel.configureBlocking(false); // Make the connect be 
> non-blocking.
>             selectorManager = SelectorManager.getInstance();
>             selectorManager.start();
>             selectionKey = selectorManager.register( socketChannel, 
> SelectionKey.OP_READ, this);
>             
>         } catch (Exception e) {
>             throw new TransportException("Connection handshake failed: " + e);
>         }
>     }
> 
>     static int nextId = 0;
>     /**
>      * @return
>      */
>     synchronized private int getNextID() {
>         return nextId++;
>     }
> 
>     /**
>      * @param data
>      * @return
>      */
>     private ByteBuffer[] serialize(AsyncMsg data) throws IOException {
>         ByteBuffer rc[] = new ByteBuffer[2];
>         rc[0] = ByteBuffer.allocate(4);
> 
>         ByteArrayOutputStream baos = new ByteArrayOutputStream();
>         OutputStream t = baos;
>         if (deflater != null)
>             t = new DeflaterOutputStream(t, deflater);
>         DataOutputStream out = new DataOutputStream(t);
> 
>         data.writeExternal(out);
>         out.close();
>         rc[1] = ByteBuffer.wrap(baos.toByteArray());
>         rc[0].putInt(rc[1].limit());
> 
>         rc[0].rewind();
>         rc[1].rewind();
>         return rc;
>     }
> 
>     /**
>      * @param buffer
>      */
>     public AsyncMsg deserialize(ByteBuffer[] message) throws IOException {
>         AsyncMsg asyncMsg = new AsyncMsg();
> 
>         InputStream t = new ByteArrayInputStream(message[1].array());
>         if (inflator != null)
>             t = new InflaterInputStream(t, inflator);
>         DataInputStream in = new DataInputStream(t);
> 
>         asyncMsg.readExternal(in);
>         in.close();
>         return asyncMsg;
>     }
> 
>     /**
>      * Starts to terminate the connection.  Lets the remote end
>      * know that we are closing.
>      * 
>      * The server side calls this close.  Could be called in response to
>      * 2 events:
>      * - we initiated the close() (so we finish the close)
>      * - An asynch error initiated the close(). (so we start the close 
> process)
>      * We keep state to know if we started the socket close().  
>      */
>     synchronized private void asyncClose() {
>         // socket is null when we finish close()
>         if (socketChannel == null)
>             return;
>         try {
>             socketChannel.socket().shutdownInput();
>             // were we allready closing??             
>             if (closing) {
>                 // both side should be shutdown now.  finish close.
>                 forcedClose();            
>             } else {
>                 closing = true;
>                 listner.closeEvent();
>             }
>             
>             
>         } catch (IOException e) {
>             // If the 'nice' shutdown fails at any point,
>             // then do the forced shutdown.
>             forcedClose();
>         }
>     }
> 
>     /**
>      * Starts to terminate the connection.  Lets the remote end
>      * know that we are closing.
>      * 
>      * The client side calls this close.  Could be called in response to
>      * 2 events:
>      * - the remote sever initiated the close(). (so we finish the close)
>      * - we initiated the close() (so we wait for the remote side to finish 
> the close)
>      * We keep state to know if we started the socket close().  
>      *   
>      */
>     synchronized public void close() {
>         // socket is null when we finish close()
>         if (socketChannel == null)
>             return;
>         try {
>             ByteBuffer buffer = ByteBuffer.allocate(4);
>             buffer.asIntBuffer().put(-1);
>             synchronized (sendMutex) {
>                 socketChannel.write(buffer);
>                 socketChannel.socket().shutdownOutput();
>             }
>             // were we allready closing??             
>             if (closing) {
>                 // both side should be shutdown now.  finish close.
>                 forcedClose();            
>             } else {
>                 closing = true;
>             }
>         } catch (IOException e) {
>             forcedClose();
>         }
>     }
> 
>     /**
>      * forcibly terminates the connection without telling the remote end 
>      * that the connection is being closed. 
>      */
>     private void forcedClose() {
>         if( socketChannel == null )
>             return;
>         try {
>             selectionKey.cancel();
>             socketChannel.close();
>             socketChannel = null;
>             SelectorManager.getInstance().stop();            
>         } catch (Throwable e) {
>         }
>         socketChannel = null;
>     }
> 
>     /**
>      * @return
>      */
>     public URI getRemoteURI() {
>         return remoteURI;
>     }
> 
>     synchronized public void selectionEvent(SelectionKey selection) {
>         if (selection.isWritable())
>             serviceWrite();
>         if (selection.isReadable())
>             serviceRead();
>     }
> 
> 
>     Mutex sendMutex = new Mutex();
> 
>     /**
>      */
>     public void send(AsyncMsg data) throws TransportException {
>         try {
>             ByteBuffer buffers[] = serialize(data);
>             
>             if( !sendMutex.attempt(10000) )
>                 throw new TransportException("Send timeout.");
>             if (closing)
>                 throw new TransportException("connection has been closed.");
>             sendBuffer = buffers;
>             
>             flushSendBuffer();
>             
>         } catch (IOException e) {
>             throw new TransportException("" + e);
>         } catch (InterruptedException e) {
>             throw new TransportException("" + e);
>         }
>     }
> 
> 
>     /**
>      * 
>      */
>     private void flushSendBuffer() throws IOException {
>         socketChannel.write(sendBuffer);
>         if ( sendBuffer[1].hasRemaining()  ) {
>             // not all was delivered in this call setup selector
>             // so we setup to finish sending async.            
>             selectorManager.setInterestOps(selectionKey, SelectionKey.OP_READ 
> | SelectionKey.OP_WRITE);
>             
>         } else {
>             // We are done writing.
>             selectorManager.setInterestOps(selectionKey, 
> SelectionKey.OP_READ);
>             sendMutex.release();
>         }
>     }
> 
>     ByteBuffer receiveBuffer[] = new ByteBuffer[] { ByteBuffer.allocate(4), 
> ByteBuffer.allocate(1024 * 10)};
>     ByteBuffer sendBuffer[] = new ByteBuffer[] { ByteBuffer.allocate(4), 
> ByteBuffer.allocate(0)};
> 
>     private void serviceWrite() {
>         try {
>             flushSendBuffer();                
>         } catch (IOException e) {
>             log.debug("Communications error, closing connection: ", e);
>             asyncClose();
>         }
>     }
> 
>     private void serviceRead() {
> 
>         boolean tracing = log.isTraceEnabled();
> 
>         if (tracing)
>             log.trace("ReadDataAction triggered.");
> 
>         try {
>             while (true) {
> 
>                 // Are we reading the header??
>                 if (receiveBuffer[0].hasRemaining()) {
>                     if (tracing)
>                         log.trace("Reading header");
> 
>                     socketChannel.read(receiveBuffer[0]);
>                     if (receiveBuffer[0].hasRemaining())
>                         break; // not done reading the header.
> 
>                     receiveBuffer[0].flip();
>                     int size = receiveBuffer[0].getInt();
> 
>                     // The socket is being closed.
>                     if (size == -1)
>                         break;
> 
>                     // Do we need to incread the capacity of our buffer?      
>                           
>                     if (size > receiveBuffer[1].capacity())
>                         receiveBuffer[1] = ByteBuffer.allocate(size);
> 
>                     receiveBuffer[1].clear();
>                     receiveBuffer[1].limit(size);
>                 }
>                 // Are we reading the body??
>                 if (receiveBuffer[1].hasRemaining()) {
>                     if (tracing)
>                         log.trace("Reading body");
> 
>                     socketChannel.read(receiveBuffer[1]);
>                     if (receiveBuffer[1].hasRemaining())
>                         break; // not done reading the body.
> 
>                     receiveBuffer[0].flip();
>                     listner.receiveEvent(deserialize(receiveBuffer));
>                     receiveBuffer[0].clear();
>                 }
>             }
>             if (tracing)
>                 log.trace("No more data available to be read.");
> 
>         } catch (IOException e) {
>             log.debug("Communications error, closing connection: ", e);
>             asyncClose();
>         }
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/nio/NonBlockingServer.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/nio/NonBlockingServer.java
0a1,248
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async.nio;
> import java.io.IOException;
> import java.net.InetAddress;
> import java.net.InetSocketAddress;
> import java.net.SocketException;
> import java.net.URI;
> import java.net.URISyntaxException;
> import java.nio.channels.ServerSocketChannel;
> import java.nio.channels.SocketChannel;
> import java.util.Properties;
> 
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.geronimo.remoting.transport.Router;
> import org.apache.geronimo.remoting.transport.TransportException;
> import org.apache.geronimo.remoting.transport.URISupport;
> import org.apache.geronimo.remoting.transport.async.AbstractServer;
> import org.apache.geronimo.remoting.transport.async.ChannelPool;
> /**
>  * Provides a Blocking implemenation of the AsynchChannelServer interface.
>  * 
>  * Sets up a blocking ServerSocket to accept blocking client connections.
>  * 
>  * @version $Revision$ $Date$
>  */
> public final class NonBlockingServer extends AbstractServer implements 
> Runnable {
>     final static private Log log = LogFactory.getLog(NonBlockingServer.class);
> 
>     /**
>      * The default timeout for the server socket. This is
>      * set so the socket will periodically return to check
>      * the running flag.
>      */
>     private final static int SO_TIMEOUT = 5000;
>     private ServerSocketChannel serverSocketChannel;
>     private URI uri;
>     private URI connectURI;
>     private Thread worker;
>     private boolean running;
>     private int compression = -1;
>     private boolean enableTcpNoDelay;
>     private Router nextRouter;
> 
>     public void bind(URI localURI, Router dispatcher) throws IOException, 
> URISyntaxException {
>         this.uri = localURI;
>         this.nextRouter = dispatcher;
> 
>         String serverBindAddress = uri.getHost();
>         String clientConnectAddress = null;
>         int serverBindPort = uri.getPort();
>         int clientConnectPort = serverBindPort;
>         int connectBackLog = 50;
>         enableTcpNoDelay = true;
> 
>         Properties params = URISupport.parseQueryParameters(uri);
>         enableTcpNoDelay = params.getProperty("tcp.nodelay", 
> "true").equals("true");
>         connectBackLog = Integer.parseInt(params.getProperty("tcp.backlog", 
> "50"));
>         clientConnectAddress = params.getProperty("client.host");
>         clientConnectPort = 
> Integer.parseInt(params.getProperty("client.port", "0"));
>         clientConnectPort = 
> Integer.parseInt(params.getProperty("compression", "-1"));
> 
>         compression = Math.min(compression, 9);
>         compression = Math.max(compression, -1);
> 
>         serverSocketChannel = ServerSocketChannel.open();
>         serverSocketChannel.socket().bind(new 
> InetSocketAddress(InetAddress.getByName(serverBindAddress), 
> serverBindPort),connectBackLog);
>         serverSocketChannel.socket().setSoTimeout(SO_TIMEOUT);
> 
>         // Lookup the local host name if needed.
>         clientConnectAddress =
>             (clientConnectAddress == null || clientConnectAddress.length() == 
> 0)
>                 ? InetAddress.getLocalHost().getHostName()
>                 : clientConnectAddress;
>         clientConnectPort = (clientConnectPort <= 0) ? 
> serverSocketChannel.socket().getLocalPort() : clientConnectPort;
> 
>         // Create the client URI:
>         Properties clientParms = new Properties();
>         clientParms.put("tcp.nodelay", enableTcpNoDelay ? "true" : "false");
>         clientParms.put("compression", "" + compression);
>         this.connectURI =
>             new URI(
>                 "async",
>                 null,
>                 clientConnectAddress,
>                 clientConnectPort,
>                 "",
>                 URISupport.toQueryString(clientParms),
>                 null);
>         log.info(
>             "Remoting 'async' protocol available at: "
>                 + serverSocketChannel.socket().getInetAddress()
>                 + ":"
>                 + serverSocketChannel.socket().getLocalPort());
>         log.info("Remoting 'async' protocol clients will connect to: " + 
> connectURI);
>     }
> 
>     synchronized public void start() throws Exception {
>         if (running)
>             return;
>         running = true;
>         worker = new Thread(this, "Acceptor " + getClientConnectURI());
>         worker.setDaemon(true);
>         worker.start();
>         super.start();
>     }
> 
>     public void stop() throws Exception {
>         if (!running)
>             return;
>         running = false;
>         try {
>             worker.interrupt();
>             worker.join();
>         } catch (InterruptedException e) {
>         }
>         super.stop();
>     }
> 
>     /**
>      * @see java.lang.Runnable#run()
>      */
>     public void run() {
>         try {
>             while (running) {
>                 SocketChannel socketChannel = null;
>                 try {
>                     socketChannel = serverSocketChannel.accept();
>                     if (log.isTraceEnabled())
>                         log.trace("Accepted connection: " + 
> socketChannel.socket());
>                 } catch (java.io.InterruptedIOException e) {
>                     // It's ok, this is due to the SO_TIME_OUT
>                     continue;
>                 }
>                 try {
>                     socketChannel.socket().setTcpNoDelay(enableTcpNoDelay);
>                     NonBlockingChannel channel = new NonBlockingChannel();
>                     channel.init(connectURI, socketChannel);
>                     ChannelPool pool = getChannelPool(channel.getRemoteURI());
>                     pool.associate(channel);
>                 } catch (TransportException ie) {
>                     log.debug("Client connection could not be accepted: ", 
> ie);
>                 } catch (IOException ie) {
>                     log.debug("Client connection could not be accepted: ", 
> ie);
>                 } catch (URISyntaxException e) {
>                     log.debug("Client connection could not be accepted: ", e);
>                 }
>             }
>         } catch (SocketException e) {
>             // There is no easy way (other than string comparison) to
>             // determine if the socket exception is caused by connection
>             // reset by peer. In this case, it's okay to ignore both
>             // SocketException and IOException.
> 
>             if (running) // We may have been stopped.
>                 log.warn(
>                     "SocketException occured (Connection reset by peer?). 
> Shutting down remoting 'async' protocol.");
>         } catch (IOException e) {
>             if (running) // We may have been stopped.
>                 log.warn("IOException occured. Shutting down remoting 'async' 
> protocol.");
>         }
>     }
> 
>     /**
>      * @see 
> org.apache.j2ee.remoting.transport.TransportServer#getClientConnectURI()
>      */
>     public URI getClientConnectURI() {
>         return connectURI;
>     }
> 
>     /**
>      * @see org.apache.j2ee.remoting.transport.TransportServer#dispose()
>      */
>     public void dispose() throws Exception {
> 
>         if (running) {
>             // we were disposed before a stop!  Shutdown QUICK.
>             running = false;
>             worker.interrupt();
>         }
>         serverSocketChannel.close();
> 
>         super.dispose();
>     }
> 
>     /**
>      * @see 
> org.apache.geronimo.remoting.transport.async.AbstractServer#getNextRouter()
>      */
>     public Router getNextRouter() {
>         return nextRouter;
>     }
> }
> // vim:expandtab:tabstop=3:shiftwidth=3
\ No newline at end of file
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/nio/SelectionEventListner.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/nio/SelectionEventListner.java
0a1,75
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async.nio;
> 
> import java.nio.channels.SelectionKey;
> 
> /**
>  * This is the interface that the attachments of SelectorKeys
>  * that are registed with the Selector of the SelectorManager manager
>  * must implement.
>  *
>  * @version $Revision$ $Date$
>  */
> public interface SelectionEventListner
> {
>    /** 
>     * When the SelectorKey is triggered, the service method will
>     * be called on the attachment.
>     */
>    public void selectionEvent(SelectionKey selection);
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/java/org/apache/geronimo/remoting/transport/async/nio/SelectorManager.java
 
incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/nio/SelectorManager.java
0a1,195
> /*
>  * The Apache Software License, Version 1.1
>  *
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Xalan" and "Apache Software Foundation" must
>  *    not be used to endorse or promote products derived from this
>  *    software without prior written permission. For written
>  *    permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    nor may "Apache" appear in their name, without prior written
>  *    permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation and was
>  * originally based on software copyright (c) 1999, Lotus
>  * Development Corporation., http://www.lotus.com.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> package org.apache.geronimo.remoting.transport.async.nio;
> 
> import java.io.IOException;
> import java.net.SocketException;
> import java.nio.channels.ClosedChannelException;
> import java.nio.channels.SelectionKey;
> import java.nio.channels.Selector;
> import java.nio.channels.SocketChannel;
> import java.util.Iterator;
> import java.util.Set;
> 
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> 
> /**
>  * The SelectorManager will manage one Selector and the thread that checks 
>  * the selector.
>  * 
>  * We may need to consider running more than one thread to check the selector
>  * if servicing the selector takes too long.
>  * 
>  * @version $Revision$ $Date$
>  */
> public class SelectorManager implements Runnable {
> 
>     final static private Log log = LogFactory.getLog(SelectorManager.class);
> 
>     static private SelectorManager instance;
>     /**
>      * The running flag that all worker and server
>      * threads check to determine if the service should
>      * be stopped.
>      */
>     private volatile boolean running;
> 
>     /**
>      * The selector used to wait for non-blocking events.
>      */
>     private Selector selector;
> 
>     /**
>      * The groupd that threads created by this class will be a member of.
>      */
>     private ThreadGroup threadGroup;
> 
>     /**
>      * how many times we have been started ++ and stoped --
>      */
>     private int startCounter;
> 
>     protected SelectorManager() throws IOException {
>         threadGroup = new ThreadGroup("NIO remoting Workers");
>         selector = Selector.open();
>     }
> 
>     public synchronized static SelectorManager getInstance() throws 
> IOException {
>         if (instance == null)
>             instance = new SelectorManager();
>         return instance;
>     }
> 
>     /**
>      * Main processing method for the SelectionManager object
>      */
>     public void run() {
>         try {
> 
>             log.debug("Selector Work thread has started.");
>             while (running) {
> 
>                 log.trace("Waiting for selector to return");
>                 int count = selector.select(500);
>                 if (count == 0)
>                     continue;
> 
>                 // Get a java.util.Set containing the SelectionKey objects for
>                 // all channels that are ready for I/O.
>                 Set keys = selector.selectedKeys();
> 
>                 // Use a java.util.Iterator to loop through the selected keys
>                 for (Iterator i = keys.iterator(); i.hasNext();) {
>                     final SelectionKey key = (SelectionKey) i.next();
>                     ((SelectionEventListner) 
> key.attachment()).selectionEvent(key);
>                     i.remove(); // Remove the key from the set of selected 
> keys
>                 }
>             }
>         } catch (SocketException e) {
>             // There is no easy way (other than string comparison) to
>             // determine if the socket exception is caused by connection
>             // reset by peer. In this case, it's okay to ignore both
>             // SocketException and IOException.
>             log.warn("SocketException occured (Connection reset by peer?).");
>         } catch (IOException e) {
>             log.warn("IOException occured.", e);
>         } finally {
>             log.debug("Selector Work thread has stopped.");
>         }
>     }
> 
>     synchronized public void start() {
>         startCounter++;
>         if (startCounter == 1) {
>             log.debug("Starting a Selector Work thread.");
>             running = true;
>             new Thread(threadGroup, (Runnable) this, "Selector 
> Worker").start();
>         }
>     }
> 
>     synchronized public void stop() {
>         startCounter--;
>         if (startCounter == 0) {
>             log.debug("Stopping a Selector Work thread.");
>             running = false;
>         }
>     }
> 
>     /**
>      * @param socketChannel
>      * @param i
>      * @param channel
>      * @return
>      */
>     public SelectionKey register(SocketChannel socketChannel, int ops, 
> SelectionEventListner listner)
>         throws ClosedChannelException {
>         SelectionKey key = socketChannel.register(selector, ops, listner);
>         selector.wakeup();
>         return key;
>     }
> 
>     /**
>      * @param selectionKey
>      * @param i
>      */
>     public void setInterestOps(SelectionKey selectionKey, int ops) {
>         selectionKey.interestOps(ops);
>         selector.wakeup();
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/test/org/apache/geronimo/remoting/MarshalingInterceptorsTest.java
 
incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/MarshalingInterceptorsTest.java
0a1,348
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> 
> package org.apache.geronimo.remoting;
> 
> import java.io.IOException;
> import java.lang.reflect.InvocationTargetException;
> import java.lang.reflect.Method;
> import java.net.MalformedURLException;
> import java.net.URL;
> import java.net.URLClassLoader;
> import java.util.ArrayList;
> 
> import junit.framework.TestCase;
> 
> import org.apache.geronimo.common.Interceptor;
> import org.apache.geronimo.proxy.ProxyContainer;
> import org.apache.geronimo.proxy.ReflexiveInterceptor;
> import org.apache.geronimo.remoting.transport.BytesMarshalledObject;
> 
> /**
>  * Unit test for the Marshaling/DeMarshaling Interceptors
>  *
>  * This test uses 2 classloaders to mock 2 seperate
>  * application classloaders.
>  *
>  * @version $Revision:$ $Date:$
>  */
> 
> public class MarshalingInterceptorsTest extends TestCase {
> 
>     private static final String PERSON_CLASS = 
> "org.apache.geronimo.remoting.Person";
>     private static final String TRANSIENT_CLASS = 
> "org.apache.geronimo.remoting.TransientValue";
>     ArrayList severContainers = new ArrayList();
>     URLClassLoader cl1, cl2;
> 
>     /**
>      * creates the two classloaders that will be used during the tests.
>      */
>     public void setUp() throws MalformedURLException, IOException {
>         URL url = new URL(System.getProperty("test-app.url"));
>         System.out.println("Setting up the CP to: " + url);
> 
>         cl1 = new URLClassLoader(new URL[] { url });
>         cl2 = new URLClassLoader(new URL[] { url });
>     }
> 
>     /**
>      * Verify that the classpath/classloader structure is
>      * as expected.  If the application classes are in
>      * the current classloader then that will throw all the 
>      * tests off.
>      * 
>      * @throws Exception
>      */
>     public void testCheckClassLoaders() throws Exception {
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Class class2 = cl2.loadClass(PERSON_CLASS);
>         assertFalse("Classpath for this test was incorrect.  The 
> '"+PERSON_CLASS+"' cannot be in the test's classpath.", 
> class1.equals(class2));
>     }
> 
>     /**
>      * Verify that the helper methods used by this test work
>      * as expected.  Everything should be ok when working in the
>      * same classloader.
>      * 
>      * @throws Throwable
>      */
>     public void testSetSpouseSameCL() throws Throwable {
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Class class2 = cl1.loadClass(PERSON_CLASS);
> 
>         Object object1 = class1.newInstance();
>         Object object2 = class2.newInstance();
> 
>         call(object1, "setSpouse", new Object[] { object2 });
>     }
> 
>     /**
>      * Verify that the helper methods used by this test work
>      * as expected.  We should see problems when you start mixing
>      * Objects from different classloaders.
>      * 
>      * @throws Throwable
>      */
>     public void testSetSpouseOtherCL() throws Throwable {
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Class class2 = cl2.loadClass(PERSON_CLASS);
> 
>         Object object1 = class1.newInstance();
>         Object object2 = class2.newInstance();
> 
>         try {
>             call(object1, "setSpouse", new Object[] { object2 });
>             fail("Call should fail due to argument type mismatch.");
>         } catch (IllegalArgumentException e) {
>         }
>     }
> 
>     /**
>      * Verify that a proxy using working in a single app context works ok.
>      * 
>      * @throws Throwable
>      */
>     public void testSetSpouseWithProxy() throws Throwable {
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Object object1 = class1.newInstance();
> 
>         // Simulate App1 creating a proxy.
>         Thread.currentThread().setContextClassLoader(cl1);
>         Object proxy1 = createProxy(object1);
>         call(proxy1, "setSpouse", new Object[] { object1 });
>     }
> 
>     /**
>      * App2 creates a proxy and serializes.  App1 context deserializes
>      * the proxy and trys to use it.  Method calls should be getting
>      * marshalled/demarshaled by the proxy to avoid getting an 
>      * IllegalArgumentException.
>      * 
>      * @throws Throwable
>      */
>     public void testSetSpouseOtherCLWithSerializedProxy() throws Throwable {
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Class class2 = cl2.loadClass(PERSON_CLASS);
> 
>         Object object1 = class1.newInstance();
>         Object object2 = class2.newInstance();
> 
>         // Simulate App2 creating a proxy.
>         Thread.currentThread().setContextClassLoader(cl2);
>         Object proxy2 = createProxy(object2);
>         MarshalledObject mo = new BytesMarshalledObject(proxy2);
> 
>         // Simulate App1 using the serialized proxy.    
>         Thread.currentThread().setContextClassLoader(cl1);
>         Object proxy1 = mo.get();
>         call(proxy1, "setSpouse", new Object[] { object1 });
>     }
> 
>     /**
>      * App1 creates a proxy.  It then creates a Transient calls that holds
>      * a "value" property that is transient when serialized.  This allows to 
>      * to see if the Transient object was serialized by getting the value back
>      * and seeing if the "value" is null.  All this work is done in one 
> classloader
>      * so no serialization should occur.
>      * 
>      * @throws Throwable
>      */
>     public void testSetTransientWithOptimizedProxy() throws Throwable {
>         Thread.currentThread().setContextClassLoader(cl1);
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Object object1 = class1.newInstance();
> 
>         Class class2 = cl1.loadClass(TRANSIENT_CLASS);
>         Object object2 = class2.newInstance();
>         call(object2, "setValue", new Object[] { "foo" });
> 
>         Object proxy1 = createProxy(object1);
>         call(proxy1, "setValue", new Object[] { object2 });
>         Object rc = call(proxy1, "getValue", new Object[] {
>         });
>         rc = call(rc, "getValue", new Object[] {
>         });
> 
>         assertSame(rc, "foo");
>     }
> 
>     /**
>      * Same as testSetTransientWithOptimizedProxy() but, the proxy is 
> serialized before it is used.
>      * It should still result in the method call not being serialized.
>      * 
>      * @throws Throwable
>      */
>     public void testSetTransientWithSerializedOptimizedProxy() throws 
> Throwable {
>         Thread.currentThread().setContextClassLoader(cl1);
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Object object1 = class1.newInstance();
> 
>         Class class2 = cl1.loadClass(TRANSIENT_CLASS);
>         Object object2 = class2.newInstance();
>         call(object2, "setValue", new Object[] { "foo" });
> 
>         Object proxy1 = createProxy(object1);
>         proxy1 = new BytesMarshalledObject(proxy1).get();
>         call(proxy1, "setValue", new Object[] { object2 });
>         Object rc = call(proxy1, "getValue", new Object[] {
>         });
>         rc = call(rc, "getValue", new Object[] {
>         });
> 
>         assertSame(rc, "foo");
>     }
> 
>     /**
>      * Same as testSetTransientWithOptimizedProxy() but, the proxy is 
> serialized before it is
>      * by App2.  Since a different classloader is using the proxy, the metod 
> call should
>      * be serialized and we should see that the set "value" is null.
>      * 
>      * @throws Throwable
>      */
>     public void testSetTransientWithSerializedNonOptimizedProxy() throws 
> Throwable {
>         Thread.currentThread().setContextClassLoader(cl1);
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Object object1 = class1.newInstance();
> 
>         Object proxy1 = createProxy(object1);
>         Thread.currentThread().setContextClassLoader(cl2);
>         proxy1 = new BytesMarshalledObject(proxy1).get();
> 
>         Class class2 = cl2.loadClass(TRANSIENT_CLASS);
>         Object object2 = class2.newInstance();
>         call(object2, "setValue", new Object[] { "foo" });
> 
>         call(proxy1, "setValue", new Object[] { object2 });
>         Object rc = call(proxy1, "getValue", new Object[] {
>         });
>         rc = call(rc, "getValue", new Object[] {
>         });
> 
>         assertSame(rc, null);
>     }
> 
>     /**
>      * Does a reflexive call on object1 my calling method with the provided 
> args.
>      * 
>      * @param object1
>      * @param string
>      * @param objects
>      */
>     private Object call(Object object1, String method, Object[] args) throws 
> Throwable {
>         try {
>             Class argTypes[] = 
> getArgTypes(object1.getClass().getClassLoader(), args);
>             Method m = findMethod(object1.getClass(), method);
>             return m.invoke(object1, args);
>         } catch (InvocationTargetException e) {
>             throw e.getTargetException();
>         }
>     }
> 
>     /**
>      * Gets the Class[] for a given Object[] using the provided loader.
>      * 
>      * @param object1
>      * @param args
>      * @return
>      */
>     private Class[] getArgTypes(ClassLoader loader, Object[] args) throws 
> Exception {
>         Class rc[] = new Class[args.length];
>         for (int i = 0; i < rc.length; i++) {
>             rc[i] = loader.loadClass(args[i].getClass().getName());
>         }
>         return rc;
>     }
> 
>     /**
>      * Finds the first method in class c whose name is name.
>      * @param c
>      * @param name
>      * @return
>      */
>     private Method findMethod(Class c, String name) {
>         Method[] methods = c.getMethods();
>         for (int i = 0; i < methods.length; i++) {
>             if (methods[i].getName().equals(name))
>                 return methods[i];
>         }
>         return null;
>     }
> 
>     /**
>       * @param object1
>       * @return
>       */
>     private Object createProxy(Object object1) throws Exception {
>         
>         ProxyContainer serverContainer = new ProxyContainer();        
> 
>         DeMarshalingInterceptor dmi = new DeMarshalingInterceptor();
>         dmi.setClassloader(object1.getClass().getClassLoader());
>         Long dmiid = InterceptorRegistry.instance.register(dmi);
>         serverContainer.addInterceptor(dmi);      
>         Interceptor reflexive = new ReflexiveInterceptor(object1);
>         serverContainer.addInterceptor(reflexive);
>         severContainers.add(serverContainer);
>         
>         ProxyContainer clientContainer = new ProxyContainer();        
>         IntraVMRoutingInterceptor ivmri = new IntraVMRoutingInterceptor();
>         ivmri.setDeMarshalingInterceptorID(dmiid);
>         clientContainer.addInterceptor(ivmri);
> 
>         return clientContainer.createProxy(object1.getClass());
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/test/org/apache/geronimo/remoting/RemotingInterceptorsTest.java
 
incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/RemotingInterceptorsTest.java
0a1,377
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> 
> package org.apache.geronimo.remoting;
> 
> import java.lang.reflect.InvocationTargetException;
> import java.lang.reflect.Method;
> import java.net.URI;
> import java.net.URL;
> import java.net.URLClassLoader;
> import java.util.ArrayList;
> 
> import junit.framework.TestCase;
> 
> import org.apache.geronimo.common.Interceptor;
> import org.apache.geronimo.proxy.ProxyContainer;
> import org.apache.geronimo.proxy.ReflexiveInterceptor;
> import org.apache.geronimo.remoting.transport.BytesMarshalledObject;
> import org.apache.geronimo.remoting.transport.FragmentBasedInterceptorRouter;
> import org.apache.geronimo.remoting.transport.RemoteTransportInterceptor;
> import org.apache.geronimo.remoting.transport.TransportFactory;
> import org.apache.geronimo.remoting.transport.TransportServer;
> import org.apache.geronimo.remoting.transport.URISupport;
> 
> /**
>  * Unit test for the Marshaling/DeMarshaling Interceptors
>  *
>  * This test uses 2 classloaders to mock 2 seperate
>  * application classloaders.
>  *
>  * @version $Revision:$ $Date:$
>  */
> 
> public class RemotingInterceptorsTest extends TestCase {
> 
>     private static final String PERSON_CLASS = 
> "org.apache.geronimo.remoting.Person";
>     private static final String TRANSIENT_CLASS = 
> "org.apache.geronimo.remoting.TransientValue";
>     ArrayList severContainers = new ArrayList();
>     URLClassLoader cl1, cl2;
>     
>     TransportServer server;
>     URI connectURI;    
> 
>     /**
>      * creates the two classloaders that will be used during the tests.
>      */
>     public void setUp() throws Exception {
>         URL url = new URL(System.getProperty("test-app.url"));
>         System.out.println("Setting up the CP to: " + url);
> 
>         cl1 = new URLClassLoader(new URL[] { url });
>         cl2 = new URLClassLoader(new URL[] { url });
> 
>         
> System.out.println("================================================");
>         URI bindURI = new URI("async://0.0.0.0:0");
>         TransportFactory tf = TransportFactory.getTransportFactory(bindURI);
>         server = tf.createSever();
>         server.bind(bindURI,new FragmentBasedInterceptorRouter());
>         connectURI = server.getClientConnectURI();
>         server.start();
> 
>     }
>     
>     /**
>      * @see junit.framework.TestCase#tearDown()
>      */
>     protected void tearDown() throws Exception {
>         server.dispose();
>     }    
> 
>     /**
>      * Verify that the classpath/classloader structure is
>      * as expected.  If the application classes are in
>      * the current classloader then that will throw all the 
>      * tests off.
>      * 
>      * @throws Exception
>      */
>     public void testCheckClassLoaders() throws Exception {
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Class class2 = cl2.loadClass(PERSON_CLASS);
>         assertFalse("Classpath for this test was incorrect.  The 
> '"+PERSON_CLASS+"' cannot be in the test's classpath.", 
> class1.equals(class2));
>     }
> 
>     /**
>      * Verify that the helper methods used by this test work
>      * as expected.  Everything should be ok when working in the
>      * same classloader.
>      * 
>      * @throws Throwable
>      */
>     public void testSetSpouseSameCL() throws Throwable {
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Class class2 = cl1.loadClass(PERSON_CLASS);
> 
>         Object object1 = class1.newInstance();
>         Object object2 = class2.newInstance();
> 
>         call(object1, "setSpouse", new Object[] { object2 });
>     }
> 
>     /**
>      * Verify that the helper methods used by this test work
>      * as expected.  We should see problems when you start mixing
>      * Objects from different classloaders.
>      * 
>      * @throws Throwable
>      */
>     public void testSetSpouseOtherCL() throws Throwable {
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Class class2 = cl2.loadClass(PERSON_CLASS);
> 
>         Object object1 = class1.newInstance();
>         Object object2 = class2.newInstance();
> 
>         try {
>             call(object1, "setSpouse", new Object[] { object2 });
>             fail("Call should fail due to argument type mismatch.");
>         } catch (IllegalArgumentException e) {
>         }
>     }
> 
>     /**
>      * Verify that a proxy using working in a single app context works ok.
>      * 
>      * @throws Throwable
>      */
>     public void testSetSpouseWithProxy() throws Throwable {
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Object object1 = class1.newInstance();
> 
>         // Simulate App1 creating a proxy.
>         Thread.currentThread().setContextClassLoader(cl1);
>         Object proxy1 = createProxy(object1);
>         call(proxy1, "setSpouse", new Object[] { object1 });
>     }
> 
>     /**
>      * App2 creates a proxy and serializes.  App1 context deserializes
>      * the proxy and trys to use it.  Method calls should be getting
>      * marshalled/demarshaled by the proxy to avoid getting an 
>      * IllegalArgumentException.
>      * 
>      * @throws Throwable
>      */
>     public void testSetSpouseOtherCLWithSerializedProxy() throws Throwable {
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Class class2 = cl2.loadClass(PERSON_CLASS);
> 
>         Object object1 = class1.newInstance();
>         Object object2 = class2.newInstance();
> 
>         // Simulate App2 creating a proxy.
>         Thread.currentThread().setContextClassLoader(cl2);
>         Object proxy2 = createProxy(object2);
>         MarshalledObject mo = new BytesMarshalledObject(proxy2);
> 
>         // Simulate App1 using the serialized proxy.    
>         Thread.currentThread().setContextClassLoader(cl1);
>         Object proxy1 = mo.get();
>         call(proxy1, "setSpouse", new Object[] { object1 });
>     }
> 
>     /**
>      * App1 creates a proxy.  It then creates a Transient calls that holds
>      * a "value" property that is transient when serialized.  This allows to 
>      * to see if the Transient object was serialized by getting the value back
>      * and seeing if the "value" is null.  All this work is done in one 
> classloader
>      * so no serialization should occur.
>      * 
>      * @throws Throwable
>      */
>     /* Disable until proxy knows how to do a local optimize.
>     public void testSetTransientWithOptimizedProxy() throws Throwable {
>         Thread.currentThread().setContextClassLoader(cl1);
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Object object1 = class1.newInstance();
> 
>         Class class2 = cl1.loadClass(TRANSIENT_CLASS);
>         Object object2 = class2.newInstance();
>         call(object2, "setValue", new Object[] { "foo" });
> 
>         Object proxy1 = createProxy(object1);
>         call(proxy1, "setValue", new Object[] { object2 });
>         Object rc = call(proxy1, "getValue", new Object[] {
>         });
>         rc = call(rc, "getValue", new Object[] {
>         });
> 
>         assertSame(rc, "foo");
>     }
>     */
>     
>     /**
>      * Same as testSetTransientWithOptimizedProxy() but, the proxy is 
> serialized before it is used.
>      * It should still result in the method call not being serialized.
>      * 
>      * @throws Throwable
>      */
>     /* Disable until proxy knows how to do a local optimize.
>     public void testSetTransientWithSerializedOptimizedProxy() throws 
> Throwable {
>         Thread.currentThread().setContextClassLoader(cl1);
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Object object1 = class1.newInstance();
> 
>         Class class2 = cl1.loadClass(TRANSIENT_CLASS);
>         Object object2 = class2.newInstance();
>         call(object2, "setValue", new Object[] { "foo" });
> 
>         Object proxy1 = createProxy(object1);
>         proxy1 = new BytesMarshalledObject(proxy1).get();
>         call(proxy1, "setValue", new Object[] { object2 });
>         Object rc = call(proxy1, "getValue", new Object[] {
>         });
>         rc = call(rc, "getValue", new Object[] {
>         });
> 
>         assertSame(rc, "foo");
>     }
>     */
>     
>     /**
>      * Same as testSetTransientWithOptimizedProxy() but, the proxy is 
> serialized before it is
>      * by App2.  Since a different classloader is using the proxy, the metod 
> call should
>      * be serialized and we should see that the set "value" is null.
>      * 
>      * @throws Throwable
>      */
>     public void testSetTransientWithSerializedNonOptimizedProxy() throws 
> Throwable {
>         Thread.currentThread().setContextClassLoader(cl1);
>         Class class1 = cl1.loadClass(PERSON_CLASS);
>         Object object1 = class1.newInstance();
> 
>         Object proxy1 = createProxy(object1);
>         Thread.currentThread().setContextClassLoader(cl2);
>         proxy1 = new BytesMarshalledObject(proxy1).get();
> 
>         Class class2 = cl2.loadClass(TRANSIENT_CLASS);
>         Object object2 = class2.newInstance();
>         call(object2, "setValue", new Object[] { "foo" });
> 
>         call(proxy1, "setValue", new Object[] { object2 });
>         Object rc = call(proxy1, "getValue", new Object[] {
>         });
>         rc = call(rc, "getValue", new Object[] {
>         });
> 
>         assertSame(rc, null);
>     }
> 
>     /**
>      * Does a reflexive call on object1 my calling method with the provided 
> args.
>      * 
>      * @param object1
>      * @param string
>      * @param objects
>      */
>     private Object call(Object object1, String method, Object[] args) throws 
> Throwable {
>         try {
>             Class argTypes[] = 
> getArgTypes(object1.getClass().getClassLoader(), args);
>             Method m = findMethod(object1.getClass(), method);
>             return m.invoke(object1, args);
>         } catch (InvocationTargetException e) {
>             throw e.getTargetException();
>         }
>     }
> 
>     /**
>      * Gets the Class[] for a given Object[] using the provided loader.
>      * 
>      * @param object1
>      * @param args
>      * @return
>      */
>     private Class[] getArgTypes(ClassLoader loader, Object[] args) throws 
> Exception {
>         Class rc[] = new Class[args.length];
>         for (int i = 0; i < rc.length; i++) {
>             rc[i] = loader.loadClass(args[i].getClass().getName());
>         }
>         return rc;
>     }
> 
>     /**
>      * Finds the first method in class c whose name is name.
>      * @param c
>      * @param name
>      * @return
>      */
>     private Method findMethod(Class c, String name) {
>         Method[] methods = c.getMethods();
>         for (int i = 0; i < methods.length; i++) {
>             if (methods[i].getName().equals(name))
>                 return methods[i];
>         }
>         return null;
>     }
> 
>     /**
>       * @param object1
>       * @return
>       */
>     private Object createProxy(Object object1) throws Exception {
>         
>         ProxyContainer serverContainer = new ProxyContainer();        
> 
>         DeMarshalingInterceptor dmi = new DeMarshalingInterceptor();
>         dmi.setClassloader(object1.getClass().getClassLoader());
>         Long dmiid = InterceptorRegistry.instance.register(dmi);
>         serverContainer.addInterceptor(dmi);      
>         Interceptor reflexive = new ReflexiveInterceptor(object1);
>         serverContainer.addInterceptor(reflexive);
>         severContainers.add(serverContainer);
>         
>         ProxyContainer clientContainer = new ProxyContainer();
>         clientContainer.addInterceptor(new MarshalingInterceptor());
>         RemoteTransportInterceptor rti = new RemoteTransportInterceptor();
>         URI u = URISupport.setFragment(connectURI, ""+dmiid);        
>         rti.setRemoteURI(u);
>         clientContainer.addInterceptor(rti);
>         
>         return clientContainer.createProxy(object1.getClass());
>     }
> 
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/test/org/apache/geronimo/remoting/transport/AsyncTransportStress.java
 
incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/transport/AsyncTransportStress.java
0a1,170
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> 
> package org.apache.geronimo.remoting.transport;
> 
> import java.net.URI;
> 
> import junit.framework.TestCase;
> 
> import org.apache.geronimo.remoting.MarshalledObject;
> 
> import EDU.oswego.cs.dl.util.concurrent.CyclicBarrier;
> import EDU.oswego.cs.dl.util.concurrent.Semaphore;
> 
> /**
>  * Unit test for the Async Remoting Transport
>  *
>  * @version $Revision:$ $Date:$
>  */
> 
> public class AsyncTransportStress extends TestCase {
> 
>     TransportServer server;
>     TransportClient client;
>     URI connectURI;
>     volatile MockRouter mockRouter;
> 
>     class MockRouter implements Router {
>         
>         Semaphore requestCounter=new Semaphore(0);
>         Semaphore datagramCounter=new Semaphore(0);
> 
>         public Msg sendRequest(URI to, Msg request) throws TransportException 
> {
>             try {
>                 requestCounter.release();
> 
>                 Msg response = request.createMsg();
>                 response.pushMarshaledObject(request.popMarshaledObject());
>                 return response;
> 
>             } catch (Exception e) {
>                 throw new TransportException(e.getMessage());
>             }
>         }
> 
>         /**
>          * @see 
> org.apache.geronimo.remoting.transport.Router#sendDatagram(java.net.URI, 
> org.apache.geronimo.remoting.transport.Msg)
>          */
>         public void sendDatagram(URI to, Msg request) throws 
> TransportException {
>             datagramCounter.release();
>         }
>     }
> 
>     /**
>      * @see junit.framework.TestCase#setUp()
>      */
>     protected void setUp() throws Exception {
>         
> System.out.println("================================================");
>         URI bindURI = new URI("async://0.0.0.0:0");
>         TransportFactory tf = TransportFactory.getTransportFactory(bindURI);
>         server = tf.createSever();
>         mockRouter = new MockRouter();
>         server.bind(bindURI,mockRouter);
>         connectURI = server.getClientConnectURI();
>         server.start();
>         client = tf.createClient();
>     }
> 
>     /**
>      * @see junit.framework.TestCase#tearDown()
>      */
>     protected void tearDown() throws Exception {
>         server.dispose();
>     }
> 
>     public void testConcurrentRequests() throws Exception {
>         
>         final int WORKERS = 100;
>         final int MESSAGE_COUNT=10;
>         final CyclicBarrier barrier = new CyclicBarrier(WORKERS); 
> 
>         for( int i=0; i < WORKERS; i++ ) {                
>         
>             new Thread() {
>                 /**
>                  * @see java.lang.Thread#run()
>                  */
>                 public void run() {
>                     try {
>                         String text = "Hello World";
>                         MarshalledObject object = 
> client.createMarshalledObject();
>                         object.set(text);
>                         Msg msg = client.createMsg();
>                         msg.pushMarshaledObject(object);
>                                 
>                         barrier.barrier();
>                         
>                         for(int i=0; i < MESSAGE_COUNT; i++ )         
>                             client.sendRequest(connectURI,msg);
>                         
>                         
>                     } catch (Exception e) {
>                         e.printStackTrace();
>                     }
>                 }
>             }.start();
>         }
>         
>         for( int j=0; j < WORKERS; j++ ) {                
>             for(int i=0; i < MESSAGE_COUNT; i++ ) {
>                 boolean b = mockRouter.requestCounter.attempt(30000000);      
>    
>                 if( !b )
>                     fail("test timed out");
>             }
>         }
>     }
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/test/org/apache/geronimo/remoting/transport/AsyncTransportTest.java
 
incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/transport/AsyncTransportTest.java
0a1,156
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> 
> package org.apache.geronimo.remoting.transport;
> 
> import java.net.URI;
> 
> import junit.framework.TestCase;
> 
> import org.apache.geronimo.remoting.MarshalledObject;
> 
> import EDU.oswego.cs.dl.util.concurrent.Semaphore;
> 
> /**
>  * Unit test for the Async Remoting Transport
>  *
>  * @version $Revision:$ $Date:$
>  */
> 
> public class AsyncTransportTest extends TestCase {
> 
>     TransportServer server;
>     TransportClient client;
>     URI connectURI;
>     MockRouter mockRouter;
> 
>     class MockRouter implements Router {
>         
>         Semaphore requestCounter=new Semaphore(0);
>         Semaphore datagramCounter=new Semaphore(0);
> 
>         public Msg sendRequest(URI to, Msg request) throws TransportException 
> {
>             try {
>                 requestCounter.release();
> 
>                 Msg response = request.createMsg();
>                 response.pushMarshaledObject(request.popMarshaledObject());
>                 return response;
> 
>             } catch (Exception e) {
>                 throw new TransportException(e.getMessage());
>             }
>         }
> 
>         /**
>          * @see 
> org.apache.geronimo.remoting.transport.Router#sendDatagram(java.net.URI, 
> org.apache.geronimo.remoting.transport.Msg)
>          */
>         public void sendDatagram(URI to, Msg request) throws 
> TransportException {
>             datagramCounter.release();
>         }
>     }
> 
>     /**
>      * @see junit.framework.TestCase#setUp()
>      */
>     protected void setUp() throws Exception {
>         
> System.out.println("================================================");
>         URI bindURI = new URI("async://0.0.0.0:0");
>         TransportFactory tf = TransportFactory.getTransportFactory(bindURI);
>         server = tf.createSever();
>         mockRouter = new MockRouter();
>         server.bind(bindURI,mockRouter);
>         connectURI = server.getClientConnectURI();
>         server.start();
>         client = tf.createClient();
>     }
> 
>     /**
>      * @see junit.framework.TestCase#tearDown()
>      */
>     protected void tearDown() throws Exception {
>         server.dispose();
>     }
> 
>     public void testRequestMessage() throws Exception {
>         String text = "Hello World";
>         
>         MarshalledObject object = client.createMarshalledObject();
>         object.set(text);
>         Msg msg = client.createMsg();
>         msg.pushMarshaledObject(object);
>         
>         Msg response = client.sendRequest(connectURI,msg);
>         Object rc = response.popMarshaledObject().get();
>         
>         assertEquals(rc,text);
>         assertTrue(mockRouter.requestCounter.permits()==1);
>         assertTrue(mockRouter.datagramCounter.permits()==0);
>     }
> 
>     public void testDatagramMessage() throws Exception {
> 
>         String text = "Hello World";
>         
>         MarshalledObject object = client.createMarshalledObject();
>         object.set(text);
>         Msg msg = client.createMsg();
>         msg.pushMarshaledObject(object);
>         
>         client.sendDatagram(connectURI,msg);        
>         assertTrue(mockRouter.datagramCounter.attempt(10000));
>     }
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/test-app/org/apache/geronimo/remoting/IPerson.java
 
incubator-geronimo/modules/core/src/test-app/org/apache/geronimo/remoting/IPerson.java
0a1,88
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public interface IPerson {
>       public TransientValue getValue();
>       public void setValue(TransientValue value);
>    /**
>     * @return
>     */
>    public abstract IPerson getSpouse();
>    /**
>     * @param spouse
>     */
>    public abstract void setSpouse(IPerson spouse);
>    /**
>     * @return
>     */
>    public abstract String getFirstName();
>    /**
>     * @param firstName
>     */
>    public abstract void setFirstName(String firstName);
>    /**
>     * @return
>     */
>    public abstract String getLastName();
>    /**
>     * @param lastName
>     */
>    public abstract void setLastName(String lastName);
> }
\ No newline at end of file
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/test-app/org/apache/geronimo/remoting/Person.java
 
incubator-geronimo/modules/core/src/test-app/org/apache/geronimo/remoting/Person.java
0a1,130
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting;
> 
> import java.io.Serializable;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class Person implements Serializable, IPerson {
>       
>       private String firstName;
>       private String lastName;
>       private IPerson spouse;
>       private TransientValue value;
>       
>    /**
>     * @return
>     */
>    public TransientValue getValue() {
>       return value;
>    }
> 
>    /**
>     * @param value
>     */
>    public void setValue(TransientValue value) {
>       this.value = value;
>    }
> 
>    /**
>     * @return
>     */
>    public IPerson getSpouse() {
>       return spouse;
>    }
> 
>    /**
>     * @param spouse
>     */
>    public void setSpouse(IPerson spouse) {
>       this.spouse = spouse;
>    }
> 
>    /**
>     * @return
>     */
>    public String getFirstName() {
>       return firstName;
>    }
> 
>    /**
>     * @param firstName
>     */
>    public void setFirstName(String firstName) {
>       this.firstName = firstName;
>    }
> 
>    /**
>     * @return
>     */
>    public String getLastName() {
>       return lastName;
>    }
> 
>    /**
>     * @param lastName
>     */
>    public void setLastName(String lastName) {
>       this.lastName = lastName;
>    }
> 
>       public static void main(String[] args) {
>       Person p = new Person();
>       p.setSpouse(p);
>    }
> }
diff -r -N -x CVS 
incubator-geronimo-head/modules/core/src/test-app/org/apache/geronimo/remoting/TransientValue.java
 
incubator-geronimo/modules/core/src/test-app/org/apache/geronimo/remoting/TransientValue.java
0a1,80
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2003 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Geronimo" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact [EMAIL PROTECTED]
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Geronimo", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  * ====================================================================
>  */
> package org.apache.geronimo.remoting;
> 
> import java.io.Serializable;
> 
> /**
>  * @version $Revision$ $Date$
>  */
> public class TransientValue implements Serializable {
>       transient public Object value;
>       
>    /**
>     * @return
>     */
>    public Object getValue() {
>       return value;
>    }
> 
>    /**
>     * @param value
>     */
>    public void setValue(Object value) {
>       this.value = value;
>    }
> 
> }

Reply via email to