You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ha...@apache.org on 2002/04/21 11:42:03 UTC

cvs commit: jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test TestInterface3.java TestInterface3Impl.java AbstractServerTest.java PipeTest.java TestClient.java TestInterface2.java TestInterfaceImpl.java

hammant     02/04/21 02:42:03

  Modified:    altrmi   base.xml
               altrmi/src/java/org/apache/excalibur/altrmi/client
                        AltrmiClientInvocationHandler.java ProxyHelper.java
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl
                        DefaultProxyHelper.java
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/socket
                        CallbackEnabledSocketCustomStreamInvocationHandler.java
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl/direct
                        DirectInvocationHandler.java
                        DirectMarshalledInvocationHandler.java
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl/multiple
                        RotatingMultipleInvocationHandler.java
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl/piped
                        AbstractPipedStreamInvocationHandler.java
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl/rmi
                        RmiInvocationHandler.java
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream
                        StreamInvocationHandler.java
               altrmi/src/java/org/apache/excalibur/altrmi/common
                        MethodFacadeArrayReply.java MethodFacadeReply.java
               altrmi/src/java/org/apache/excalibur/altrmi/generator
                        ProxyGeneratorImpl.java
               altrmi/src/java/org/apache/excalibur/altrmi/server
                        MethodInvocationHandler.java
                        PublicationDescription.java
               altrmi/src/java/org/apache/excalibur/altrmi/server/impl
                        DefaultMethodInvocationHandler.java
               altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters
                        InvocationHandlerAdapter.java
                        PublicationAdapter.java
               altrmi/src/test/org/apache/excalibur/altrmi/test
                        AbstractServerTest.java PipeTest.java
                        TestClient.java TestInterface2.java
                        TestInterfaceImpl.java
  Added:       altrmi/src/test/org/apache/excalibur/altrmi/test
                        TestInterface3.java TestInterface3Impl.java
  Log:
  upcasting of objects on the client side now possible.
  
  Revision  Changes    Path
  1.3       +1 -1      jakarta-avalon-excalibur/altrmi/base.xml
  
  Index: base.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/base.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- base.xml	18 Apr 2002 06:35:00 -0000	1.2
  +++ base.xml	21 Apr 2002 09:42:01 -0000	1.3
  @@ -47,7 +47,7 @@
       <altrmiproxies genname="Hello" srcgendir="${build.home}/genjava" 
           classgendir="${build.home}/genclasses" verbose="true"
           interfaces="org.apache.excalibur.altrmi.test.TestInterface" 
  -        additionalfacades="org.apache.excalibur.altrmi.test.TestInterface2">
  +        additionalfacades="org.apache.excalibur.altrmi.test.TestInterface3,org.apache.excalibur.altrmi.test.TestInterface2">
         <classpath>
           <pathelement location="${build.home}/classes"/>
           <pathelement location="${build.home}/testclasses"/>            
  
  
  
  1.2       +5 -1      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/AltrmiClientInvocationHandler.java
  
  Index: AltrmiClientInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/AltrmiClientInvocationHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AltrmiClientInvocationHandler.java	3 Apr 2002 11:29:49 -0000	1.1
  +++ AltrmiClientInvocationHandler.java	21 Apr 2002 09:42:01 -0000	1.2
  @@ -20,7 +20,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version * $Revision: 1.1 $
  + * @version * $Revision: 1.2 $
    */
   public interface AltrmiClientInvocationHandler extends AltrmiInvocationHandler
   {
  @@ -83,4 +83,8 @@
        *
        */
       ClassLoader getInterfacesClassLoader();
  +
  +
  +    boolean isCallbackEnabled();
  +
   }
  
  
  
  1.2       +3 -2      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/ProxyHelper.java
  
  Index: ProxyHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/ProxyHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProxyHelper.java	10 Apr 2002 23:36:57 -0000	1.1
  +++ ProxyHelper.java	21 Apr 2002 09:42:01 -0000	1.2
  @@ -16,7 +16,7 @@
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
    * @author Vinay Chandrasekharan <a href="mailto:vinay_chandran@users.sourceforge.net">vinay_chandran@users.sourceforge.net</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public interface ProxyHelper
   {
  @@ -25,6 +25,7 @@
        * Method processObjectRequestGettingFacade
        *
        *
  +     * @param returnClassType
        * @param methodSignature
        * @param args
        * @param objectName
  @@ -34,7 +35,7 @@
        * @throws Throwable
        *
        */
  -    Object processObjectRequestGettingFacade(
  +    Object processObjectRequestGettingFacade(Class returnClassType,
           String methodSignature, Object[] args, String objectName) throws Throwable;
   
       /**
  
  
  
  1.5       +211 -120  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/DefaultProxyHelper.java
  
  Index: DefaultProxyHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/DefaultProxyHelper.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultProxyHelper.java	20 Apr 2002 17:39:44 -0000	1.4
  +++ DefaultProxyHelper.java	21 Apr 2002 09:42:01 -0000	1.5
  @@ -25,24 +25,29 @@
   import org.apache.excalibur.altrmi.common.GarbageCollectionReply;
   import org.apache.excalibur.altrmi.client.AltrmiProxy;
   import org.apache.excalibur.altrmi.client.ProxyHelper;
  -import org.apache.excalibur.altrmi.client.impl.callback.socket.CallbackEnabledSocketCustomStreamInvocationHandler;
  +import org.apache.excalibur.altrmi.client.impl.callback.socket
  +    .CallbackEnabledSocketCustomStreamInvocationHandler;
   
   import java.lang.reflect.Array;
   
   //callback
   import org.apache.excalibur.altrmi.common.ExposedObjectProxy;
  +
   import java.util.StringTokenizer;
  +
   import org.apache.excalibur.altrmi.common.AltrmiCallbackException;
   
  +
   /**
    * Class DefaultProxyHelper
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
    * @author Vinay Chandrasekharan <a href="mailto:vinay_chandran@users.sourceforge.net">vinay_chandran@users.sourceforge.net</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
  -public final class DefaultProxyHelper implements ProxyHelper {
  +public final class DefaultProxyHelper implements ProxyHelper
  +{
   
       private final transient AbstractAltrmiFactory mAltrmiFactory;
       private final transient AltrmiInvocationHandler mInvocationHandler;
  @@ -50,10 +55,14 @@
       private final transient String mObjectName;
       private final transient Long mReferenceID;
       private final transient Long mSession;
  -	//<callback related>
  -	private boolean mbIsCallbackAware=false;
  -	private CallbackEnabledSocketCustomStreamInvocationHandler mCallbackEnabledSocketCustomStreamInvocationHandler=null;
  -	//</callback related>
  +
  +    //<callback related>
  +    private boolean mbIsCallbackAware = false;
  +    private CallbackEnabledSocketCustomStreamInvocationHandler mCallbackEnabledSocketCustomStreamInvocationHandler =
  +        null;
  +
  +    //</callback related>
  +
       /**
        * Constructor DefaultProxyHelper
        *
  @@ -67,9 +76,10 @@
        *
        */
       public DefaultProxyHelper(AbstractAltrmiFactory altrmiFactory,
  -                            AltrmiInvocationHandler invocationHandler,
  -                            String pubishedServiceName, String objectName, Long referenceID,
  -                            Long session) {
  +                              AltrmiInvocationHandler invocationHandler,
  +                              String pubishedServiceName, String objectName, Long referenceID,
  +                              Long session)
  +    {
   
           mAltrmiFactory = altrmiFactory;
           mInvocationHandler = invocationHandler;
  @@ -77,14 +87,15 @@
           mObjectName = objectName;
           mReferenceID = referenceID;
           mSession = session;
  +
           //<callback related>
  -        if(mInvocationHandler instanceof CallbackEnabledSocketCustomStreamInvocationHandler)
  -		{
  +        if (mInvocationHandler instanceof CallbackEnabledSocketCustomStreamInvocationHandler)
  +        {
  +            mCallbackEnabledSocketCustomStreamInvocationHandler =
  +                (CallbackEnabledSocketCustomStreamInvocationHandler) mInvocationHandler;
  +            mbIsCallbackAware = true;
  +        }
   
  -			mCallbackEnabledSocketCustomStreamInvocationHandler	=
  -				(CallbackEnabledSocketCustomStreamInvocationHandler)mInvocationHandler;
  -			mbIsCallbackAware=true;
  -		}
           //</callback related>
       }
   
  @@ -95,7 +106,8 @@
        * @param implBean
        *
        */
  -    public void registerImplObject(Object implBean) {
  +    public void registerImplObject(Object implBean)
  +    {
           mAltrmiFactory.registerReferenceObject(implBean, mReferenceID);
       }
   
  @@ -103,6 +115,8 @@
        * Method processObjectRequestGettingFacade
        *
        *
  +     *
  +     * @param returnClassType
        * @param methodSignature
        * @param args
        * @param objectName
  @@ -113,17 +127,22 @@
        *
        */
       public Object processObjectRequestGettingFacade(
  -            String methodSignature, Object[] args, String objectName) throws Throwable {
  +            Class returnClassType, String methodSignature, Object[] args, String objectName)
  +                throws Throwable
  +    {
   
           boolean arrayRetVal = objectName.endsWith("[]");
           String objNameWithoutArray = objectName.substring(0, objectName.length() - 2);
           MethodFacadeRequest request;
   
  -        if (arrayRetVal) {
  +        if (arrayRetVal)
  +        {
               request = new MethodFacadeRequest(mPublishedServiceName, mObjectName,
                                                 methodSignature, args, mReferenceID,
                                                 objNameWithoutArray, mSession);
  -        } else {
  +        }
  +        else
  +        {
               request = new MethodFacadeRequest(mPublishedServiceName, mObjectName,
                                                 methodSignature, args, mReferenceID, objectName,
                                                 mSession);
  @@ -131,60 +150,79 @@
   
           AltrmiReply reply = mInvocationHandler.handleInvocation(request);
   
  -        if (reply.getReplyCode() == AltrmiReply.METHODFACADEREPLY) {
  +        if (reply.getReplyCode() == AltrmiReply.METHODFACADEREPLY)
  +        {
               MethodFacadeReply mfr = (MethodFacadeReply) reply;
               Long ref = mfr.getReferenceID();
   
               // it might be that the return value was intended to be null.
  -            if (ref == null) {
  +            if (ref == null)
  +            {
                   return null;
               }
   
               Object implBean = mAltrmiFactory.getImplObj(ref);
   
  -            if (implBean == null) {
  -                DefaultProxyHelper bo2 = new DefaultProxyHelper(mAltrmiFactory, mInvocationHandler,
  -                                                            mPublishedServiceName, objectName,
  -                                                            ref, mSession);
  -                Object retFacade = mAltrmiFactory.getInstance(mPublishedServiceName, objectName,
  -                                                              bo2, mAltrmiFactory.isBeanOnly());
  +            if (implBean == null)
  +            {
  +                DefaultProxyHelper pHelper = new DefaultProxyHelper(mAltrmiFactory,
  +                                                                    mInvocationHandler,
  +                                                                    mPublishedServiceName,
  +                                                                    mfr.getObjectName(), ref,
  +                                                                    mSession);
  +                Object retFacade = mAltrmiFactory.getInstance(mPublishedServiceName,
  +                                                              mfr.getObjectName(), pHelper,
  +                                                              mAltrmiFactory.isBeanOnly());
   
  -                bo2.registerImplObject(retFacade);
  +                pHelper.registerImplObject(retFacade);
   
                   return retFacade;
  -            } else {
  +            }
  +            else
  +            {
                   return implBean;
               }
  -        } else if (reply.getReplyCode() == AltrmiReply.METHODFACADEARRAYREPLY) {
  +        }
  +        else if (reply.getReplyCode() == AltrmiReply.METHODFACADEARRAYREPLY)
  +        {
               MethodFacadeArrayReply mfar = (MethodFacadeArrayReply) reply;
  -            Class clazz = mAltrmiFactory.getFacadeClass(mPublishedServiceName,
  -                                                        objNameWithoutArray,
  -                                                        mAltrmiFactory.isBeanOnly());
               Long[] refs = mfar.getReferenceIDs();
  -            Object[] implBeans = (Object[]) Array.newInstance(clazz, refs.length);
  +            String[] objectNames = mfar.getObjectNames();
  +            Object[] implBeans = (Object[]) Array.newInstance(returnClassType, refs.length);
   
  -            for (int i = 0; i < refs.length; i++) {
  +            for (int i = 0; i < refs.length; i++)
  +            {
                   Long ref = refs[i];
   
  -                if (ref == null) {
  +                if (ref == null)
  +                {
                       implBeans[i] = null;
  -                } else {
  -                    implBeans[i] = mAltrmiFactory.getImplObj(ref);
  +                }
  +                else
  +                {
  +                    Object o = mAltrmiFactory.getImplObj(ref);
  +
  +                    implBeans[i] = o;
   
  -                    if (implBeans[i] == null) {
  +                    if (implBeans[i] == null)
  +                    {
                           DefaultProxyHelper bo2 = new DefaultProxyHelper(mAltrmiFactory,
  -                                                                    mInvocationHandler,
  -                                                                    mPublishedServiceName,
  -                                                                    objNameWithoutArray, refs[i],
  -                                                                    mSession);
  +                                                                        mInvocationHandler,
  +                                                                        mPublishedServiceName,
  +                                                                        objectNames[i], refs[i],
  +                                                                        mSession);
                           Object retFacade = null;
   
  -                        try {
  +                        try
  +                        {
                               retFacade = mAltrmiFactory.getInstance(mPublishedServiceName,
  -                                                                   objNameWithoutArray, bo2,
  +                                                                   objectNames[i], bo2,
                                                                      mAltrmiFactory.isBeanOnly());
  -                        } catch (Exception e) {
  -                            System.out.println("objNameWithoutArray=" + objNameWithoutArray);
  +                        }
  +                        catch (Exception e)
  +                        {
  +                            System.out.println("objNameWithoutArray="
  +                                               + returnClassType.getName());
                               System.out.flush();
                               e.printStackTrace();
                           }
  @@ -197,11 +235,15 @@
               }
   
               return implBeans;
  -        } else if (reply.getReplyCode() == AltrmiReply.EXCEPTIONREPLY) {
  +        }
  +        else if (reply.getReplyCode() == AltrmiReply.EXCEPTIONREPLY)
  +        {
               ExceptionReply er = (ExceptionReply) reply;
   
               throw er.getReplyException();
  -        } else {
  +        }
  +        else
  +        {
               throw new AltrmiInvocationException("Internal Error : Unknown reply type :"
                                                   + reply.getClass().getName());
           }
  @@ -219,23 +261,29 @@
        * @throws Throwable
        *
        */
  -    public Object processObjectRequest(String methodSignature, Object[] args) throws Throwable {
  +    public Object processObjectRequest(String methodSignature, Object[] args) throws Throwable
  +    {
   
  -        marshallCorrection(methodSignature,args);
  +        marshallCorrection(methodSignature, args);
   
           MethodRequest request = new MethodRequest(mPublishedServiceName, mObjectName,
                                                     methodSignature, args, mReferenceID, mSession);
           AltrmiReply reply = mInvocationHandler.handleInvocation(request);
   
  -        if (reply.getReplyCode() == AltrmiReply.METHODREPLY) {
  +        if (reply.getReplyCode() == AltrmiReply.METHODREPLY)
  +        {
               MethodReply or = (MethodReply) reply;
   
               return or.getReplyObject();
  -        } else if (reply.getReplyCode() == AltrmiReply.EXCEPTIONREPLY) {
  +        }
  +        else if (reply.getReplyCode() == AltrmiReply.EXCEPTIONREPLY)
  +        {
               ExceptionReply er = (ExceptionReply) reply;
   
               throw er.getReplyException();
  -        } else {
  +        }
  +        else
  +        {
               throw new AltrmiInvocationException("Internal Error : Unknown reply type :"
                                                   + reply.getClass().getName());
           }
  @@ -251,7 +299,8 @@
        * @throws Throwable
        *
        */
  -    public void processVoidRequest(String methodSignature, Object[] args) throws Throwable {
  +    public void processVoidRequest(String methodSignature, Object[] args) throws Throwable
  +    {
   
           MethodRequest request = new MethodRequest(mPublishedServiceName, mObjectName,
                                                     methodSignature, args, mReferenceID, mSession);
  @@ -259,15 +308,20 @@
           //debug(args);
           AltrmiReply reply = mInvocationHandler.handleInvocation(request);
   
  -        if (reply.getReplyCode() == AltrmiReply.METHODREPLY) {
  +        if (reply.getReplyCode() == AltrmiReply.METHODREPLY)
  +        {
               MethodReply or = (MethodReply) reply;
   
               return;
  -        } else if (reply.getReplyCode() == AltrmiReply.EXCEPTIONREPLY) {
  +        }
  +        else if (reply.getReplyCode() == AltrmiReply.EXCEPTIONREPLY)
  +        {
               ExceptionReply er = (ExceptionReply) reply;
   
               throw er.getReplyException();
  -        } else {
  +        }
  +        else
  +        {
               throw new AltrmiInvocationException("Internal Error : Unknown reply type :"
                                                   + reply.getClass().getName());
           }
  @@ -284,15 +338,20 @@
        *
        */
       public void processVoidRequestWithRedirect(String methodSignature, Object[] args)
  -            throws Throwable {
  +            throws Throwable
  +    {
   
           Object[] newArgs = new Object[args.length];
   
  -        for (int i = 0; i < args.length; i++) {
  -            if (args[i] instanceof AltrmiProxy) {
  +        for (int i = 0; i < args.length; i++)
  +        {
  +            if (args[i] instanceof AltrmiProxy)
  +            {
   
                   //TODO somehow get the reference details and put a redirect place holder here
  -            } else {
  +            }
  +            else
  +            {
                   newArgs[i] = args[i];
               }
           }
  @@ -310,16 +369,19 @@
        * @return
        *
        */
  -    public FacadeRefHolder makeFacadeRefHolder(AltrmiProxy obj, String objectName) {
  +    public FacadeRefHolder makeFacadeRefHolder(AltrmiProxy obj, String objectName)
  +    {
   
           Long refID = mAltrmiFactory.getReferenceID(obj);
   
           return new FacadeRefHolder(refID, objectName);
       }
   
  -    private void debug(Object[] args) {
  +    private void debug(Object[] args)
  +    {
   
  -        for (int i = 0; i < args.length; i++) {
  +        for (int i = 0; i < args.length; i++)
  +        {
               Object arg = args[i];
   
               System.out.println("i = " + i + " class= " + args[i].getClass().getName() + " "
  @@ -327,66 +389,83 @@
           }
       }
   
  -    private void marshallCorrection(String methodSignature , Object[] args) {
  -
  -		String _methodArgumentClasses = methodSignature.substring(methodSignature.indexOf("(")+1,methodSignature.lastIndexOf(")"));
  -		StringTokenizer _methodArgumentClassTokens = new StringTokenizer(_methodArgumentClasses,",");
  -
  -        for (int i = 0; i < args.length; i++) {
  +    private void marshallCorrection(String methodSignature, Object[] args)
  +    {
   
  -			String _sArgClass=_methodArgumentClassTokens.nextToken().trim();
  -			Class _cArgClass=null;
  -			try
  -			{
  -
  -				_cArgClass=Class.forName(_sArgClass);
  -			}
  -			catch(ClassNotFoundException cnfe)
  -			{
  -				System.err.println("Class "+_sArgClass +" Not Found");
  -			}
  +        String _methodArgumentClasses =
  +            methodSignature.substring(methodSignature.indexOf("(") + 1,
  +                                      methodSignature.lastIndexOf(")"));
  +        StringTokenizer _methodArgumentClassTokens = new StringTokenizer(_methodArgumentClasses,
  +                                                         ",");
  +
  +        for (int i = 0; i < args.length; i++)
  +        {
  +            String _sArgClass = _methodArgumentClassTokens.nextToken().trim();
  +            Class _cArgClass = null;
  +
  +            try
  +            {
  +                _cArgClass = Class.forName(_sArgClass);
  +            }
  +            catch (ClassNotFoundException cnfe)
  +            {
  +                System.err.println("Class " + _sArgClass + " Not Found");
  +            }
   
               //check whether its one of those remote ref that we got from the server
               //TODO : todo
  -            if (args[i] instanceof AltrmiProxy) {
  +            if (args[i] instanceof AltrmiProxy)
  +            {
                   AltrmiProxy proxy = (AltrmiProxy) args[i];
   
  -                if (mAltrmiFactory.getReferenceID(proxy) != null) {
  +                if (mAltrmiFactory.getReferenceID(proxy) != null)
  +                {
                       String objName = args[i].getClass().getName().substring(16);
   
                       args[i] = makeFacadeRefHolder(proxy, objName);
                   }
               }
  -            else if(mbIsCallbackAware)
  -			{
  -				String publishedName = mCallbackEnabledSocketCustomStreamInvocationHandler.getPublishedName(args[i]);
  -				if(publishedName!=null) //already published
  -				{
  -					ExposedObjectProxy exposedObjectProxy =  new ExposedObjectProxy(publishedName);
  -					args[i]=exposedObjectProxy;
  -				}
  -				else //check whether its Publish'able
  -				{
  -					if(!_cArgClass.isInterface()) //Hey do we handle only interfaces?
  -						continue;
  -					if(_cArgClass.isAssignableFrom(args[i].getClass()))
  -					{
  -						try
  -						{
  -							mCallbackEnabledSocketCustomStreamInvocationHandler.exposeObject(args[i],_cArgClass);
  -						}
  -						catch(AltrmiCallbackException ace)
  -						{
  -							ace.printStackTrace();
  -						}
  -						publishedName = mCallbackEnabledSocketCustomStreamInvocationHandler.getPublishedName(args[i]);
  -						ExposedObjectProxy exposedObjectProxy =  new ExposedObjectProxy(publishedName);
  -						args[i]=exposedObjectProxy;
  +            else if (mbIsCallbackAware)
  +            {
  +                String publishedName =
  +                    mCallbackEnabledSocketCustomStreamInvocationHandler.getPublishedName(args[i]);
  +
  +                if (publishedName != null)            //already published
  +                {
  +                    ExposedObjectProxy exposedObjectProxy = new ExposedObjectProxy(publishedName);
   
  -					}
  +                    args[i] = exposedObjectProxy;
  +                }
  +                else                                  //check whether its Publish'able
  +                {
  +                    if (!_cArgClass.isInterface())    //Hey do we handle only interfaces?
  +                    {
  +                        continue;
  +                    }
   
  -				}
  -			}
  +                    if (_cArgClass.isAssignableFrom(args[i].getClass()))
  +                    {
  +                        try
  +                        {
  +                            mCallbackEnabledSocketCustomStreamInvocationHandler
  +                                .exposeObject(args[i], _cArgClass);
  +                        }
  +                        catch (AltrmiCallbackException ace)
  +                        {
  +                            ace.printStackTrace();
  +                        }
  +
  +                        publishedName =
  +                            mCallbackEnabledSocketCustomStreamInvocationHandler
  +                                .getPublishedName(args[i]);
  +
  +                        ExposedObjectProxy exposedObjectProxy =
  +                            new ExposedObjectProxy(publishedName);
  +
  +                        args[i] = exposedObjectProxy;
  +                    }
  +                }
  +            }
           }
       }
   
  @@ -399,23 +478,35 @@
        * @return
        *
        */
  -    public Long getReferenceID(Object factory) {
  +    public Long getReferenceID(Object factory)
  +    {
   
           // this checks the factory because reference IDs should not be
           // given out to any requester.  It should be privileged information.
  -
  -        if (factory == mAltrmiFactory) {
  +        if (factory == mAltrmiFactory)
  +        {
               return mReferenceID;
  -        } else {
  +        }
  +        else
  +        {
               return null;
           }
       }
   
  -    protected void finalize() throws Throwable {
  -        synchronized(mAltrmiFactory) {
  -            GarbageCollectionReply gcr = (GarbageCollectionReply) mInvocationHandler.handleInvocation(new GarbageCollectionRequest(mPublishedServiceName, mObjectName, mSession, mReferenceID));
  +    protected void finalize() throws Throwable
  +    {
  +
  +        synchronized (mAltrmiFactory)
  +        {
  +            GarbageCollectionReply gcr =
  +                (GarbageCollectionReply) mInvocationHandler
  +                    .handleInvocation(new GarbageCollectionRequest(mPublishedServiceName,
  +                                                                   mObjectName, mSession,
  +                                                                   mReferenceID));
  +
               //System.out.println("BO finalizing");
           }
  +
           super.finalize();
       }
   }
  
  
  
  1.2       +5 -0      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/socket/CallbackEnabledSocketCustomStreamInvocationHandler.java
  
  Index: CallbackEnabledSocketCustomStreamInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/socket/CallbackEnabledSocketCustomStreamInvocationHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CallbackEnabledSocketCustomStreamInvocationHandler.java	20 Apr 2002 17:39:44 -0000	1.1
  +++ CallbackEnabledSocketCustomStreamInvocationHandler.java	21 Apr 2002 09:42:01 -0000	1.2
  @@ -24,7 +24,7 @@
    * Class CallbackEnabledSocketCustomStreamInvocationHandler
    *
    * @author <a href="mailto:vinayc77@yahoo.com">Vinay Chandran</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public final class CallbackEnabledSocketCustomStreamInvocationHandler
           extends AbstractSocketStreamInvocationHandler {
  @@ -59,5 +59,10 @@
   	{
   		return mCallbackEnabledClientCustomStreamReadWriter.getPublishedName(tobeExposedObject);
   	}
  +
  +    public boolean isCallbackEnabled() {
  +        return true;
  +    }
  +
   }
   
  
  
  
  1.2       +6 -1      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/direct/DirectInvocationHandler.java
  
  Index: DirectInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/direct/DirectInvocationHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DirectInvocationHandler.java	3 Apr 2002 11:29:50 -0000	1.1
  +++ DirectInvocationHandler.java	21 Apr 2002 09:42:01 -0000	1.2
  @@ -32,7 +32,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public final class DirectInvocationHandler extends AbstractDirectInvocationHandler
   {
  @@ -58,4 +58,9 @@
       {
           return mAltrmiInvocationHandler.handleInvocation(request);
       }
  +
  +    public boolean isCallbackEnabled() {
  +        return false;
  +    }
  +
   }
  
  
  
  1.2       +6 -1      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/direct/DirectMarshalledInvocationHandler.java
  
  Index: DirectMarshalledInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/direct/DirectMarshalledInvocationHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DirectMarshalledInvocationHandler.java	3 Apr 2002 11:29:50 -0000	1.1
  +++ DirectMarshalledInvocationHandler.java	21 Apr 2002 09:42:01 -0000	1.2
  @@ -35,7 +35,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public final class DirectMarshalledInvocationHandler extends AbstractDirectInvocationHandler
   {
  @@ -115,4 +115,9 @@
       {
           return mInterfacesClassLoader;
       }
  +
  +    public boolean isCallbackEnabled() {
  +        return false;
  +    }
  +
   }
  
  
  
  1.2       +6 -1      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/multiple/RotatingMultipleInvocationHandler.java
  
  Index: RotatingMultipleInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/multiple/RotatingMultipleInvocationHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RotatingMultipleInvocationHandler.java	3 Apr 2002 11:29:50 -0000	1.1
  +++ RotatingMultipleInvocationHandler.java	21 Apr 2002 09:42:01 -0000	1.2
  @@ -23,7 +23,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class RotatingMultipleInvocationHandler extends AbstractMultipleInvocationHandler
   {
  @@ -115,4 +115,9 @@
                   .handleInvocation(request);
           }
       }
  +
  +    public boolean isCallbackEnabled() {
  +        return false;
  +    }
  +
   }
  
  
  
  1.2       +6 -1      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/piped/AbstractPipedStreamInvocationHandler.java
  
  Index: AbstractPipedStreamInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/piped/AbstractPipedStreamInvocationHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractPipedStreamInvocationHandler.java	3 Apr 2002 11:29:51 -0000	1.1
  +++ AbstractPipedStreamInvocationHandler.java	21 Apr 2002 09:42:01 -0000	1.2
  @@ -31,7 +31,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public abstract class AbstractPipedStreamInvocationHandler extends StreamInvocationHandler
   {
  @@ -83,4 +83,9 @@
   
       protected abstract ClientStreamReadWriter createClientStreamReadWriter(
           InputStream in, OutputStream out) throws IOException;
  +
  +    public boolean isCallbackEnabled() {
  +        return false;
  +    }
  +
   }
  
  
  
  1.2       +6 -1      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/rmi/RmiInvocationHandler.java
  
  Index: RmiInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/rmi/RmiInvocationHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RmiInvocationHandler.java	3 Apr 2002 11:29:51 -0000	1.1
  +++ RmiInvocationHandler.java	21 Apr 2002 09:42:02 -0000	1.2
  @@ -41,7 +41,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public final class RmiInvocationHandler extends AbstractClientInvocationHandler
   {
  @@ -230,4 +230,9 @@
       {
           return mLastRealRequest;
       }
  +
  +    public boolean isCallbackEnabled() {
  +        return false;
  +    }
  +
   }
  
  
  
  1.2       +5 -1      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream/StreamInvocationHandler.java
  
  Index: StreamInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream/StreamInvocationHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StreamInvocationHandler.java	3 Apr 2002 11:29:52 -0000	1.1
  +++ StreamInvocationHandler.java	21 Apr 2002 09:42:02 -0000	1.2
  @@ -38,7 +38,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public abstract class StreamInvocationHandler extends AbstractClientInvocationHandler
   {
  @@ -228,5 +228,9 @@
       public long getLastRealRequest()
       {
           return mLastRealRequest;
  +    }
  +
  +    public boolean isCallbackEnabled() {
  +        return false;
       }
   }
  
  
  
  1.3       +20 -3     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/common/MethodFacadeArrayReply.java
  
  Index: MethodFacadeArrayReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/common/MethodFacadeArrayReply.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MethodFacadeArrayReply.java	4 Apr 2002 12:53:03 -0000	1.2
  +++ MethodFacadeArrayReply.java	21 Apr 2002 09:42:02 -0000	1.3
  @@ -20,13 +20,14 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public final class MethodFacadeArrayReply extends AltrmiReply
   {
  -    static final long serialVersionUID = 3982374893707173208L;
   
  +    static final long serialVersionUID = 3982374893707173208L;
       private Long[] mReferenceIDs;
  +    private String[] mObjectNames;
   
       /**
        * Constructor MethodFacadeReply
  @@ -34,11 +35,13 @@
        *
        *
        * @param referenceIDs
  +     * @param objectTypes
        *
        */
  -    public MethodFacadeArrayReply(Long[] referenceIDs)
  +    public MethodFacadeArrayReply(Long[] referenceIDs, String[] objectNames)
       {
           mReferenceIDs = referenceIDs;
  +        mObjectNames = objectNames;
       }
   
       /**
  @@ -63,6 +66,18 @@
       }
   
       /**
  +     * Method getObjectTypes
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public String[] getObjectNames()
  +    {
  +        return mObjectNames;
  +    }
  +
  +    /**
        * Method getReplyCode.  This is quicker than instanceof for type checking.
        *
        *
  @@ -92,6 +107,7 @@
       public void writeExternal(ObjectOutput out) throws IOException
       {
           out.writeObject(mReferenceIDs);
  +        out.writeObject(mObjectNames);
       }
   
       /**
  @@ -109,5 +125,6 @@
       public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
       {
           mReferenceIDs = (Long[]) in.readObject();
  +        mObjectNames = (String[]) in.readObject();
       }
   }
  
  
  
  1.3       +21 -4     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/common/MethodFacadeReply.java
  
  Index: MethodFacadeReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/common/MethodFacadeReply.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MethodFacadeReply.java	4 Apr 2002 12:53:03 -0000	1.2
  +++ MethodFacadeReply.java	21 Apr 2002 09:42:02 -0000	1.3
  @@ -20,24 +20,27 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public final class MethodFacadeReply extends AltrmiReply
   {
  -    static final long serialVersionUID = 3332468131008501932L;
   
  +    static final long serialVersionUID = 3332468131008501932L;
       private Long mReferenceID;
  +    private String mObjectName;
   
       /**
        * Constructor MethodFacadeReply
        *
        *
        * @param referenceID
  +     * @param objectName
        *
        */
  -    public MethodFacadeReply(Long referenceID)
  +    public MethodFacadeReply(Long referenceID, String objectName)
       {
  -        this.mReferenceID = referenceID;
  +        mReferenceID = referenceID;
  +        mObjectName = objectName;
       }
   
       /**
  @@ -62,6 +65,18 @@
       }
   
       /**
  +     * Method getObjectName
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public String getObjectName()
  +    {
  +        return mObjectName;
  +    }
  +
  +    /**
        * Method getReplyCode.  This is quicker than instanceof for type checking.
        *
        *
  @@ -91,6 +106,7 @@
       public void writeExternal(ObjectOutput out) throws IOException
       {
           out.writeObject(mReferenceID);
  +        out.writeObject(mObjectName);
       }
   
       /**
  @@ -108,5 +124,6 @@
       public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
       {
           mReferenceID = (Long) in.readObject();
  +        mObjectName = (String) in.readObject();
       }
   }
  
  
  
  1.4       +11 -2     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/ProxyGeneratorImpl.java
  
  Index: ProxyGeneratorImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/ProxyGeneratorImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProxyGeneratorImpl.java	10 Apr 2002 23:36:58 -0000	1.3
  +++ ProxyGeneratorImpl.java	21 Apr 2002 09:42:02 -0000	1.4
  @@ -32,7 +32,7 @@
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
    * @author Mike Miller of www.gac.com
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class ProxyGeneratorImpl extends AbstractMethodHandler implements ProxyGenerator
   {
  @@ -349,8 +349,17 @@
   
                           if (isFacadeRetVal)
                           {
  +                            Class retClassType = rClass;
  +                            boolean isArray = false;
  +                            if (rClass.isArray())
  +                            {
  +                                retClassType = rClass.getComponentType();
  +                                isArray = true;
  +                            }
  +
                               mClassSource.println(
  -                                "      Object retVal = mProxyHelper.processObjectRequestGettingFacade(\""
  +                                "      Object retVal = mProxyHelper.processObjectRequestGettingFacade("
  +                                + retClassType.getName() + ".class , \""
                                   + methodSignature.toString() + "\",args,\""
                                   + encodeClassName(getClassType(rClass)) + "\");");
                               mClassSource.println("      return (" + getClassType(rClass)
  
  
  
  1.2       +11 -1     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/MethodInvocationHandler.java
  
  Index: MethodInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/MethodInvocationHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MethodInvocationHandler.java	3 Apr 2002 11:29:54 -0000	1.1
  +++ MethodInvocationHandler.java	21 Apr 2002 09:42:02 -0000	1.2
  @@ -19,7 +19,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public interface MethodInvocationHandler
   {
  @@ -63,4 +63,14 @@
        *
        */
       Long getOrMakeReferenceIDForBean(Object implBean);
  +
  +    /**
  +     * Method getMostDerivedType
  +     *
  +     *
  +     * @param beanImpl
  +     *
  +     */
  +    Class getMostDerivedType(Object beanImpl);
  +
   }
  
  
  
  1.2       +35 -1     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/PublicationDescription.java
  
  Index: PublicationDescription.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/PublicationDescription.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PublicationDescription.java	3 Apr 2002 11:29:54 -0000	1.1
  +++ PublicationDescription.java	21 Apr 2002 09:42:02 -0000	1.2
  @@ -15,7 +15,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version * $Revision: 1.1 $
  + * @version * $Revision: 1.2 $
    */
   public final class PublicationDescription
   {
  @@ -220,5 +220,39 @@
               throw new PublicationException("Class not found during publication:" + e.getMessage()
                                              + " " + e.getException().getMessage());
           }
  +    }
  +
  +    /**
  +     * Method getMostDerivedType
  +     *
  +     *
  +     * @param beanImpl
  +     *
  +     * @return
  +     *
  +     */
  +    public Class getMostDerivedType(Object beanImpl)
  +    {
  +
  +        Class facadeRetVal = null;
  +
  +        for (int i = 0; i < mAdditionalFacades.length; i++)
  +        {
  +            Class facade = mAdditionalFacades[i];
  +
  +            if (facade.isAssignableFrom(beanImpl.getClass()))
  +            {
  +                if (facadeRetVal == null)
  +                {
  +                    facadeRetVal = facade;
  +                }
  +                else if (facadeRetVal.isAssignableFrom(facade))
  +                {
  +                    facadeRetVal = facade;
  +                }
  +            }
  +        }
  +
  +        return facadeRetVal;
       }
   }
  
  
  
  1.3       +91 -29    jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/DefaultMethodInvocationHandler.java
  
  Index: DefaultMethodInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/DefaultMethodInvocationHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultMethodInvocationHandler.java	7 Apr 2002 09:21:33 -0000	1.2
  +++ DefaultMethodInvocationHandler.java	21 Apr 2002 09:42:02 -0000	1.3
  @@ -21,6 +21,7 @@
   import org.apache.excalibur.altrmi.common.FacadeRefHolder;
   import org.apache.excalibur.altrmi.server.MethodInvocationHandler;
   import org.apache.excalibur.altrmi.server.AltrmiPublisher;
  +import org.apache.excalibur.altrmi.server.PublicationDescription;
   import org.apache.excalibur.altrmi.client.AltrmiProxy;
   
   import java.util.HashMap;
  @@ -41,9 +42,10 @@
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
    * @author Vinay Chandrasekharan <a href="mailto:vinay_chandran@users.sourceforge.net">vinay_chandran@users.sourceforge.net</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
  -public class DefaultMethodInvocationHandler implements MethodInvocationHandler {
  +public class DefaultMethodInvocationHandler implements MethodInvocationHandler
  +{
   
       private WeakHashMap mRefBeans = new WeakHashMap();
       private WeakHashMap mBeanRefs = new WeakHashMap();
  @@ -52,6 +54,7 @@
       private AltrmiPublisher mAltrmiPublisher;
       private String mPublishedThing;
       private Object mBeanImpl;
  +    private final PublicationDescription mPublicationDescription;
   
       /**
        * Constructor DefaultMethodInvocationHandler
  @@ -61,14 +64,18 @@
        * @param altrmiPublisher
        * @param publishedThing
        * @param methodMap
  +     * @param publicationDescription
        *
        */
       public DefaultMethodInvocationHandler(AltrmiPublisher altrmiPublisher, String publishedThing,
  -                                          HashMap methodMap) {
  +                                          HashMap methodMap,
  +                                          PublicationDescription publicationDescription)
  +    {
   
           mAltrmiPublisher = altrmiPublisher;
           mPublishedThing = publishedThing;
           mMethodMap = methodMap;
  +        mPublicationDescription = publicationDescription;
       }
   
       /**
  @@ -78,7 +85,8 @@
        * @return
        *
        */
  -    public String toString() {
  +    public String toString()
  +    {
           return "DMIH:" + mPublishedThing;
       }
   
  @@ -90,11 +98,14 @@
        * @param beanImpl
        *
        */
  -    public void addImplementationBean(Long referenceID, Object beanImpl) {
  -        if (referenceID.equals(new Long(0))) {
  +    public void addImplementationBean(Long referenceID, Object beanImpl)
  +    {
  +
  +        if (referenceID.equals(new Long(0)))
  +        {
               mBeanImpl = beanImpl;
           }
  -        WeakReference wr = new WeakReference(beanImpl);
  +
           mRefBeans.put(referenceID, new WeakReference(beanImpl));
           mBeanRefs.put(beanImpl, referenceID);
       }
  @@ -107,7 +118,8 @@
        * @param withImplBean
        *
        */
  -    public void replaceImplementationBean(Object implBean, Object withImplBean) {
  +    public void replaceImplementationBean(Object implBean, Object withImplBean)
  +    {
   
           Long ref = (Long) mBeanRefs.get(implBean);
   
  @@ -115,11 +127,10 @@
           mBeanRefs.remove(implBean);
           mBeanRefs.put(withImplBean, ref);
   
  -        if (mBeanImpl == implBean) {
  +        if (mBeanImpl == implBean)
  +        {
               mBeanImpl = withImplBean;
           }
  -
  -
       }
   
       /**
  @@ -129,11 +140,13 @@
        * @param implBean
        *
        */
  -    public Long getOrMakeReferenceIDForBean(Object implBean) {
  +    public Long getOrMakeReferenceIDForBean(Object implBean)
  +    {
   
           Long ref = (Long) mBeanRefs.get(implBean);
   
  -        if (ref == null) {
  +        if (ref == null)
  +        {
   
               //ref = new Long((long) ((long) mNextReference++ << 32)
               //               + (long) Math.round(Math.random()));
  @@ -156,25 +169,33 @@
        * @return
        *
        */
  -    public AltrmiReply handleMethodInvocation(MethodRequest request) {
  +    public AltrmiReply handleMethodInvocation(MethodRequest request)
  +    {
   
           String methodSignature = request.getMethodSignature();
   
  -        if (!mMethodMap.containsKey(methodSignature)) {
  +        if (!mMethodMap.containsKey(methodSignature))
  +        {
               return new ExceptionReply(
                   new AltrmiInvocationException("Method not present in impl"));
           }
   
           Method method = (Method) mMethodMap.get(methodSignature);
   
  -        try {
  +        try
  +        {
               WeakReference wr = (WeakReference) mRefBeans.get(request.getReferenceID());
  -            if (wr == null) {
  -                System.out.println("missing weak reference for referenceID - " + request.getReferenceID());
  +
  +            if (wr == null)
  +            {
  +                System.out.println("missing weak reference for referenceID - "
  +                                   + request.getReferenceID() + " pub " + mPublishedThing);
               }
  +
               Object beanImpl = wr.get();
   
  -            if (beanImpl == null) {
  +            if (beanImpl == null)
  +            {
                   System.out.println("Missin beanImpl for " + request.getReferenceID());
   
                   return new NoSuchReferenceReply(request.getReferenceID());
  @@ -185,19 +206,26 @@
               correctArgs(request, args);
   
               return new MethodReply(method.invoke(beanImpl, request.getArgs()));
  -        } catch (InvocationTargetException ite) {
  +        }
  +        catch (InvocationTargetException ite)
  +        {
               Throwable t = ite.getTargetException();
   
  -            if (t instanceof Serializable) {
  +            if (t instanceof Serializable)
  +            {
   
                   // NOTE Sever side stack traces will appear on the client side
                   return new ExceptionReply(t);
  -            } else {
  +            }
  +            else
  +            {
                   return new ExceptionReply(
                       new AltrmiInvocationException(
                           "Exception was not serializable :" + t.getClass().getName()));
               }
  -        } catch (Throwable t) {
  +        }
  +        catch (Throwable t)
  +        {
               System.out.flush();
               t.printStackTrace();
   
  @@ -207,28 +235,34 @@
           }
       }
   
  -    private void correctArgs(MethodRequest mr, Object[] args) {
  +    private void correctArgs(MethodRequest mr, Object[] args)
  +    {
   
  -        for (int i = 0; i < args.length; i++) {
  +        for (int i = 0; i < args.length; i++)
  +        {
   
               // TODO find a faster way to do this....
  -            if (args[i] instanceof FacadeRefHolder) {
  +            if (args[i] instanceof FacadeRefHolder)
  +            {
                   FacadeRefHolder frh = (FacadeRefHolder) args[i];
                   DefaultMethodInvocationHandler methodInvocationHandler =
                       (DefaultMethodInvocationHandler) mAltrmiPublisher
                           .getMethodInvocationHandler(frh.getObjectName());
  +                WeakReference wr =
  +                    (WeakReference) methodInvocationHandler.mRefBeans.get(frh.getReferenceID());
   
  -                WeakReference wr = (WeakReference) methodInvocationHandler.mRefBeans.get(frh.getReferenceID());
                   args[i] = wr.get();
               }
           }
       }
   
  -    private void debug(Object[] args) {
  +    private void debug(Object[] args)
  +    {
   
           System.out.println("*************************");
   
  -        for (int i = 0; i < args.length; i++) {
  +        for (int i = 0; i < args.length; i++)
  +        {
               Object arg = args[i];
   
               System.out.println("i = " + i + " class= " + args[i].getClass().getName() + " "
  @@ -236,5 +270,33 @@
           }
   
           System.out.println("*************************");
  +    }
  +
  +    /**
  +     * Method getMostDerivedType
  +     *
  +     *
  +     * @param beanImpl
  +     *
  +     * @return
  +     *
  +     */
  +    public Class getMostDerivedType(Object beanImpl)
  +    {
  +        return mPublicationDescription.getMostDerivedType(beanImpl);
  +    }
  +
  +    /**
  +     * Method encodeClassName
  +     *
  +     *
  +     * @param className
  +     *
  +     * @return
  +     *
  +     */
  +    public String encodeClassName(String className)
  +    {
  +        return className.replace('.', '$');
       }
   }
  
  
  
  1.4       +231 -174  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters/InvocationHandlerAdapter.java
  
  Index: InvocationHandlerAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters/InvocationHandlerAdapter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- InvocationHandlerAdapter.java	10 Apr 2002 22:33:10 -0000	1.3
  +++ InvocationHandlerAdapter.java	21 Apr 2002 09:42:02 -0000	1.4
  @@ -39,6 +39,7 @@
   import org.apache.excalibur.altrmi.server.ClassRetrievalException;
   import org.apache.excalibur.altrmi.server.ClassRetriever;
   import org.apache.excalibur.altrmi.server.AltrmiAuthenticator;
  +import org.apache.excalibur.altrmi.server.PublicationDescription;
   import org.apache.excalibur.altrmi.server.impl.classretrievers.NoClassRetriever;
   import org.apache.excalibur.altrmi.server.impl.DefaultAuthenticator;
   import org.apache.excalibur.altrmi.server.impl.AbstractServer;
  @@ -54,7 +55,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class InvocationHandlerAdapter extends PublicationAdapter
           implements AltrmiInvocationHandler
  @@ -112,238 +113,294 @@
           // it is the one we want to be most speedy.
           if (request.getRequestCode() == AltrmiRequest.METHODREQUEST)
           {
  -            MethodRequest mReq = (MethodRequest) request;
  -            String publishedThing = mReq.getPublishedServiceName() + "_" + mReq.getObjectName();
  +            return doMethodRequest(request);
   
  -            if (!mPublishedObjects.containsKey(publishedThing))
  -            {
  -                return new NotPublishedReply();
  -            }
  +        }
  +        else if (request.getRequestCode() == AltrmiRequest.METHODFACADEREQUEST)
  +        {
  +            return doMethodFacadeRequest(request);
   
  -            MethodInvocationHandler methodInvocationHandler =
  -                (MethodInvocationHandler) mPublishedObjects.get(publishedThing);
  +        }
  +        else if (request.getRequestCode() == AltrmiRequest.GCREQUEST)
  +        {
  +            return doGarbageCollectionRequest(request);
   
  -            return methodInvocationHandler.handleMethodInvocation(mReq);
           }
  -        else if (request.getRequestCode() == AltrmiRequest.METHODFACADEREQUEST)
  +        else if (request.getRequestCode() == AltrmiRequest.LOOKUPREQUEST)
           {
  -            MethodFacadeRequest mFacReq = (MethodFacadeRequest) request;
  -            String publishedThing = mFacReq.getPublishedServiceName() + "_"
  -                                    + mFacReq.getObjectName();
  +            return doLookupRequest(request);
   
  -            if (!mPublishedObjects.containsKey(publishedThing))
  -            {
  -                return new NotPublishedReply();
  -            }
  +        }
  +        else if (request.getRequestCode() == AltrmiRequest.CLASSREQUEST)
  +        {
  +            return doClassRequest(request);
   
  -            if (!sessionExists(mFacReq.getSession()))
  -            {
  -                return new ExceptionReply(
  -                    new AltrmiInvocationException("TODO - you dirty rat/hacker"));
  -            }
  +        }
  +        else if (request.getRequestCode() == AltrmiRequest.OPENCONNECTIONREQUEST)
  +        {
  +            return doOpenConnectionRequest();
   
  -            MethodInvocationHandler methodInvocationHandler =
  -                (MethodInvocationHandler) mPublishedObjects.get(publishedThing);
  -            AltrmiReply ar = methodInvocationHandler.handleMethodInvocation(mFacReq);
  +        }
  +        else if (request.getRequestCode() == AltrmiRequest.PINGREQUEST)
  +        {
   
  -            if (ar.getReplyCode() == AltrmiReply.EXCEPTIONREPLY)
  -            {
  -                return ar;
  -            }
  -            else if (ar.getReplyCode() >= AltrmiReply.PROBLEMREPLY)
  -            {
  -                return ar;
  -            }
  -            else if (ar.getReplyCode() != AltrmiReply.METHODREPLY)
  -            {
  -                return new RequestFailedReply("TODO");
  -            }
  +            // we could communicate back useful state info in this transaction.
  +            return new PingReply();
  +        }
  +        else if (request.getRequestCode() == AltrmiRequest.LISTREQUEST)
  +        {
  +            return doListRequest();
  +        }
  +        else
  +        {
  +            return new RequestFailedReply("Unknown request :" + request.getClass().getName());
  +        }
  +    }
   
  -            Object replyObject = ((MethodReply) ar).getReplyObject();
  +    private AltrmiReply doMethodFacadeRequest(AltrmiRequest request) {
  +        MethodFacadeRequest mFacReq = (MethodFacadeRequest) request;
  +        String publishedThing = mFacReq.getPublishedServiceName() + "_"
  +                                + mFacReq.getObjectName();
   
  -            if (replyObject == null)
  -            {
  -                return new MethodFacadeReply(null);    // null passing
  -            }
  -            else if (!replyObject.getClass().isArray())
  -            {
  -                Object beanImpl = replyObject;
  -                MethodInvocationHandler methodInvocationHandler2 =
  -                    (MethodInvocationHandler) mPublishedObjects
  -                        .get(mFacReq.getPublishedServiceName() + "_"
  -                             + mFacReq.getBaseReturnClassNameEncoded());
  -
  -                if (methodInvocationHandler2 == null)
  -                {
  -                    return new NotPublishedReply();
  -                }
  -
  -                if (!sessionExists(mFacReq.getSession()))
  -                {
  -                    return new ExceptionReply(
  -                        new AltrmiInvocationException("TODO - you dirty rat/hacker"));
  -                }
  +        if (!mPublishedObjects.containsKey(publishedThing))
  +        {
  +            return new NotPublishedReply();
  +        }
   
  -                //TODO a decent ref number for main?
  -                Long newRef = methodInvocationHandler2.getOrMakeReferenceIDForBean(beanImpl);
  +        if (!sessionExists(mFacReq.getSession()))
  +        {
  +            return new ExceptionReply(
  +                new AltrmiInvocationException("TODO - you dirty rat/hacker"));
  +        }
   
  -                // make sure the bean is not garbage collected.
  -                AltrmiSession sess = (AltrmiSession) mSessions.get(mFacReq.getSession());
  +        MethodInvocationHandler methodInvocationHandler =
  +            (MethodInvocationHandler) mPublishedObjects.get(publishedThing);
  +        AltrmiReply ar = methodInvocationHandler.handleMethodInvocation(mFacReq);
   
  -                sess.addBeanInUse(newRef, beanImpl);
  +        if (ar.getReplyCode() == AltrmiReply.EXCEPTIONREPLY)
  +        {
  +            return ar;
  +        }
  +        else if (ar.getReplyCode() >= AltrmiReply.PROBLEMREPLY)
  +        {
  +            return ar;
  +        }
  +        else if (ar.getReplyCode() == AltrmiReply.METHODREPLY)
  +        {
  +            Object methodReply = ((MethodReply) ar).getReplyObject();
   
  -                //long newRef2 = asih2.getOrMakeReferenceIDForBean(beanImpl);
  -                return new MethodFacadeReply(newRef);
  +            if (methodReply == null)
  +            {
  +                return new MethodFacadeReply(null, null);    // null passing
  +            }
  +            else if (!methodReply.getClass().isArray())
  +            {
  +                return doMethodFacadeRequestNonArray(methodReply, mFacReq);
               }
               else
               {
  -                Object[] beanImpls = (Object[]) replyObject;
  -                Long[] refs = new Long[beanImpls.length];
  +                return doMethodFacadeRequestArray(methodReply, mFacReq);
   
  -                for (int i = 0; i < beanImpls.length; i++)
  -                {
  -                    Object impl = beanImpls[i];
  -                    MethodInvocationHandler methodInvocationHandler2 =
  -                        (MethodInvocationHandler) mPublishedObjects
  -                            .get(mFacReq.getPublishedServiceName() + "_"
  -                                 + mFacReq.getBaseReturnClassNameEncoded());
  -
  -                    if (methodInvocationHandler2 == null)
  -                    {
  -                        return new NotPublishedReply();
  -                    }
  -
  -                    if (!sessionExists(mFacReq.getSession()))
  -                    {
  -                        return new ExceptionReply(
  -                            new AltrmiInvocationException("TODO - you dirty rat/hacker"));
  -                    }
  -
  -                    //TODO a decent ref number for main?
  -                    if (beanImpls[i] == null)
  -                    {
  -                        refs[i] = null;
  -                    }
  -                    else
  -                    {
  -                        refs[i] =
  -                            methodInvocationHandler2.getOrMakeReferenceIDForBean(beanImpls[i]);
  -
  -                        AltrmiSession sess = (AltrmiSession) mSessions.get(mFacReq.getSession());
  -
  -                        sess.addBeanInUse(refs[i], beanImpls[i]);
  -                    }
  -                }
  -
  -                return new MethodFacadeArrayReply(refs);
               }
           }
  -        else if (request.getRequestCode() == AltrmiRequest.GCREQUEST)
  +        else
           {
  -            GarbageCollectionRequest gcr = (GarbageCollectionRequest) request;
  -            String publishedThing = gcr.getPublishedServiceName() + "_" + gcr.getObjectName();
  +            // unknown reply type from
  +            return new RequestFailedReply("TODO");
  +        }
  +    }
  +
  +    private AltrmiReply doMethodFacadeRequestArray(Object methodReply, MethodFacadeRequest mFacReq) {
  +        Object[] beanImpls = (Object[]) methodReply;
  +        Long[] refs = new Long[beanImpls.length];
  +        String[] objectNames = new String[beanImpls.length];
  +
  +        for (int i = 0; i < beanImpls.length; i++)
  +        {
  +            Object impl = beanImpls[i];
  +            MethodInvocationHandler mainMethodInvocationHandler = (MethodInvocationHandler)
  +                    mPublishedObjects.get(mFacReq.getPublishedServiceName() + "_Main");
  +
  +            objectNames[i] = encodeClassName(mainMethodInvocationHandler.getMostDerivedType(beanImpls[i]).getName());
  +
  +            MethodInvocationHandler methodInvocationHandler2 =
  +                (MethodInvocationHandler) mPublishedObjects
  +                    .get(mFacReq.getPublishedServiceName() + "_"
  +                         + objectNames[i]);
  +
   
  -            if (!mPublishedObjects.containsKey(publishedThing))
  +            if (methodInvocationHandler2 == null)
               {
                   return new NotPublishedReply();
               }
   
  -            if (!sessionExists(gcr.getSession()))
  +            if (!sessionExists(mFacReq.getSession()))
               {
                   return new ExceptionReply(
                       new AltrmiInvocationException("TODO - you dirty rat/hacker"));
               }
   
  -            AltrmiSession sess = (AltrmiSession) mSessions.get(gcr.getSession());
  -            if (sess == null) {
  -                System.out.println("DEBUG- GC on missing session -" + gcr.getSession());
  -            }
  -            if (gcr.getReferenceID() == null) {
  -                System.out.println("DEBUG- GC on missing referenceID -" + gcr.getReferenceID());
  +            //TODO a decent ref number for main?
  +            if (beanImpls[i] == null)
  +            {
  +                refs[i] = null;
               }
  -            sess.removeBeanInUse(gcr.getReferenceID());
  +            else
  +            {
  +                refs[i] =
  +                    methodInvocationHandler2.getOrMakeReferenceIDForBean(beanImpls[i]);
   
  -            MethodInvocationHandler methodInvocationHandler =
  -                (MethodInvocationHandler) mPublishedObjects.get(publishedThing);
  +                AltrmiSession sess = (AltrmiSession) mSessions.get(mFacReq.getSession());
   
  -            return new GarbageCollectionReply();
  +                sess.addBeanInUse(refs[i], beanImpls[i]);
  +            }
           }
  -        else if (request.getRequestCode() == AltrmiRequest.LOOKUPREQUEST)
  -        {
  -            LookupRequest lr = (LookupRequest) request;
   
  -            try
  -            {
  -                mAltrmiAuthenticator.checkAuthority(lr.getAltrmiAuthentication(),
  -                                                    lr.getPublishedServiceName());
  -            }
  -            catch (AltrmiAuthenticationException aae)
  -            {
  -                return new ExceptionReply(aae);
  -            }
  +        return new MethodFacadeArrayReply(refs, objectNames);
  +    }
   
  -            //TODO a decent ref number for main?
  -            return new LookupReply(new Long(0));
  -        }
  -        else if (request.getRequestCode() == AltrmiRequest.CLASSREQUEST)
  +    private AltrmiReply doMethodFacadeRequestNonArray(Object beanImpl, MethodFacadeRequest mFacReq) {
  +
  +        MethodInvocationHandler mainMethodInvocationHandler = (MethodInvocationHandler)
  +                mPublishedObjects.get(mFacReq.getPublishedServiceName() + "_Main");
  +
  +        String objectName = encodeClassName(mainMethodInvocationHandler.getMostDerivedType(beanImpl).getName());
  +
  +        MethodInvocationHandler methodInvocationHandler =
  +            (MethodInvocationHandler) mPublishedObjects
  +                .get(mFacReq.getPublishedServiceName() + "_" + objectName);
  +
  +        if (methodInvocationHandler == null)
           {
  -            ClassRequest cr = (ClassRequest) request;
  -            String publishedThing = cr.getPublishedServiceName() + "_" + cr.getObjectName();
  +            return new NotPublishedReply();
  +        }
   
  -            try
  -            {
  -                return new ClassReply(mClassRetriever.getBeanBytes(publishedThing),
  -                                      mClassRetriever
  -                                          .getInterfaceImplementationBytes(publishedThing));
  -            }
  -            catch (ClassRetrievalException e)
  -            {
  -                e.printStackTrace();
  -                return new ClassRetrievalFailedReply(e.getMessage());
  -            }
  +        if (!sessionExists(mFacReq.getSession()))
  +        {
  +            return new ExceptionReply(
  +                new AltrmiInvocationException("TODO - you dirty rat/hacker"));
           }
  -        else if (request.getRequestCode() == AltrmiRequest.OPENCONNECTIONREQUEST)
  +
  +        //TODO a decent ref number for main?
  +        Long newRef = methodInvocationHandler.getOrMakeReferenceIDForBean(beanImpl);
  +
  +        // make sure the bean is not garbage collected.
  +        AltrmiSession sess = (AltrmiSession) mSessions.get(mFacReq.getSession());
  +
  +        sess.addBeanInUse(newRef, beanImpl);
  +
  +        //long newRef2 = asih2.getOrMakeReferenceIDForBean(beanImpl);
  +        return new MethodFacadeReply(newRef, objectName);
  +    }
  +
  +    private AltrmiReply doMethodRequest(AltrmiRequest request) {
  +        MethodRequest mReq = (MethodRequest) request;
  +        String publishedThing = mReq.getPublishedServiceName() + "_" + mReq.getObjectName();
  +
  +        if (!mPublishedObjects.containsKey(publishedThing))
           {
  -            Long session = getNewSession();
  +            return new NotPublishedReply();
  +        }
  +
  +        MethodInvocationHandler methodInvocationHandler =
  +            (MethodInvocationHandler) mPublishedObjects.get(publishedThing);
   
  -            mSessions.put(session, new AltrmiSession(session));
  +        return methodInvocationHandler.handleMethodInvocation(mReq);
  +    }
   
  -            return new OpenConnectionReply(mAltrmiAuthenticator.getTextToSign(), session);
  +    private AltrmiReply doLookupRequest(AltrmiRequest request) {
  +        LookupRequest lr = (LookupRequest) request;
  +
  +        try
  +        {
  +            mAltrmiAuthenticator.checkAuthority(lr.getAltrmiAuthentication(),
  +                                                lr.getPublishedServiceName());
           }
  -        else if (request.getRequestCode() == AltrmiRequest.PINGREQUEST)
  +        catch (AltrmiAuthenticationException aae)
           {
  +            return new ExceptionReply(aae);
  +        }
   
  -            // we could communicate back useful state info in this transaction.
  -            return new PingReply();
  +        //TODO a decent ref number for main?
  +        return new LookupReply(new Long(0));
  +    }
  +
  +    private AltrmiReply doClassRequest(AltrmiRequest request) {
  +        ClassRequest cr = (ClassRequest) request;
  +        String publishedThing = cr.getPublishedServiceName() + "_" + cr.getObjectName();
  +
  +        try
  +        {
  +            return new ClassReply(mClassRetriever.getBeanBytes(publishedThing),
  +                                  mClassRetriever
  +                                      .getInterfaceImplementationBytes(publishedThing));
           }
  -        else if (request.getRequestCode() == AltrmiRequest.LISTREQUEST)
  +        catch (ClassRetrievalException e)
           {
  +            e.printStackTrace();
  +            return new ClassRetrievalFailedReply(e.getMessage());
  +        }
  +    }
   
  -            //return the list of published objects to the server
  -            Iterator iterator = mPublishedObjects.keySet().iterator();
  -            Vector vecOfPublishedObjectNames = new Vector();
  +    private AltrmiReply doOpenConnectionRequest() {
  +        Long session = getNewSession();
   
  -            while (iterator.hasNext())
  -            {
  -                final String item = (String) iterator.next();
  +        mSessions.put(session, new AltrmiSession(session));
  +
  +        return new OpenConnectionReply(mAltrmiAuthenticator.getTextToSign(), session);
  +    }
  +
  +    private AltrmiReply doListRequest() {
  +        //return the list of published objects to the server
  +        Iterator iterator = mPublishedObjects.keySet().iterator();
  +        Vector vecOfPublishedObjectNames = new Vector();
   
  -                if (item.endsWith("_Main"))
  -                {
  -                    vecOfPublishedObjectNames.add(item.substring(0, item.lastIndexOf("_Main")));
  -                }
  +        while (iterator.hasNext())
  +        {
  +            final String item = (String) iterator.next();
  +
  +            if (item.endsWith("_Main"))
  +            {
  +                vecOfPublishedObjectNames.add(item.substring(0, item.lastIndexOf("_Main")));
               }
  +        }
  +
  +        String[] _listOfPublishedObjectNames = new String[vecOfPublishedObjectNames.size()];
   
  -            String[] _listOfPublishedObjectNames = new String[vecOfPublishedObjectNames.size()];
  +        System.arraycopy(vecOfPublishedObjectNames.toArray(), 0, _listOfPublishedObjectNames,
  +                         0, vecOfPublishedObjectNames.size());
  +
  +        return new ListReply(_listOfPublishedObjectNames);
  +    }
   
  -            System.arraycopy(vecOfPublishedObjectNames.toArray(), 0, _listOfPublishedObjectNames,
  -                             0, vecOfPublishedObjectNames.size());
  +    private AltrmiReply doGarbageCollectionRequest(AltrmiRequest request) {
  +        GarbageCollectionRequest gcr = (GarbageCollectionRequest) request;
  +        String publishedThing = gcr.getPublishedServiceName() + "_" + gcr.getObjectName();
   
  -            return new ListReply(_listOfPublishedObjectNames);
  +        if (!mPublishedObjects.containsKey(publishedThing))
  +        {
  +            return new NotPublishedReply();
           }
  -        else
  +
  +        if (!sessionExists(gcr.getSession()))
           {
  -            return new RequestFailedReply("Unknown request :" + request.getClass().getName());
  +            return new ExceptionReply(
  +                new AltrmiInvocationException("TODO - you dirty rat/hacker"));
           }
  +
  +        AltrmiSession sess = (AltrmiSession) mSessions.get(gcr.getSession());
  +        if (sess == null) {
  +            System.out.println("DEBUG- GC on missing session -" + gcr.getSession());
  +        }
  +        if (gcr.getReferenceID() == null) {
  +            System.out.println("DEBUG- GC on missing referenceID -" + gcr.getReferenceID());
  +        }
  +        sess.removeBeanInUse(gcr.getReferenceID());
  +
  +        MethodInvocationHandler methodInvocationHandler =
  +            (MethodInvocationHandler) mPublishedObjects.get(publishedThing);
  +
  +        return new GarbageCollectionReply();
       }
   
       private boolean sessionExists(Long session)
  
  
  
  1.2       +3 -3      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters/PublicationAdapter.java
  
  Index: PublicationAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters/PublicationAdapter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PublicationAdapter.java	3 Apr 2002 11:29:55 -0000	1.1
  +++ PublicationAdapter.java	21 Apr 2002 09:42:02 -0000	1.2
  @@ -28,7 +28,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class PublicationAdapter extends AbstractMethodHandler implements AltrmiPublisher
   {
  @@ -82,7 +82,7 @@
           // add method maps for main lookup-able service.
           HashMap mainMethodMap = new HashMap();
           MethodInvocationHandler mainMethodInvocationHandler =
  -            new DefaultMethodInvocationHandler(this, asName + "_Main", mainMethodMap);
  +            new DefaultMethodInvocationHandler(this, asName + "_Main", mainMethodMap, publicationDescription);
   
           mainMethodInvocationHandler.addImplementationBean(new Long(0), impl);
   
  @@ -113,7 +113,7 @@
               HashMap methodMap = new HashMap();
               MethodInvocationHandler methodInvocationHandler =
                   new DefaultMethodInvocationHandler(this, asName + "_" + encodedClassName,
  -                                                   methodMap);
  +                                                   methodMap, publicationDescription);
   
               for (int y = 0; y < methods.length; y++)
               {
  
  
  
  1.2       +6 -3      jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/AbstractServerTest.java
  
  Index: AbstractServerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/AbstractServerTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractServerTest.java	20 Apr 2002 17:40:38 -0000	1.1
  +++ AbstractServerTest.java	21 Apr 2002 09:42:02 -0000	1.2
  @@ -23,12 +23,13 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public abstract class AbstractServerTest
   {
   
  -    protected abstract AbstractServer makeAbstractServer(String[] args) throws AltrmiServerException, MalformedURLException;
  +    protected abstract AbstractServer makeAbstractServer(String[] args)
  +        throws AltrmiServerException, MalformedURLException;
   
       /**
        * Method launch
  @@ -37,13 +38,15 @@
        * @param args
        *
        */
  -    public void launch(String[] args) throws PublicationException, AltrmiServerException, MalformedURLException
  +    public void launch(String[] args)
  +            throws PublicationException, AltrmiServerException, MalformedURLException
       {
   
           AbstractServer as = makeAbstractServer(args);
           TestInterfaceImpl ti = new TestInterfaceImpl();
           PublicationDescription pd = new PublicationDescription(TestInterface.class,
  -                                                               TestInterface2.class);
  +                                                               new Class[]{ TestInterface3.class,
  +                                                                            TestInterface2.class });
   
           as.publish(ti, "Hello", pd);
           as.start();
  
  
  
  1.2       +9 -7      jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/PipeTest.java
  
  Index: PipeTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/PipeTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PipeTest.java	3 Apr 2002 11:29:57 -0000	1.1
  +++ PipeTest.java	21 Apr 2002 09:42:02 -0000	1.2
  @@ -36,7 +36,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class PipeTest
   {
  @@ -63,6 +63,12 @@
           TestInterfaceImpl ti = new TestInterfaceImpl();
           ClassRetriever cr = new NoClassRetriever();
   
  +        PublicationDescription pd = new PublicationDescription(TestInterface.class,
  +                                                               new Class[]{
  +                                                                   TestInterface3.class,
  +                                                                   TestInterface2.class });
  +
  +
           if (mServerOrClientFactory.equals("S"))
           {
               cr = new JarFileClassRetriever("build" + File.separator + "classes2");
  @@ -83,17 +89,13 @@
               dr.setSrcGenDir(source.getAbsolutePath());
               dr.setClassGenDir(gen.getAbsolutePath());
   
  -            PublicationDescription pd = new PublicationDescription(TestInterface.class,
  -                                                                   TestInterface2.class);
  -
               dr.generate("Hello", pd, null);
   
               cr = dr;
           }
   
           ps.setClassRetriever(cr);
  -        ps.publish(ti, "Hello",
  -                   new PublicationDescription(TestInterface.class, TestInterface2.class));
  +        ps.publish(ti, "Hello",pd);
           ps.start();
   
           PipedTestClient ptc = new PipedTestClient(ps);
  @@ -107,7 +109,7 @@
        *
        *
        * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  -     * @version $Revision: 1.1 $
  +     * @version $Revision: 1.2 $
        */
       static class PipedTestClient implements Runnable
       {
  
  
  
  1.4       +13 -2     jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/TestClient.java
  
  Index: TestClient.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/TestClient.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestClient.java	10 Apr 2002 22:28:28 -0000	1.3
  +++ TestClient.java	21 Apr 2002 09:42:02 -0000	1.4
  @@ -24,7 +24,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class TestClient
   {
  @@ -68,6 +68,13 @@
           TestInterface2 ti2One = ti.makeTestInterface2("One");
           TestInterface2 ti2Two = ti.makeTestInterface2("Two");
   
  +        if (ti2One instanceof TestInterface3) {
  +            System.out.println("CLT: ti2One could be cast to TestInterface3");
  +        }
  +        if (ti2Two instanceof TestInterface3) {
  +            System.out.println("CLT: ti2Two could be cast to TestInterface3");
  +        }
  +
           System.out.println("CLT: One name = '" + ti2One.getName() + "'");
           System.out.println("CLT: Two name = '" + ti2Two.getName() + "'");
           System.out.println("CLT: Changing name for One to '111'");
  @@ -96,7 +103,11 @@
           {
               TestInterface2 ti2 = ti2s[i];
   
  -            System.out.println("CLT: .. name[" + i + "] = '" + ti2s[i].getName() + "'");
  +            System.out.print("CLT: .. ti2[" + i + "] = '" + ti2s[i].getName() + "'");
  +            if (ti2 instanceof TestInterface3) {
  +                System.out.print(" (could be cast to TestInterface3, d.o.b = "+((TestInterface3) ti2).getDOB()+" ) ");
  +            }
  +            System.out.println("");
           }
   
           System.out.println(
  
  
  
  1.2       +1 -1      jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/TestInterface2.java
  
  Index: TestInterface2.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/TestInterface2.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestInterface2.java	3 Apr 2002 11:29:57 -0000	1.1
  +++ TestInterface2.java	21 Apr 2002 09:42:02 -0000	1.2
  @@ -16,11 +16,11 @@
   
   
   /**
  - * Interface TestInterface
  + * Interface TestInterface2
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version * $Revision: 1.1 $
  + * @version * $Revision: 1.2 $
    */
   public interface TestInterface2
   {
  
  
  
  1.2       +13 -2     jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/TestInterfaceImpl.java
  
  Index: TestInterfaceImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/TestInterfaceImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestInterfaceImpl.java	3 Apr 2002 11:29:57 -0000	1.1
  +++ TestInterfaceImpl.java	21 Apr 2002 09:42:02 -0000	1.2
  @@ -15,6 +15,7 @@
   import java.io.IOException;
   
   import java.util.Vector;
  +import java.util.Date;
   
   
   /**
  @@ -22,13 +23,14 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class TestInterfaceImpl implements TestInterface
   {
   
       Vector ti2Holder = new Vector();
       TestObject[] mTestObjects;
  +    private int testInterface2Counter = 0;
   
       /**
        * Method hello
  @@ -141,7 +143,16 @@
       public TestInterface2 makeTestInterface2(String thingName)
       {
   
  -        TestInterface2 ti2 = new TestInterface2Impl(thingName);
  +        TestInterface2 ti2;
  +        if ((testInterface2Counter %2) * 2 == testInterface2Counter++)
  +        {
  +            // even calls only
  +            ti2 = new TestInterface3Impl(new Date(), thingName);
  +        }
  +        else
  +        {
  +            ti2 = new TestInterface2Impl(thingName);
  +        }
   
           ti2Holder.add(ti2);
   
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/TestInterface3.java
  
  Index: TestInterface3.java
  ===================================================================
  
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.excalibur.altrmi.test;
  
  
  
  import java.beans.PropertyVetoException;
  
  import java.io.IOException;
  import java.util.Date;
  
  
  /**
   * Interface TestInterface3
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version * $Revision: 1.1 $
   */
  public interface TestInterface3 extends TestInterface2
  {
  
      /**
       * Method setDOB
       *
       *
       * @param dob
       *
       */
      void setDOB(Date dob);
  
      /**
       * Method getDOB
       *
       *
       *
       * @return
       *
       */
      Date getDOB();
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/TestInterface3Impl.java
  
  Index: TestInterface3Impl.java
  ===================================================================
  
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.excalibur.altrmi.test;
  
  import java.util.Date;
  
  
  /**
   * Class TestInterface3Impl
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version * $Revision: 1.1 $
   */
  public class TestInterface3Impl extends TestInterface2Impl implements TestInterface3
  {
  
      private Date mDob;
  
      /**
       * Constructor TestInterface3Impl
       *
       *
       * @param name
       *
       */
      public TestInterface3Impl(Date dob, String name)
      {
          super(name);
  
          System.out.println("SVR: ... and created with dob: '" + dob + "'");
  
          mDob = dob;
      }
  
      /**
       * Method setDOB
       *
       *
       * @param dob
       *
       */
      public void setDOB(Date dob)
      {
  
          mDob = dob;
  
          System.out.println("SVR: Object " + this + " dob changed to: '" + dob + "'");
      }
  
      /**
       * Method getDob
       *
       *
       *
       * @return
       *
       */
      public Date getDOB()
      {
          return mDob;
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>