You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by le...@apache.org on 2002/08/06 14:58:27 UTC

cvs commit: jakarta-avalon-excalibur/instrument/src/manager/org/apache/excalibur/instrument/manager/altrmi InstrumentManagerAltrmiConnector.java

leif        2002/08/06 05:58:26

  Modified:    instrument/src/manager/org/apache/excalibur/instrument/manager
                        DefaultInstrumentManager.java
                        InstrumentManagerConnector.java
               instrument/src/manager/org/apache/excalibur/instrument/manager/altrmi
                        InstrumentManagerAltrmiConnector.java
  Log:
  Improve the plugability of Connectors by freeing them to implement the actions
  of their choice.
  
  Revision  Changes    Path
  1.6       +25 -3     jakarta-avalon-excalibur/instrument/src/manager/org/apache/excalibur/instrument/manager/DefaultInstrumentManager.java
  
  Index: DefaultInstrumentManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/instrument/src/manager/org/apache/excalibur/instrument/manager/DefaultInstrumentManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultInstrumentManager.java	5 Aug 2002 11:51:59 -0000	1.5
  +++ DefaultInstrumentManager.java	6 Aug 2002 12:58:26 -0000	1.6
  @@ -17,6 +17,7 @@
   import java.util.Arrays;
   import java.util.Comparator;
   import java.util.HashMap;
  +import java.util.Iterator;
   
   import org.apache.excalibur.instrument.AbstractInstrument;
   import org.apache.excalibur.instrument.CounterInstrument;
  @@ -35,7 +36,9 @@
   import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
   import org.apache.avalon.framework.configuration.DefaultConfigurationSerializer;
  +import org.apache.avalon.framework.container.ContainerUtil;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.service.ServiceException;
   
   /**
  @@ -163,6 +166,9 @@
               m_name = configuration.getChild( "name" ).getValue( "instrument-manager" );
               m_description = configuration.getChild( "description" ).getValue( m_name );
               
  +            // Create a logger to use with the connectors
  +            Logger connLogger = getLogger().getChildLogger( "connector" );
  +            
               // Configure the connectors
               Configuration connectorsConf = configuration.getChild( "connectors" );
               Configuration[] connectorConfs =
  @@ -187,8 +193,9 @@
                       
                       // Initialize the new connector
                       connector.setInstrumentManager( this );
  -                    connector.configure( connectorConf );
  -                    connector.start();
  +                    ContainerUtil.enableLogging( connector, connLogger );
  +                    ContainerUtil.configure( connector, connectorConf );
  +                    ContainerUtil.start( connector );
                       
                       m_connectors.add( connector );
                   }
  @@ -277,6 +284,21 @@
           if( m_runner != null )
           {
               m_runner = null;
  +        }
  +        
  +        // Shutdown the connectors
  +        for ( Iterator iter = m_connectors.iterator(); iter.hasNext(); )
  +        {
  +            InstrumentManagerConnector connector = (InstrumentManagerConnector)iter.next();
  +            try
  +            {
  +                ContainerUtil.stop( connector );
  +                ContainerUtil.dispose( connector );
  +            }
  +            catch ( Exception e )
  +            {
  +                getLogger().error( "Encountered an unexpected error shutting down a connector", e );
  +            }
           }
   
           saveState();
  
  
  
  1.2       +5 -5      jakarta-avalon-excalibur/instrument/src/manager/org/apache/excalibur/instrument/manager/InstrumentManagerConnector.java
  
  Index: InstrumentManagerConnector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/instrument/src/manager/org/apache/excalibur/instrument/manager/InstrumentManagerConnector.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- InstrumentManagerConnector.java	4 Aug 2002 10:33:33 -0000	1.1
  +++ InstrumentManagerConnector.java	6 Aug 2002 12:58:26 -0000	1.2
  @@ -7,19 +7,19 @@
    */
   package org.apache.excalibur.instrument.manager;
   
  -import org.apache.avalon.framework.activity.Startable;
  -import org.apache.avalon.framework.configuration.Configurable;
  -
   /**
    * Interface for classes which can be registered as Connectors for
    *  InstrumentManagers.
    *
  + * The InstrumentManager is smart about handling connectors which implement
  + *  the LogEnabled, Configurable, Initializable, Startable and Disposable
  + *  interfaces.
  + *
    * @author <a href="mailto:leif@tanukisoftware.com">Leif Mortenson</a>
    * @version CVS $Revision$ $Date$
    * @since 4.1
    */
   public interface InstrumentManagerConnector
  -    extends Configurable, Startable
   {
       /**
        * Set the InstrumentManager to which the Connecter will provide
  
  
  
  1.2       +9 -4      jakarta-avalon-excalibur/instrument/src/manager/org/apache/excalibur/instrument/manager/altrmi/InstrumentManagerAltrmiConnector.java
  
  Index: InstrumentManagerAltrmiConnector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/instrument/src/manager/org/apache/excalibur/instrument/manager/altrmi/InstrumentManagerAltrmiConnector.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- InstrumentManagerAltrmiConnector.java	4 Aug 2002 10:33:33 -0000	1.1
  +++ InstrumentManagerAltrmiConnector.java	6 Aug 2002 12:58:26 -0000	1.2
  @@ -7,8 +7,11 @@
    */
   package org.apache.excalibur.instrument.manager.altrmi;
   
  +import org.apache.avalon.framework.activity.Startable;
  +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.excalibur.instrument.manager.DefaultInstrumentManager;
   import org.apache.excalibur.instrument.manager.InstrumentManagerClientLocalImpl;
  @@ -31,7 +34,8 @@
    * @since 4.1
    */
   public class InstrumentManagerAltrmiConnector
  -    implements InstrumentManagerConnector
  +    extends AbstractLogEnabled
  +    implements InstrumentManagerConnector, Configurable, Startable
   {
       /** The default port. */
       public static final int DEFAULT_PORT = 15555;
  @@ -78,6 +82,7 @@
       public void start()
           throws Exception
       {
  +        getLogger().debug( "Starting Instrument Manager Altrmi Connector" );
           InstrumentManagerClientLocalImpl client = new InstrumentManagerClientLocalImpl( m_manager );
           
           // Create the socket server
  @@ -93,14 +98,14 @@
           m_server.publish( client, "InstrumentManagerClient", 
               new PublicationDescription( InstrumentManagerClient.class, additionalFacadeClasses ) );
           
  -        System.out.println( "Starting CompleteSocketObjectStreamServer..." );
           m_server.start();
  -        System.out.println( "Started on port: " + m_port );
  +        getLogger().info( "Instrument Manager Altrmi Connector listening on port: " + m_port );
       }
       
       public void stop()
           throws Exception
       {
  +        getLogger().debug( "Stopping Instrument Manager Altrmi Connector" );
           m_server.stop();
           m_server = null;
       }
  
  
  

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