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 2003/01/06 00:11:41 UTC

cvs commit: jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/remotable RemotableDescriptorTestCase.java

hammant     2003/01/05 15:11:41

  Modified:    altrmi/src/test/org/apache/excalibur/altrmi/client/impl
                        DummyInvocationHandler.java
               altrmi/src/test/org/apache/excalibur/altrmi/test
                        ProConClientTest.java
               altrmi/src/test/org/apache/excalibur/altrmi/test/callback
                        CallBackTestClient.java CallBackTestImpl.java
               altrmi/src/test/org/apache/excalibur/altrmi/test/dynamic
                        DynamicInvokerTestCase.java
               altrmi/src/test/org/apache/excalibur/altrmi/test/generator
                        TestInvocationHandler.java
               altrmi/src/test/org/apache/excalibur/altrmi/test/invalidstate
                        BouncingServerTestCase.java
  Added:       altrmi/lib excalibur-container-1.0.jar
               altrmi/src/java/org/apache/excalibur/altrmi/client
                        ClientInvocationHandler.java
                        ConnectionClosedException.java
                        ConnectionListener.java ConnectionPinger.java
                        HostContext.java InterfaceLookup.java
                        InterfaceLookupFactory.java LookupSource.java
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl/subscriber
                        DefaultLookupSource.java
               altrmi/src/java/org/apache/excalibur/altrmi/remotable
                        Remotable.java RemotableDescriptor.java
                        RemotableExtensionManager.java
                        RemotableExtensionManager.xconfig
                        RemotableExtensionManager.xinfo
               altrmi/src/test/org/apache/excalibur/altrmi/test/remotable
                        RemotableDescriptorTestCase.java
  Removed:     altrmi/src/java/org/apache/excalibur/altrmi/client
                        AltrmiClientInvocationHandler.java
                        AltrmiConnectionClosedException.java
                        AltrmiConnectionListener.java
                        AltrmiConnectionPinger.java AltrmiHostContext.java
                        AltrmiInterfaceLookup.java
                        AltrmiInterfaceLookupFactory.java
                        AltrmiLookupSource.java
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl/subscriber
                        DefaultAltrmiLookupSource.java
  Log:
  Start of renames on class names.  'Altrmi' as a prefix to everything is needless as has been pointed out many times.  Vinay's remotable added too (alpha).
  
  Revision  Changes    Path
  1.5       +6 -6      jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/client/impl/DummyInvocationHandler.java
  
  Index: DummyInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/client/impl/DummyInvocationHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DummyInvocationHandler.java	5 Jan 2003 22:05:03 -0000	1.4
  +++ DummyInvocationHandler.java	5 Jan 2003 23:11:40 -0000	1.5
  @@ -10,12 +10,12 @@
   import org.apache.excalibur.altrmi.common.AltrmiReply;
   import org.apache.excalibur.altrmi.common.AltrmiRequest;
   import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
  -import org.apache.excalibur.altrmi.client.AltrmiClientInvocationHandler;
  -import org.apache.excalibur.altrmi.client.AltrmiConnectionListener;
  -import org.apache.excalibur.altrmi.client.AltrmiConnectionPinger;
  +import org.apache.excalibur.altrmi.client.ClientInvocationHandler;
  +import org.apache.excalibur.altrmi.client.ConnectionListener;
  +import org.apache.excalibur.altrmi.client.ConnectionPinger;
   
   
  -public class DummyInvocationHandler implements AltrmiClientInvocationHandler
  +public class DummyInvocationHandler implements ClientInvocationHandler
   {
   
       boolean pinged = false;
  @@ -52,12 +52,12 @@
           throw new java.lang.UnsupportedOperationException();
       }
   
  -    public void setAltrmiConnectionListener(AltrmiConnectionListener altrmiConnectionListener)
  +    public void setAltrmiConnectionListener(ConnectionListener altrmiConnectionListener)
       {
           throw new java.lang.UnsupportedOperationException();
       }
   
  -    public void setConnectionPinger(AltrmiConnectionPinger connectionPinger)
  +    public void setConnectionPinger(ConnectionPinger connectionPinger)
       {
           throw new java.lang.UnsupportedOperationException();
       }
  
  
  
  1.3       +2 -2      jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/ProConClientTest.java
  
  Index: ProConClientTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/ProConClientTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProConClientTest.java	24 Apr 2002 12:43:02 -0000	1.2
  +++ ProConClientTest.java	5 Jan 2003 23:11:40 -0000	1.3
  @@ -8,7 +8,7 @@
   package org.apache.excalibur.altrmi.test;
   
   import org.apache.excalibur.altrmi.client.AltrmiFactory;
  -import org.apache.excalibur.altrmi.client.AltrmiHostContext;
  +import org.apache.excalibur.altrmi.client.HostContext;
   import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
   import org.apache.excalibur.altrmi.client.impl.ServerClassAltrmiFactory;
   import org.apache.excalibur.altrmi.client.impl.socket.SocketCustomStreamHostContext;
  @@ -37,7 +37,7 @@
   
           System.out.println( "Stream over Socket Client" );
   
  -        AltrmiHostContext arhc;
  +        HostContext arhc;
   
           if( args[ 1 ].equals( "ObjectStream" ) )
           {
  
  
  
  1.7       +2 -2      jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/callback/CallBackTestClient.java
  
  Index: CallBackTestClient.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/callback/CallBackTestClient.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CallBackTestClient.java	24 Apr 2002 12:43:03 -0000	1.6
  +++ CallBackTestClient.java	5 Jan 2003 23:11:40 -0000	1.7
  @@ -8,7 +8,7 @@
   package org.apache.excalibur.altrmi.test.callback;
   
   import org.apache.excalibur.altrmi.client.AltrmiFactory;
  -import org.apache.excalibur.altrmi.client.AltrmiHostContext;
  +import org.apache.excalibur.altrmi.client.HostContext;
   import org.apache.excalibur.altrmi.client.impl.ServerClassAltrmiFactory;
   import org.apache.excalibur.altrmi.client.impl.callback.socket.CallbackEnabledSocketCustomStreamHostContext;
   
  @@ -34,7 +34,7 @@
   
           System.out.println( "Callback test Client" );
   
  -        AltrmiHostContext arhc;
  +        HostContext arhc;
   
           arhc = new CallbackEnabledSocketCustomStreamHostContext( "127.0.0.1", 1235 );
   
  
  
  
  1.5       +2 -2      jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/callback/CallBackTestImpl.java
  
  Index: CallBackTestImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/callback/CallBackTestImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CallBackTestImpl.java	5 Jan 2003 22:05:03 -0000	1.4
  +++ CallBackTestImpl.java	5 Jan 2003 23:11:40 -0000	1.5
  @@ -9,7 +9,7 @@
   
   import java.util.ArrayList;
   import java.util.List;
  -import org.apache.excalibur.altrmi.client.AltrmiConnectionClosedException;
  +import org.apache.excalibur.altrmi.client.ConnectionClosedException;
   
   /**
    * Class CallBackTestImpl
  @@ -60,7 +60,7 @@
                           // ( (CallBackTestListener)m_list.get( i ) ).serverCallingClient2( callBackTest );
   
                       }
  -                    catch( AltrmiConnectionClosedException ace ) //SHLD this be some other exception
  +                    catch( ConnectionClosedException ace ) //SHLD this be some other exception
                       {
                           System.out.println( "Invalid Callback" );
                           m_list.remove( i );
  
  
  
  1.3       +2 -2      jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/dynamic/DynamicInvokerTestCase.java
  
  Index: DynamicInvokerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/dynamic/DynamicInvokerTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DynamicInvokerTestCase.java	5 Nov 2002 07:19:46 -0000	1.2
  +++ DynamicInvokerTestCase.java	5 Jan 2003 23:11:40 -0000	1.3
  @@ -58,7 +58,7 @@
   
   import junit.framework.TestCase;
   
  -import org.apache.excalibur.altrmi.client.AltrmiHostContext;
  +import org.apache.excalibur.altrmi.client.HostContext;
   import org.apache.excalibur.altrmi.client.impl.DynamicInvoker;
   import org
       .apache
  @@ -95,7 +95,7 @@
       protected AbstractServer server;
       protected TestInterfaceImpl testServer;
       protected TestInterface testClient;
  -    protected AltrmiHostContext altrmiHostContext;
  +    protected HostContext altrmiHostContext;
       protected DynamicInvoker dynamicInvoker;
       //-------Constructor----------//
       /**
  
  
  
  1.6       +1 -1      jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/generator/TestInvocationHandler.java
  
  Index: TestInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/generator/TestInvocationHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestInvocationHandler.java	4 Sep 2002 11:01:23 -0000	1.5
  +++ TestInvocationHandler.java	5 Jan 2003 23:11:40 -0000	1.6
  @@ -83,7 +83,7 @@
           return true;
       }
       /*
  -     * @see AltrmiClientInvocationHandler#getLastRealRequest()
  +     * @see ClientInvocationHandler#getLastRealRequest()
        */
       public long getLastRealRequest()
       {
  
  
  
  1.2       +4 -4      jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/invalidstate/BouncingServerTestCase.java
  
  Index: BouncingServerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/invalidstate/BouncingServerTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BouncingServerTestCase.java	5 Jan 2003 22:38:26 -0000	1.1
  +++ BouncingServerTestCase.java	5 Jan 2003 23:11:40 -0000	1.2
  @@ -20,8 +20,8 @@
   import org.apache.excalibur.altrmi.client.impl.NeverConnectionPinger;
   import org.apache.excalibur.altrmi.client.impl.DumbConnectionListener;
   import org.apache.excalibur.altrmi.client.impl.socket.SocketCustomStreamHostContext;
  -import org.apache.excalibur.altrmi.client.AltrmiHostContext;
  -import org.apache.excalibur.altrmi.client.AltrmiClientInvocationHandler;
  +import org.apache.excalibur.altrmi.client.HostContext;
  +import org.apache.excalibur.altrmi.client.ClientInvocationHandler;
   import org.apache.excalibur.altrmi.common.NoSuchSessionException;
   
   
  @@ -49,10 +49,10 @@
   
               // Client side setup
               altrmiFactory = new ClientClassAltrmiFactory(false);
  -            AltrmiHostContext hc = new SocketCustomStreamHostContext("127.0.0.1", 12101);
  +            HostContext hc = new SocketCustomStreamHostContext("127.0.0.1", 12101);
   
               altrmiFactory.setHostContext(hc, false);
  -            AltrmiClientInvocationHandler ih = hc.getClientInvocationHandler();
  +            ClientInvocationHandler ih = hc.getClientInvocationHandler();
               ih.setConnectionPinger(new NeverConnectionPinger());
               ih.setAltrmiConnectionListener(new DumbConnectionListener());
               TestInterface testClient = (TestInterface) altrmiFactory.lookup("Hello");
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/lib/excalibur-container-1.0.jar
  
  	<<Binary file>>
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/ClientInvocationHandler.java
  
  Index: ClientInvocationHandler.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.client;
  
  import java.io.IOException;
  import org.apache.excalibur.altrmi.common.AltrmiInvocationHandler;
  import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
  
  /**
   * Interface ClientInvocationHandler
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version * $Revision: 1.1 $
   */
  public interface ClientInvocationHandler extends AltrmiInvocationHandler
  {
  
      /**
       * Method setAltrmiConnectionListener
       *
       *
       * @param altrmiConnectionListener
       *
       */
      void setAltrmiConnectionListener( ConnectionListener altrmiConnectionListener );
  
      /**
       * Method setConnectionPinger
       *
       *
       * @param connectionPinger
       *
       */
      void setConnectionPinger( ConnectionPinger connectionPinger );
  
      /**
       * Method initialize
       *
       *
       * @throws AltrmiConnectionException
         *
       */
      void initialize() throws AltrmiConnectionException;
  
      /**
       * Method close
       *
       *
       */
      void close();
  
      /**
       * Method getLastRealRequest
       *
       *
       * @return
       *
       */
      long getLastRealRequest();
  
      /**
       * Method ping
       *
       *
       */
      void ping();
  
      /**
       * Method getInterfacesClassLoader
       *
       *
       * @return
       *
       */
      ClassLoader getInterfacesClassLoader();
      
      /**
       * morphObject handles any changes  to the arguments being
       * marshalled to the server.
       * @param inputArgumentClass Class of the input argument
       * @param inputArgumentInstance instance of the object being marshalled to the server
       * @return Object new object that replaces the input argument.
       */
  
      public Object resolveArgument(String methodSignature,Class inputArgumentClass, Object inputArgumentInstance);
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/ConnectionClosedException.java
  
  Index: ConnectionClosedException.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.client;
  
  /**
   * Class ConnectionClosedException
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class ConnectionClosedException extends RuntimeException
  {
  
      /**
       * Constructor ConnectionClosedException
       *
       *
       * @param msg the message that is the root cause.
       *
       */
      public ConnectionClosedException( String msg )
      {
          super( msg );
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/ConnectionListener.java
  
  Index: ConnectionListener.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.client;
  
  import org.apache.excalibur.altrmi.common.AltrmiRequest;
  
  import java.io.IOException;
  
  /**
   * Interface ConnectionListener
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version * $Revision: 1.1 $
   */
  public interface ConnectionListener
  {
  
      /**
       * Method methodCalled
       *
       *
       *
       * @param methodSignature
       * @param duration
       *
       */
      void methodCalled( String methodSignature, long duration );
  
      /**
       * Method methodLogging tests if the implementing class intends to do method logging.
       *
       *
       * @return
       *
       */
      boolean methodLogging();
  
      /**
       * Method serviceSuspended
       *
       *
       *
       * @param altrmiRequest
       * @param attempt
       * @param suggestedWaitMillis
       *
       */
      void serviceSuspended( AltrmiRequest altrmiRequest, int attempt, int suggestedWaitMillis );
  
      /**
       * Method serviceAbend
       *
       *
       *
       * @param attempt
       *
       */
      void serviceAbend( int attempt, IOException cause );
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/ConnectionPinger.java
  
  Index: ConnectionPinger.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.client;
  
  /**
   * Interface ConnectionPinger
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version * $Revision: 1.1 $
   */
  public interface ConnectionPinger
  {
  
      /**
       * Method setAltrmiInvocationHandler
       *
       *
       *
       */
      void setAltrmiInvocationHandler( ClientInvocationHandler altrmiInvocationHandler );
  
      /**
       * Method start
       *
       *
       */
      void start();
  
      /**
       * Method stop
       *
       *
       */
      void stop();
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/HostContext.java
  
  Index: HostContext.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.client;
  
  /**
   * HostContext, as the name suggests, describes the
   * context of the calls made to the server which could be 
   * Over Piped Streams or Over Custom Transport or Direct calls etc ..
   * 
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version * $Revision: 1.1 $
   */
  public interface HostContext
  {
  
      /**
       * Return the Invocation Handler that can talk over
       * the transport this particular context addresses.
       * @return InvocationHandler
       *
       */
      ClientInvocationHandler getClientInvocationHandler();
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/InterfaceLookup.java
  
  Index: InterfaceLookup.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.client;
  
  import org.apache.excalibur.altrmi.common.AltrmiAuthentication;
  import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
  
  /**
   * InterfaceLookup describes the initial client's interaction with
   * with the server (lookup/listing of remote services.)
   * 
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public interface InterfaceLookup
  {
  
      /**
       * Lookup a name by which the remote service is 
       * published by the server.
       * Usage:
       * <code>
       *  InterfaceLookup lookupService= . . . . ;
       *  RemoteInterface remoteInterface = lookupService.lookup("Published-Name-Of-The-Remote-Server");
       * </code>
       * @param publishedServiceName
       * @return proxy to the Remote service.
       * @throws AltrmiConnectionException
       */
      Object lookup(String publishedServiceName)
          throws AltrmiConnectionException;
  
      /**
       * Lookup a name by which the remote service is 
       * published by the server within the context of 
       * the Authentication credentials supplied.
       *
       * @param publishedServiceName
       * @param altrmiAuthentication
       * @return
       * @throws AltrmiConnectionException
       *
       */
      Object lookup(
          String publishedServiceName,
          AltrmiAuthentication altrmiAuthentication)
          throws AltrmiConnectionException;
  
      /**
       * This method returns the list of names of the
       * remote services.
       * @return
       */
      String[] list();
  
      /**
       * Method getTextToSignForAuthentication
       *
       *
       * @return
       *
       */
      String getTextToSignForAuthentication();
  
      /**
       * Method close
       *
       *
       */
      void close();
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/InterfaceLookupFactory.java
  
  Index: InterfaceLookupFactory.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.client;
  
  import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
  
  /**
   * Interface InterfaceLookupFactory
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version * $Revision: 1.1 $
   */
  public interface InterfaceLookupFactory
  {
  
      /**
       * Method getAltrmiInterfaceLookup
       *
       * FactoryStrings as listed here should look like this:
       *
       *   "SocketObjectStream:abcde.com:1234:S:BO"
       *   "SocketCustomStream:abcde.com:1235:C:NBO"
       *   "RMI:abcde.com:1236:S:NBO"
       *
       *   S:BO and alike is
       *    - "S" for server side proxy classes
       *    - "C" for client side proxy classes
       *    - "BO" is BeanOnly (not castable to the interface)
       *    - "NBO" is NotBeanOnly (castable to the interface)
       *
       * @param factoryString
       * @param optimize
       *
       * @return
       *
       */
      InterfaceLookup getAltrmiInterfaceLookup( String factoryString, boolean optimize )
          throws AltrmiConnectionException;
  
      /**
       * Method getAltrmiInterfaceLookup
       *
       *
       * @param factoryString
       * @param interfacesClassLoader
       * @param optimize
       *
       * @return
       *
       * @throws AltrmiConnectionException
       *
       */
      InterfaceLookup getAltrmiInterfaceLookup(
          String factoryString, ClassLoader interfacesClassLoader, boolean optimize
          ) throws AltrmiConnectionException;
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/LookupSource.java
  
  Index: LookupSource.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.client;
  
  import org.apache.avalon.framework.component.Component;
  
  /**
   * The <code>LookupSource</code> is a component that will return an
   * <code>InterfaceLookup</code>.
   *
   * @see DefaultLookupSource
   * @author <a href="proyal@apache.org">Peter Royal</a>
   * @version $Revision: 1.1 $
   */
  public interface LookupSource extends Component
  {
      String ROLE = LookupSource.class.getName();
  
      /**
       * Get an <code>InterfaceLookup</code>.
       *
       * @return an <code>InterfaceLookup</code>
       */
      InterfaceLookup get();
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/subscriber/DefaultLookupSource.java
  
  Index: DefaultLookupSource.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.client.impl.subscriber;
  
  import org.apache.avalon.excalibur.pool.DefaultPoolController;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.thread.ThreadSafe;
  import org.apache.excalibur.altrmi.client.InterfaceLookup;
  import org.apache.excalibur.altrmi.client.LookupSource;
  
  /**
   * The Default implementation of an <code>LookupSource</code>.
   *
   * <p>
   * Configuration Example:
   * <pre>
   *  &lt;altrmi-subscriber&gt;
   *     &lt;pool-controller min="3" max="50"/&gt;
   *      &lt;factory class="org.apache.excalibur.altrmi.client.impl.subscriber.SocketObjectStreamInterfaceLookupFactory"&gt;
   *          &lt;proxyClassLocation&gt;client&lt;/proxyClassLocation&gt;
   *          &lt;host&gt;localhost&lt;/host&gt;
   *          &lt;port&gt;1234&lt;/port&gt;
   *      &lt;/factory&gt;
   *  &lt;/altrmi-subscriber&gt;
   * </pre>
   * <p>
   * Configuration Attributes:
   * <ul>
   * <li>The <code>min</code> attribute is used to set the minimum size of the InterfaceLookup
   *   pool. When first initialized, this number of connections will be automatically created and be
   *   ready for use. (Defaults to "1")</li>
   *
   * <li>The <code>max</code> attribute is used to set the maximum number of connections which
   *  will be opened. (Defaults to "3")</li>
   *
   * <li>The <code>factory</code> element is used to set the factory used to create
   *   <code>InterfaceLookup</code> instances. The <code>class</code> attribute contains
   *   the name of the class to use. This configuration block is also passed to the factory
   *   to configure it.
   * </li>
   * </ul>
   *
   * @author <a href="mailto:proyal@apache.org">Peter Royal</a>
   * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
   * @version CVS $Revision: 1.1 $ $Date: 2003/01/05 23:11:41 $
   */
  public class DefaultLookupSource extends AbstractLogEnabled
      implements LookupSource, Disposable, Configurable, ThreadSafe
  {
      protected AltrmiLookupPool m_pool;
  
      /**
       *  Configure and set up DB connection.  Here we set the connection
       *  information needed to create the Connection objects.  It must
       *  be called only once.
       *
       * @param conf The Configuration object needed to describe the
       *             connection.
       *
       * @throws ConfigurationException
       */
      public void configure( final Configuration configuration ) throws ConfigurationException
      {
          if( null == m_pool )
          {
              final Configuration controller = configuration.getChild( "pool-controller" );
              final int min = controller.getAttributeAsInteger( "min", 1 );
              final int max = controller.getAttributeAsInteger( "max", 3 );
              final Configuration fconfig = configuration.getChild( "factory" );
  
              final int l_max;
              final int l_min;
  
              // Validate the min and max pool size values.
              if( min < 1 )
              {
                  if( getLogger().isWarnEnabled() )
                  {
                      getLogger().warn( "Min number of connections specified must be at least 1." );
                  }
  
                  l_min = 1;
              }
              else
              {
                  l_min = min;
              }
  
              if( max < 1 )
              {
                  if( getLogger().isWarnEnabled() )
                  {
                      getLogger().warn( "Max number of connections specified must be at least 1." );
                  }
  
                  l_max = 1;
              }
              else
              {
                  if( max < min )
                  {
                      if( getLogger().isWarnEnabled() )
                      {
                          getLogger().warn( "Maximum number of connections specified must be " +
                                            "more than the minimum number of connections." );
                      }
  
                      l_max = min + 1;
                  }
                  else
                  {
                      l_max = max;
                  }
              }
  
              try
              {
                  final DefaultPoolController poolController = new DefaultPoolController( l_max / 4 );
                  final AbstractAltrmiInterfaceLookupFactory factory = createFactory( fconfig );
  
                  m_pool = new AltrmiLookupPool( factory, poolController, l_min, l_max );
                  m_pool.enableLogging( getLogger() );
                  m_pool.initialize();
              }
              catch( Exception e )
              {
                  throw new ConfigurationException( "Error configuring LookupSource", e );
              }
          }
      }
  
      private AbstractAltrmiInterfaceLookupFactory createFactory( final Configuration fconfig )
          throws Exception
      {
          final ClassLoader loader = Thread.currentThread().getContextClassLoader();
          final String className = fconfig.getAttribute( "class" );
          final AbstractAltrmiInterfaceLookupFactory factory =
              ( AbstractAltrmiInterfaceLookupFactory ) loader.loadClass(className).newInstance();
  
          setupLogger( factory );
  
          factory.configure( fconfig );
  
          return factory;
      }
  
      /** Get the database connection */
      public InterfaceLookup get()
      {
          try
          {
              return ( InterfaceLookup ) m_pool.get();
          }
          catch( final Exception e )
          {
              throw new ConnectionException( e.getMessage(), e );
          }
      }
  
      /** Dispose properly of the pool */
      public void dispose()
      {
          m_pool.dispose();
          m_pool = null;
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/remotable/Remotable.java
  
  Index: Remotable.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Avalon", 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 apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 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.excalibur.altrmi.remotable;
  
  /**
   *  Remotable Lifecycle Extension enables a object to
   * expose itself remotely to its potential client using
   * AltRMI.
   * <br/>
   * Example:
   * <br/>
   * <code>
   * <pre>
   *   public class XYZComponent extends AbstractLogEnabled
   *              implements ...,Remotable
   *
   *   {
   *       . . . .
   *       . . . .
   *       . . . .
   *    public RemotableDescriptor getExposedObjects()
   *    {
   *       // Here we expose a object(someObjThatWishesToExposed)
   *       return new RemotableDescriptor().add("publishName",
   *                                            someObjThatWillBeExposed,
   *                                            new Class[]{RemoteInterfaceThatClientSees.class,AnotherRemoteInterface.class});
   *    }
   *    . . . .
   *    . . . .
   *   }
   *
   * </pre>
   * </code>
   *
   * @author <a href="mailto:vinayc@apache.org">Vinay Chandran</a>
   */
  public interface Remotable
  {
      /**
       * Get the list of objects to be exposed from this
       * component
       * @return RemotableDescriptor This descriptor stores the list
       *  of objects that are exposed to the clients.
       *
       */
      RemotableDescriptor getExposedObjects();
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/remotable/RemotableDescriptor.java
  
  Index: RemotableDescriptor.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Avalon", 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 apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 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.excalibur.altrmi.remotable;
  
  import org.apache.excalibur.altrmi.server.PublicationDescriptionItem;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  
  /**
   *
   *  <code>RemotableDescriptor</code> details the remotable objects that the
   * component wishes to expose over Altrmi.
   * Usage :
   * <code><pre>
   * RemotableDescriptor weatherStationComponentDescriptor
   *     =new RemotableDescriptor().add("WeatherStation",WeatherStationImpl,new Class[]{WeatherStationInf.class})
   *                               .add("Meteriologist",MeteriologistImpl,new Class[]{Meteriologist.class});
   * </pre>
   * </code>
   *
   * @author <a href="mailto:vinayc@apache.org">Vinay Chandran</a>
   */
  public class RemotableDescriptor implements Iterator
  {
      //
      //****************************
      //********* Variables
      //****************************
      //
      /** List of remotable objects that are to be exposed */
      private ArrayList m_listOfRemotables;
      /** Published Name */
      private String m_publishName;
      /** Implementation Obj to  be exposed */
      private Object m_implObj;
      /** Exposed Interfaces  */
      private Class[] m_interfacesExposed=new Class[0];
      /** Additional facade Interfaces */
      private Class[] m_additionalFacadeInterfaces=new Class[0];
      /** current position in the array of RemotableDescriptors*/
      private int m_index = 0;
      //
      //****************************
      //*********Constructor
      //****************************
      //
      /**
       *
       * This Constructor is used to create the root <code>RemotableDescriptor</code> object,
       * which contains the collection of <code>RemotableDescriptor</code>'s
       * which in turn contains the neccessary details to expose the object through AltRMI server..
       * Usage :
       * <code><pre>
       * RemotableDescriptor weatherStationComponentDescriptor
       *     =new RemotableDescriptor().add("WeatherStation",WeatherStationImpl,new Class[]{WeatherStationInf.class})
       *                               .add("Meteriologist",MeteriologistImpl,new Class[]{Meteriologist.class});
       * </pre>
       * </code>
       *
       */
  
      public RemotableDescriptor()
      {
          m_listOfRemotables = new ArrayList();
      }
  
      /**
       *
       * Constructor a RemotableDescriptor element,
       * which describes the object that is exposed
       *
       */
      public RemotableDescriptor(
          String publishName,
          Object implObj,
          Class[] interfacesExposed)
      {
          m_publishName = publishName;
          m_implObj = implObj;
          m_interfacesExposed = interfacesExposed;
      }
  
      /**
       *
       * Constructor a RemotableDescriptor element,
       * which describes the object that is exposed
       *
       */
      public RemotableDescriptor(
          String publishName,
          Object implObj,
          Class[] interfacesExposed,
          Class[] additionalFacades)
      {
          this(publishName,implObj,interfacesExposed);
          m_additionalFacadeInterfaces=additionalFacades;
      }
  
      //
      //****************************
      //*********Accessor Methods
      //****************************
      //
  
      /**
       * Returns the implObj.
       * @return Object
       */
      public Object getImplObj()
      {
          return m_implObj;
      }
  
      /**
       * Returns the interfacesExposed.
       * @return items
       */
      public PublicationDescriptionItem[] getInterfacesExposed()
      {
          if (m_interfacesExposed == null)
          {
              return new PublicationDescriptionItem[0];
          }
  
          PublicationDescriptionItem[] items = new PublicationDescriptionItem[m_interfacesExposed.length];
          for (int i = 0; i < m_interfacesExposed.length; i++)
          {
              Class clazz = m_interfacesExposed[i];
              items[i] = new PublicationDescriptionItem(clazz);
          }
          return items;
  
      }
  
      /**
       * Returns the additionalFacadeInterfaces.
       * @return items
       */
      public PublicationDescriptionItem[] getAdditionalFacadeInterfaces()
      {
          if (m_additionalFacadeInterfaces == null)
          {
              return new PublicationDescriptionItem[0];
          }
  
          PublicationDescriptionItem[] items = new PublicationDescriptionItem[m_additionalFacadeInterfaces.length];
          for (int i = 0; i < m_additionalFacadeInterfaces.length; i++)
          {
              Class clazz = m_additionalFacadeInterfaces[i];
              items[i] = new PublicationDescriptionItem(clazz);
          }
          return items;
      }
  
      /**
       * Returns the listOfRemotables.
       * @return ArrayList
       */
      public ArrayList getListOfRemotables()
      {
          return m_listOfRemotables;
      }
  
      /**
       * Returns the publishName.
       * @return String
       */
      public String getPublishName()
      {
          return m_publishName;
      }
  
      //
      //****************************
      //*********Methods
      //****************************
      //
      /**
       *
       * Add a object's remote descriptor
       *
       * @return RemotableDescriptor Return the
       *          reference of the invoked descriptor and
       *          thus one can build the collection of
       *          descriptors easily.
       *
       */
      public RemotableDescriptor add(
          String publishName,
          Object implObj,
          Class[] interfacesToExpose)
      {
          return this.add(publishName,implObj,interfacesToExpose,null);
      }
  
      /**
       * Add a object's remote descriptor
       */
      public RemotableDescriptor add(String publishName,Object implObj,Class[] interfacesToExpose,Class[] additionalFacadeInterfaces)
      {
          m_listOfRemotables.add(
              new RemotableDescriptor(publishName, implObj, interfacesToExpose,additionalFacadeInterfaces));
          return this;
      }
  
      /**
       *
       * Add the RemotableDescriptor element to the collection
       *
       */
      public RemotableDescriptor add(RemotableDescriptor remotableDescriptor)
      {
          m_listOfRemotables.add(remotableDescriptor);
          return this;
      }
  
      //
      //****************************
      //*********Iterator implementations
      //****************************
      //
  
      /**
       * @see java.util.Iterator#hasNext()
       */
      public boolean hasNext()
      {
          return m_listOfRemotables.size() > m_index;
      }
  
      /**
       * @see java.util.Iterator#next()
       */
      public Object next()
      {
          return m_listOfRemotables.get(m_index++);
      }
  
      /**
       * @see java.util.Iterator#remove()
       */
      public void remove()
      {
          m_listOfRemotables.remove(--m_index);
      }
  
  
  
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/remotable/RemotableExtensionManager.java
  
  Index: RemotableExtensionManager.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Avalon", 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 apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 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.excalibur.altrmi.remotable;
  
  import java.io.File;
  import java.lang.reflect.Constructor;
  import java.net.URL;
  import java.net.URLClassLoader;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.Serviceable;
  import org.apache.excalibur.altrmi.common.ProxyGenerator;
  import org.apache.excalibur.altrmi.server.AltrmiProxyGenerator;
  import org.apache.excalibur.altrmi.server.PublicationDescription;
  import org.apache.excalibur.altrmi.server.PublicationDescriptionItem;
  import org.apache.excalibur.altrmi.server.impl.AbstractServer;
  import org.apache.excalibur.altrmi.server.impl.classretrievers.PlainClassRetriever;
  import org.apache.excalibur.container.lifecycle.Creator;
  
  /**
   * Remotable Extension handler.
   * <br/>
   * It uses Altrmi to expose objects supplied by components implementing
   * the <code>Remotable</code> lifecycle extension.
   * <br/>
   * One can chose between the different Altrmi transport implementation
   * using the &lt;altrmi&gt;  configuration element while configuring the
   * extension handler.
   * <br/>
   * Using this one can specify the specific altrmi transport
   * while configuring the <code>RemotableExtensionManager</code> component.
   * <br/>
   * Example:
   * <br/>
   * <code><pre>
   * &lt;altrmi type="custom.altrmi"
   *  class="org.apache.excalibur.altrmi.server.impl.socket.CompleteSocketCustomStreamServer"/&gt;
   * </pre></code>
   *
   * @author <a href="mailto:vinayc@apache.org">Vinay Chandran</a>
   */
  public class RemotableExtensionManager
      extends AbstractLogEnabled
      implements
          Serviceable,
          Configurable,
          Initializable,
          Disposable,
          Creator,
          Contextualizable
  {
  
      //
      //****************************
      //*********Variables
      //****************************
      //
      /** Altrmi server through which the components are remoted*/
      private AbstractServer m_altrmiServer;
      /** Class Retriever that fetchs the stubs on clients request */
      private PlainClassRetriever m_classRetriever;
      /** ProxyGenerator used to generate stubs dynamicalls */
      private ProxyGenerator m_proxyGenerator;
      /** Classpath entry needed by the proxyGenerator */
      private String m_classpath;
      /** Indicates whether the extension handler has been activated
       * successfully*/
      private boolean m_initialized = false;
      /** Port number Altrmi server is listening on */
      private int m_port = 1234;
      /** Altrmi working directory*/
      private File m_altrmiWorkDirectory;
      /** Generated Stub Class's Directory*/
      private File m_altrmiGeneratedClassesDirectory;
      /** Generated Stub Source's Directory*/
      private File m_altrmiGeneratedSourceDirectory;
      //
      //****************************
      //*********Lifecycle Methods
      //****************************
      //
      /**
       * @see org.apache.avalon.framework.context.Contextualizable#contextualize(Context)
       */
      public void contextualize(Context context) throws ContextException
      {
          getLogger().info("context");
          //Create the working directory for Altrmi.
          m_altrmiWorkDirectory =
              new File((File) context.get("avalon:home"), "work-altrmi");
          m_altrmiWorkDirectory.mkdir();
          m_altrmiGeneratedClassesDirectory =
              new File(m_altrmiWorkDirectory, "genClasses");
          m_altrmiGeneratedClassesDirectory.mkdir();
          m_altrmiGeneratedSourceDirectory =
              new File(m_altrmiWorkDirectory, "genSource");
          m_altrmiGeneratedSourceDirectory.mkdir();
          getLogger().info(
              "working directory for altrmi:" + m_altrmiWorkDirectory);
      }
  
      /**
       * @see org.apache.avalon.framework.service.Serviceable#service(ServiceManager)
       */
      public void service(ServiceManager arg0) throws ServiceException
      {
          getLogger().info("service");
      }
  
      /**
       * Configure the Altrmi Server with the transport
       * choices specified within the configuration of the handler.
       * <br/>
       * <code>
       * <pre>
       * &lt;altrmi type="<i>short hand for the transport type</i>"
       *               classname="<i> Altrmi Server implementation</i>"
       *               class-retriever="<i>Class name of the ClassRetriever </i>"/>
       * </pre>
       * </code>
       * <br/>
       * Note:
       * "classname" is optional with the default of Altrmi Custom server.
       * (org.apache.excalibur.altrmi.server.impl.socket.CompleteSocketCustomStreamServer)
       * <br/>
       * <br/>
       * "class-retriever" is optional with the default of Javac ClassRetriever.
       * (org.apache.excalibur.altrmi.server.impl.classretrievers.JavacDynamicGeneratorClassRetriever)
       *
       * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
       */
      public void configure(Configuration config) throws ConfigurationException
      {
          getLogger().info("configure");
          Configuration altrmiConfig = config.getChild("altrmi");
          //create Altrmi Server
          if (!createServer(altrmiConfig))
          {
              return;
          }
          /*
           * if (!createClassRetriever(altrmiConfig))
          {
              return;
          }
          */
          if (!createProxyGenerator(altrmiConfig))
          {
              return;
          }
          if (!checkCompiler())
          {
              return;
          }
  
          //Finally announce the successful initialization
          getLogger().info("AltRMI server started on port[" + m_port + "]");
          m_initialized = true;
  
      }
  
      /**
       * Method createServer.
       * @param config
       * @return boolean
       * @throws ConfigurationException
       */
  
      private boolean createServer(Configuration config)
          throws ConfigurationException
      {
  
          //Read atlrmi server class name
          String className =
              config.getAttribute(
                  "class",
                  "org.apache.excalibur.altrmi.server.impl.socket.CompleteSocketCustomStreamServer");
          Class transportClass = null;
          try
          {
              transportClass =
                  this.getClass().getClassLoader().loadClass(className);
          }
          catch (ClassNotFoundException e)
          {
              getLogger().error(
                  "\n**********************************************************************"
                      + "\n Altrmi Transport class ["
                      + className
                      + "] NOT FOUND"
                      + "\n Remedy:"
                      + "\n -------------------------------------------------------------------"
                      + "\n Place Altrmi libraries within the classpath of the  container"
                      + "\n "
                      + "\n Proceeding further without AltRMI beside the components for remoting"
                      + "\n**********************************************************************");
              return false;
          }
          //Read port to listen on
          m_port = config.getAttributeAsInteger("port", m_port);
  
          //Fetch the constructor.
          Constructor cons = null;
          try
          {
              cons = transportClass.getConstructor(new Class[] { Integer.TYPE });
          }
          catch (NoSuchMethodException e)
          {
              getLogger().error(
                  "\n**********************************************************************"
                      + "\n Altrmi Transport class ["
                      + className
                      + "] does NOT have a constructor that "
                      + "\n takes the port no. it listens to"
                      + "\n "
                      + "\n Proceeding further without AltRMI beside the components for remoting"
                      + "\n**********************************************************************");
              return false;
          }
  
          //Now Create the instance
          try
          {
              m_altrmiServer =
                  (AbstractServer) cons.newInstance(
                      new Object[] { new Integer(m_port)});
          }
          catch (ClassCastException e)
          {
              getLogger().error(
                  "\n**********************************************************************"
                      + "\n Altrmi Transport class ["
                      + className
                      + "] does NOT extend o.a.excalibur.altrmi.server.impl.AbstractServer "
                      + "\n "
                      + "\n Proceeding further without AltRMI beside the components for remoting"
                      + "\n**********************************************************************");
              return false;
          }
          catch (Exception e)
          {
              getLogger().error(
                  "\n**********************************************************************"
                      + "\n An instance of Altrmi Transport class ["
                      + className
                      + "] could NOT be created"
                      + "\n "
                      + "\n Proceeding further without AltRMI beside the components for remoting"
                      + "\n**********************************************************************");
              return false;
          }
  
          //Successful
          return true;
      }
  
      /**
       * Method createProxyGenerator.
       * @param config
       * @return boolean
       */
  
      private boolean createProxyGenerator(Configuration config)
      {
          //Read proxy generator class
          String strProxyGenerator =
              config.getAttribute(
                  "proxy-generator",
                  "org.apache.excalibur.altrmi.generator.ProxyGeneratorImpl");
          //Create a instance of the proxy generator
          try
          {
              Class clazz =
                  getClass().getClassLoader().loadClass(strProxyGenerator);
              //Check if the class is after all a 'ClassRetriever'
              if (!ProxyGenerator.class.isAssignableFrom(clazz))
              {
                  getLogger().error(
                      "\n**********************************************************************"
                          + "\n Altrmi Proxy  Generator["
                          + strProxyGenerator
                          + "] does NOT implement "
                          + AltrmiProxyGenerator.class.getName()
                          + " interface"
                          + "\n"
                          + "\n Proceeding further without AltRMI beside the components for remoting"
                          + "\n**********************************************************************");
                  return false;
              }
  
              m_proxyGenerator = (ProxyGenerator) clazz.newInstance();
          }
          catch (Exception e)
          {
              getLogger().error(
                  "\n**********************************************************************"
                      + "\n Altrmi Proxy Generator["
                      + strProxyGenerator
                      + "] could NOT be created"
                      + "\n Exception Message[",
                  e);
              getLogger().error(
                  "] \nProceeding further without AltRMI beside the components for remoting"
                      + "\n**********************************************************************");
              return false;
          }
  
          //successful
          return true;
      }
  
      /**
       * Check if SUN's javac compiler is present
       * TODO:
       */
      private boolean checkCompiler()
      {
          try
          {
              Class.forName("sun.tools.javac.Main");
          }
          catch (ClassNotFoundException cnfe)
          {
              getLogger().error(
                  "\n**********************************************************************"
                      + " \n Java Compiler[sun.tools.javac.Main] Not Found"
                      + " \n Remedy: Add tools.jar to the container's classpath"
                      + "] \nProceeding further without AltRMI beside the components for remoting"
                      + "\n**********************************************************************");
              return false;
          }
          return true;
      }
  
      /**
       * Initialize the internal Altrmi Server
       * @see org.apache.avalon.framework.activity.Initializable#initialize()
       */
      public void initialize() throws Exception
      {
          if (!m_initialized)
          {
              getLogger().info(
                  "short-circuiting Remotable lifecycle since the Altrmi Server could NOT start successfully");
              return;
          }
          getLogger().info("initialize");
          //Initialize the proxyGenerator
          m_proxyGenerator.setClassGenDir(
              m_altrmiGeneratedClassesDirectory.getCanonicalPath());
          m_proxyGenerator.setSrcGenDir(
              m_altrmiGeneratedSourceDirectory.getCanonicalPath());
  
          //set the classpath entry needed
          m_classpath =
              m_altrmiGeneratedSourceDirectory.getCanonicalPath()
                  + File.pathSeparator
                  + m_altrmiGeneratedClassesDirectory.getCanonicalPath();
          try
          {
              //adding altrmi-client-interfaces library
              m_classpath += File.pathSeparator
                  + getClassLocation(
                      Class.forName(
                          "org.apache.excalibur.altrmi.client.AltrmiProxy"));
              //adding altrmi-common library
              m_classpath += File.pathSeparator
                  + getClassLocation(
                      Class.forName(
                          "org.apache.excalibur.altrmi.common.AltrmiInvocationException"));
  
          }
          catch (ClassNotFoundException e)
          {
              //dump the stack trace
              getLogger().info("******************************", e);
              getLogger().info("******************************");
  
          }
          //Initialize the class retriever
          m_classRetriever =
              new PlainClassRetriever(
                  new URLClassLoader(
                      new URL[] { m_altrmiGeneratedClassesDirectory.toURL()},
                      getClass().getClassLoader()));
          //Initialize the server
          m_altrmiServer.setClassRetriever(m_classRetriever);
          m_altrmiServer.start();
      }
  
      /**
       * Stop the Altrmi Server
       * @see org.apache.avalon.framework.activity.Disposable#dispose()
       */
      public void dispose()
      {
          if (!m_initialized)
          {
              getLogger().info(
                  "short-circuiting Remotable lifecycle since the Altrmi Server could NOT start successfully");
              return;
          }
          getLogger().info("dispose");
          m_altrmiServer.stop();
      }
  
      //
      //****************************
      //*********Extension enablers(Creator)
      //****************************
      //
  
      /**
       * Here we catch hold of the component that intends
       * to expose itself off remotely to the client.
       * We query the component to give us a list of object's that it wishes to expose.
       *
       * @see org.apache.excalibur.container.lifecycle.Creator#create(Object, Context)
       */
      public void create(Object obj, Context context) throws Exception
      {
          if (!m_initialized)
          {
              getLogger().info(
                  "short-circuiting Remotable lifecycle since the Altrmi Server could NOT start successfully");
              return;
          }
          getLogger().debug("create");
          if (obj instanceof Remotable)
          {
              RemotableDescriptor remotableDescriptor =
                  ((Remotable) obj).getExposedObjects();
              if (remotableDescriptor == null)
              {
                  getLogger().debug(
                      "Component["
                          + obj.getClass().getName()
                          + "] has Nothing to expose");
                  return;
              }
              while (remotableDescriptor.hasNext())
              {
                  RemotableDescriptor descriptor =
                      ((RemotableDescriptor) remotableDescriptor.next());
                  if (descriptor.getInterfacesExposed().length < 1)
                  {
                      //Nothing to generate
                      continue;
                  }
  
                  //Create the dynamic classpath  required by the proxygenerator
                  PublicationDescriptionItem[] interfacesExposed = descriptor.getInterfacesExposed();
                  String classpath = "";
                  for (int i = 0; i < interfacesExposed.length; i++)
                  {
                      //adding the classpath entries to enable the proxy generator to find the
                      // interfaces
                      classpath += File.pathSeparator
                          + getClassLocation(interfacesExposed[i].getFacadeClass());
                  }
                  m_proxyGenerator.setClasspath(m_classpath + classpath);
                  //proceeding with the generation
                  m_proxyGenerator.setGenName(descriptor.getPublishName());
                  m_proxyGenerator.setInterfacesToExpose(descriptor.getInterfacesExposed());
                  m_proxyGenerator.setAdditionalFacades(descriptor.getAdditionalFacadeInterfaces());
                  //generating NOW
                  m_proxyGenerator.generateSrc(getClass().getClassLoader());
                  m_proxyGenerator.generateClass(getClass().getClassLoader());
  
                  PublicationDescription pd = new PublicationDescription();
                  pd.addInterfacesToExpose(descriptor.getInterfacesExposed());
                  pd.addAdditionalFacadesToExpose(descriptor.getAdditionalFacadeInterfaces());
  
  
                  //publishing NOW
                  m_altrmiServer.publish(
                      descriptor.getImplObj(),
                      descriptor.getPublishName(),pd);
  
                  getLogger().info("Publishing:" + descriptor.getPublishName());
              }
          }
      }
      /**
       * Currently we dont do anything since the shutdown of this
       * handler will shutdown the published objects too .
       * @see org.apache.excalibur.container.lifecycle.Creator#destroy(Object, Context)
       */
      public void destroy(Object obj, Context context)
      {
          if (!m_initialized)
          {
              getLogger().info(
                  "short-circuiting Remotable lifecycle since the Altrmi Server could NOT start successfully");
              return;
          }
          getLogger().debug("destroy");
  
          if (obj instanceof Remotable)
          {
          }
      }
  
      /**
       * Retrieve the location of the given class.
       * @return the classpath entry corresponding to location class.
       */
      private String getClassLocation(Class clazz)
      {
          URL urlOfClassFile =
              getClass().getClassLoader().getResource(
                  clazz.getName().replace('.', '/') + ".class");
          String protocol = urlOfClassFile.getProtocol();
          if ("jar".equals(protocol))
          {
              //In Windows a jar URL in string notation appears as :
              //   jar:file:/E:/eclipse/workspace/assembly/bin/lib/remotable-demo.jar!/org/apache/avalon/altrmi/merlin/demo/SimpleService.class
              String strJarFile =
                  urlOfClassFile.toString().substring(
                      10,
                      urlOfClassFile.toString().lastIndexOf('!'));
              getLogger().info("Adding to classpath:" + strJarFile);
              return strJarFile;
          }
          return "";
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/remotable/RemotableExtensionManager.xconfig
  
  Index: RemotableExtensionManager.xconfig
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
  The .xconfig file contains the default configuration for the component.
  -->
  
  <configuration>
     <!-- Configuration for a custom Altrmi server bootup-->
     <altrmi type="altrmi.custom" 
     		   class="org.apache.excalibur.altrmi.server.impl.socket.CompleteSocketCustomStreamServer"
     		   class-retriever="org.apache.excalibur.altrmi.server.impl.classretrievers.JarFileClassRetriever"
     		   proxy-generator="org.apache.excalibur.altrmi.generator.ProxyGeneratorImpl"/>
  </configuration>
  
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/remotable/RemotableExtensionManager.xinfo
  
  Index: RemotableExtensionManager.xinfo
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
  Definition of the extension type phase support.
  -->
  
  <type>
  
    <component>
      <name>remotable</name>
    </component>
    
    <context>
  	<entry key="avalon:home" type="java.io.File"/>
    </context>
  
    <!--
    Declaration of the lifecycle support phases that this manager provides. 
    -->
    <extensions>
  
      <!--
      Each extension has a name, a versioned interface reference, and optional 
      attributes.
      -->
      <extension stage="ALL">
        <name>remotable</name>
        <reference type="org.apache.avalon.altrmi.remotable.Remotable" version="1.0"/>
        <attributes>
          <attribute key="status" value="experimental"/>
        </attributes>
      </extension>
  
    </extensions>
  
  </type>
  
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/remotable/RemotableDescriptorTestCase.java
  
  Index: RemotableDescriptorTestCase.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.remotable;
  
  import junit.framework.TestCase;
  
  import org.apache.excalibur.altrmi.remotable.RemotableDescriptor;
  
  /**
   * <p>
   * Test RemotableDescriptor
   * </p>
   *
   * @author <a href="mailto:vinayc@apache.org">Vinay Chandran</a>
   */
  public class RemotableDescriptorTestCase extends TestCase
  {
      //
      //****************************
      //*********Testcase Constructor
      //****************************
      //
      public RemotableDescriptorTestCase(String name)
      {
          super(name);
      }
  
      //
      //****************************
      //*********Test cases
      //****************************
      //
      public void testDescriptor()
      {
          String pn_1 = "publishName1";
          String implObj_1 = "ImplObj1";
          Class[] interfaceToExpose_1 = new Class[] { String.class };
          String pn_2 = "publishName2";
          String implObj_2 = "ImplObj2";
          Class[] interfaceToExpose_2 = new Class[] { Integer.class };
  
          RemotableDescriptor remotableDescriptor =
              new RemotableDescriptor().add(pn_1, implObj_1, interfaceToExpose_1)
                                        .add(pn_2,implObj_2,interfaceToExpose_2);
          //1st elem
          assertEquals(true, remotableDescriptor.hasNext());
          RemotableDescriptor elem =
              (RemotableDescriptor) remotableDescriptor.next();
          assertNotNull(elem);
          assertEquals("publishName1", elem.getPublishName());
          assertEquals("ImplObj1", elem.getImplObj());
          //2nd elem
          assertEquals(true, remotableDescriptor.hasNext());
          elem =
              (RemotableDescriptor) remotableDescriptor.next();
          assertNotNull(elem);
          assertEquals("publishName2", elem.getPublishName());
          assertEquals("ImplObj2", elem.getImplObj());
      }
  }
  
  
  

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