You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2004/01/04 16:23:01 UTC

cvs commit: avalon/merlin project.xml

mcconnell    2004/01/04 07:23:01

  Modified:    merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl
                        Deployer.java DeploymentRequest.java
               merlin/composition/impl maven.xml
               merlin   project.xml
  Log:
  Update exception message related to deployment timeout errors, update code format, remove on-line requirement from composition testcase, and bump HEAD build version to 3.3.
  
  Revision  Changes    Path
  1.2       +68 -27    avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/Deployer.java
  
  Index: Deployer.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/Deployer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Deployer.java	4 Jan 2004 12:00:28 -0000	1.1
  +++ Deployer.java	4 Jan 2004 15:23:01 -0000	1.2
  @@ -4,7 +4,7 @@
                      The Apache Software License, Version 1.1
    ============================================================================
   
  - Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  + Copyright (C) 1999-2004 The Apache Software Foundation. All rights reserved.
   
    Redistribution and use in source and binary forms, with or without modifica-
    tion, are permitted provided that the following conditions are met:
  @@ -56,24 +56,51 @@
   
   import org.apache.avalon.framework.logger.Logger;
   
  +/**
  + * Runnable deployment thread.
  + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
  + * @version $Revision$ $Date$
  + */
   class Deployer
       implements Runnable
   {
  -    static private int  m_ThreadCounter = 0;
  +    //------------------------------------------------------------
  +    // static
  +    //------------------------------------------------------------
  +
  +    static private int m_ThreadCounter = 0;
       
  -    private Logger      m_Logger;
  -    private Thread      m_DeploymentThread;
  -    private SimpleFIFO  m_DeploymentFIFO;
  +    //------------------------------------------------------------
  +    // immutable state
  +    //------------------------------------------------------------
  +
  +    private final Logger m_logger;
  +    private final SimpleFIFO m_deploymentFIFO;
  +
  +    //------------------------------------------------------------
  +    // mutable static
  +    //------------------------------------------------------------
  +
  +    private Thread      m_deploymentThread;
       
  +    //------------------------------------------------------------
  +    // constructor
  +    //------------------------------------------------------------
  +
       Deployer( Logger logger )
       {
  -        m_Logger = logger;
  -        m_DeploymentFIFO = new SimpleFIFO();
  +        m_logger = logger;
  +        m_deploymentFIFO = new SimpleFIFO();
           
  -        m_DeploymentThread = new Thread( this, "Deployer - " + m_ThreadCounter++ );
  -        m_DeploymentThread.start();
  +        m_deploymentThread = 
  +          new Thread( this, "Deployer - " + m_ThreadCounter++ );
  +        m_deploymentThread.start();
       }
   
  +    //------------------------------------------------------------
  +    // implementation
  +    //------------------------------------------------------------
  +
       /** Deploys the given Deployable, and allows a maximum time
        *  for the deployment to complete.
        * @throws DeploymentException if the deployment hanged, but the
  @@ -88,51 +115,65 @@
       void deploy( Deployable deployable, long timeout )
           throws Exception
       {
  -        if( deployable == null ) 
  +        if( deployable == null )
  +        {
               throw new NullPointerException( "deployable" );
  -        if( m_Logger.isDebugEnabled() )
  -            m_Logger.debug( "Deployer: deploy - " + deployable );
  -        DeploymentRequest req = new DeploymentRequest( deployable, m_DeploymentThread );
  -        m_DeploymentFIFO.put( req );
  +        }
  +        if( m_logger.isDebugEnabled() )
  +        {
  +            m_logger.debug( "Deployer: deploy - " + deployable );
  +        }
  +        DeploymentRequest req = 
  +          new DeploymentRequest( deployable, m_deploymentThread );
  +        m_deploymentFIFO.put( req );
           req.waitForCompletion( timeout );
       }
   
  -    /** Disposal of the Deployer.
  -     *
  +    /** 
  +     * Disposal of the Deployer.
        * The Deployer allocates a deployment thread, which needs to be
        * disposed of before releasing the Deployer reference.
        **/
       void dispose()
       {
  -        if( m_Logger.isDebugEnabled() )
  -            m_Logger.debug( "Deployer: dispose deployer " );
  -        m_DeploymentThread.interrupt();
  +        if( m_logger.isDebugEnabled() )
  +        {
  +            m_logger.debug( "Deployer: dispose deployer " );
  +        }
  +        m_deploymentThread.interrupt();
       }
       
       public void run()
       {
  -        if( m_Logger.isDebugEnabled() )
  -            m_Logger.debug( "Deployer: DeploymentThread started." );
  +        if( m_logger.isDebugEnabled() )
  +        {
  +            m_logger.debug( "Deployer: DeploymentThread started." );
  +        }
           try
           {
               while( true )
               {
  -                DeploymentRequest req = (DeploymentRequest) m_DeploymentFIFO.get();
  +                DeploymentRequest req = (DeploymentRequest) m_deploymentFIFO.get();
                   Deployable deployable = req.getDeployable();
                   try
                   {
                       deployable.deploy();
                       req.done();
  -                } catch( InterruptedException e )
  +                } 
  +                catch( InterruptedException e )
                   {
                       req.interrupted();
  -                } catch( Throwable e )
  +                } 
  +                catch( Throwable e )
                   {
                       req.exception( e );
                   }
               }
  -        } catch( InterruptedException e )
  -        {} // ignore, part of dispose();
  -        m_DeploymentThread = null;
  +        } 
  +        catch( InterruptedException e )
  +        { 
  +            // ignore, part of dispose();
  +        }
  +        m_deploymentThread = null;
       }
   }
  
  
  
  1.2       +75 -26    avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/DeploymentRequest.java
  
  Index: DeploymentRequest.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/DeploymentRequest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeploymentRequest.java	4 Jan 2004 12:00:28 -0000	1.1
  +++ DeploymentRequest.java	4 Jan 2004 15:23:01 -0000	1.2
  @@ -4,7 +4,7 @@
                      The Apache Software License, Version 1.1
    ============================================================================
   
  - Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  + Copyright (C) 1999-2004 The Apache Software Foundation. All rights reserved.
   
    Redistribution and use in source and binary forms, with or without modifica-
    tion, are permitted provided that the following conditions are met:
  @@ -56,26 +56,48 @@
   import org.apache.avalon.activation.appliance.DeploymentException;
   import org.apache.avalon.activation.appliance.FatalDeploymentException;
   
  +/**
  + * A deployment request handler.
  + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
  + * @version $Revision$ $Date$
  + */
   class DeploymentRequest
   {
  -    private Deployable m_Deployable;
  -    private boolean   m_Completed;
  -    private boolean   m_Interrupted;
  -    private Thread    m_DeploymentThread;
  -    private Throwable m_Exception;
  +    //------------------------------------------------------------
  +    // immutable state
  +    //------------------------------------------------------------
  +
  +    private final Deployable m_deployable;
  +    private final Thread m_deploymentThread;
       
  +    //------------------------------------------------------------
  +    // mutable state
  +    //------------------------------------------------------------
  +
  +    private boolean   m_completed;
  +    private boolean   m_interrupted;
  +    private Throwable m_exception;
  +
  +    //------------------------------------------------------------
  +    // constructor
  +    //------------------------------------------------------------
  +
       DeploymentRequest( Deployable deployable, Thread deploymentThread )
       {
  -        m_Deployable = deployable;
  -        m_Completed = false;
  -        m_Interrupted = false;
  -        m_Exception = null;
  -        m_DeploymentThread = deploymentThread;
  +        m_deployable = deployable;
  +        m_completed = false;
  +        m_interrupted = false;
  +        m_exception = null;
  +        m_deploymentThread = deploymentThread;
       }
   
  +    //------------------------------------------------------------
  +    // implementation
  +    //------------------------------------------------------------
  +
       Deployable getDeployable()
       {
  -        return m_Deployable;
  +        return m_deployable;
       }
   
       void waitForCompletion( long timeout )
  @@ -85,28 +107,55 @@
           {
               wait( timeout );
               processException();
  -            if( m_Completed )
  +            if( m_completed )
  +            {
                   return;
  -            m_DeploymentThread.interrupt();
  +            }
  +            m_deploymentThread.interrupt();
               wait( timeout );
               processException();
  -            if( m_Interrupted || m_Completed )
  -                throw new DeploymentException( "Deployable '" + m_Deployable + "' hanged during deployment and was interrupted." );
  -            throw new FatalDeploymentException( "Deployable '" + m_Deployable + "' hanged during deployment and could not be interrupted." );
  +            if( m_interrupted || m_completed )
  +            {
  +                final String error = 
  +                  "deployment target: [" 
  +                  + m_deployable 
  +                  + "] did not respond within the timeout period: [" 
  +                  + timeout
  +                  + "] and was successfully interrupted.";
  +                throw new DeploymentException( error );
  +            }
  +            else
  +            {
  +                final String error = 
  +                  "deployment target: [" 
  +                  + m_deployable 
  +                  + "] did not respond within the timeout period: [" 
  +                  + timeout
  +                  + "] and failed to respond to an interrupt.";
  +                throw new FatalDeploymentException( error );
  +            }
           }
       }
   
       private void processException()
           throws Exception
       {
  -        if( m_Exception != null )
  +        if( m_exception != null )
           {
  -            if( m_Exception instanceof Exception )
  -                throw (Exception) m_Exception;
  -            else if( m_Exception instanceof Error )
  -                throw (Error) m_Exception;
  +            if( m_exception instanceof Exception )
  +            {
  +                throw (Exception) m_exception;
  +            }
  +            else if( m_exception instanceof Error )
  +            {
  +                throw (Error) m_exception;
  +            }
               else
  -                throw new InvocationTargetException( m_Exception, "Unknown Throwable type, neither Exception nor Error." );
  +            {
  +                final String error = 
  +                  "Unexpected deployment error.";
  +                throw new InvocationTargetException( m_exception, error );
  +            }
           }
       }
   
  @@ -114,19 +163,19 @@
       {
           synchronized( this )
           {
  -            m_Completed = true;
  +            m_completed = true;
               notifyAll();
           }
       }
   
       void interrupted()
       {
  -        m_Interrupted = true;
  +        m_interrupted = true;
       }
   
       void exception( Throwable e )
       {
  -        m_Exception = e;
  +        m_exception = e;
       }
   }
   
  
  
  
  1.2       +2 -0      avalon/merlin/composition/impl/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/maven.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- maven.xml	24 Sep 2003 09:31:24 -0000	1.1
  +++ maven.xml	4 Jan 2004 15:23:01 -0000	1.2
  @@ -51,6 +51,8 @@
         </fileset>
       </ant:delete>
   
  +    <ant:copy toDir="${basedir}/target/test-classes/repository/avalon-framework/jars" 
  +      file="${pom.getDependencyPath('avalon-framework:avalon-framework-impl')}"/>
       <ant:copy toDir="${basedir}/target/test-classes/ext" 
         file="${pom.getDependencyPath('avalon-framework:avalon-framework-api')}"/>
       <ant:copy toDir="${basedir}/target/test-classes/ext" 
  
  
  
  1.19      +1 -1      avalon/merlin/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/project.xml,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- project.xml	1 Jan 2004 23:34:45 -0000	1.18
  +++ project.xml	4 Jan 2004 15:23:01 -0000	1.19
  @@ -6,7 +6,7 @@
     <groupId>merlin</groupId>
     <id>merlin</id>
     <name>Avalon Merlin</name>
  -  <currentVersion>3.2.3</currentVersion>
  +  <currentVersion>3.2.4</currentVersion>
   
     <organization>
       <name>Apache Software Foundation</name>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org