ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace DefaultTaskContext.java
Date Tue, 23 Apr 2002 07:24:11 GMT
donaldp     02/04/23 00:24:11

  Modified:    container/src/java/org/apache/myrmidon/components/workspace
                        DefaultTaskContext.java
  Log:
  Add ExecutionFrame into context and directly retrieve ServiceManager/PropertyStore/Resolver
and Logger from it.
  
  Note that we will zap logger in future and replace it with direct calling of TaskEventManager.fireTaskMessage
  
  Revision  Changes    Path
  1.38      +35 -49    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java
  
  Index: DefaultTaskContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- DefaultTaskContext.java	23 Apr 2002 06:55:39 -0000	1.37
  +++ DefaultTaskContext.java	23 Apr 2002 07:24:11 -0000	1.38
  @@ -12,11 +12,11 @@
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.excalibur.io.FileUtil;
  -import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
   import org.apache.myrmidon.interfaces.property.PropertyStore;
   
  @@ -24,7 +24,7 @@
    * Default implementation of TaskContext.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.37 $ $Date: 2002/04/23 06:55:39 $
  + * @version $Revision: 1.38 $ $Date: 2002/04/23 07:24:11 $
    */
   public class DefaultTaskContext
       implements TaskContext
  @@ -32,34 +32,18 @@
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultTaskContext.class );
   
  -    private final ServiceManager m_serviceManager;
  -    private final Logger m_logger;
  -    private final PropertyStore m_store;
  -    private PropertyResolver m_propertyResolver;
  +    private final ExecutionFrame m_frame;
   
       /**
  -     * Constructor that takes both parent context and a service directory.
  +     * Constructor that takes adapts TaskContext to a particular frame.
        */
  -    public DefaultTaskContext( final ServiceManager serviceManager,
  -                               final Logger logger,
  -                               final PropertyStore store )
  +    public DefaultTaskContext( final ExecutionFrame frame )
       {
  -        m_serviceManager = serviceManager;
  -        m_logger = logger;
  -        m_store = store;
  -
  -        if( null == m_serviceManager )
  -        {
  -            throw new NullPointerException( "serviceManager" );
  -        }
  -        if( null == m_logger )
  +        if( null == frame )
           {
  -            throw new NullPointerException( "logger" );
  -        }
  -        if( null == m_store )
  -        {
  -            throw new NullPointerException( "store" );
  +            throw new NullPointerException( "frame" );
           }
  +        m_frame = frame;
       }
   
       /**
  @@ -97,11 +81,12 @@
       {
           final String name = serviceClass.getName();
           //Note that this will chain up to parent ServiceManagers (if any)
  -        if( null != m_serviceManager && m_serviceManager.hasService( name ) )
  +        final ServiceManager serviceManager = m_frame.getServiceManager();
  +        if( null != serviceManager && serviceManager.hasService( name ) )
           {
               try
               {
  -                return m_serviceManager.lookup( name );
  +                return serviceManager.lookup( name );
               }
               catch( final ServiceException se )
               {
  @@ -143,12 +128,10 @@
       {
           try
           {
  -            if( null == m_propertyResolver )
  -            {
  -                m_propertyResolver = (PropertyResolver)getService( PropertyResolver.class
);
  -            }
  +            final PropertyResolver propertyResolver =
  +                (PropertyResolver)getService( PropertyResolver.class );
               final Object object =
  -                m_propertyResolver.resolveProperties( value, this );
  +                propertyResolver.resolveProperties( value, this );
               if( null == object )
               {
                   final String message = REZ.getString( "null-resolved-value.error", value
);
  @@ -174,7 +157,8 @@
       {
           try
           {
  -            return m_store.getProperty( name );
  +            final PropertyStore store = m_frame.getPropertyStore();
  +            return store.getProperty( name );
           }
           catch( final Exception e )
           {
  @@ -190,7 +174,8 @@
       public Map getProperties()
           throws TaskException
       {
  -        return m_store.getProperties();
  +        final PropertyStore store = m_frame.getPropertyStore();
  +        return store.getProperties();
       }
   
       /**
  @@ -202,7 +187,8 @@
       public void setProperty( final String name, final Object value )
           throws TaskException
       {
  -        m_store.setProperty( name, value );
  +        final PropertyStore store = m_frame.getPropertyStore();
  +        store.setProperty( name, value );
       }
   
       /**
  @@ -212,7 +198,7 @@
        */
       public void debug( final String message )
       {
  -        m_logger.debug( message );
  +        m_frame.getLogger().debug( message );
       }
   
       /**
  @@ -223,7 +209,7 @@
        */
       public void debug( final String message, final Throwable throwable )
       {
  -        m_logger.debug( message, throwable );
  +        m_frame.getLogger().debug( message, throwable );
       }
   
       /**
  @@ -233,7 +219,7 @@
        */
       public boolean isDebugEnabled()
       {
  -        return m_logger.isDebugEnabled();
  +        return m_frame.getLogger().isDebugEnabled();
       }
   
       /**
  @@ -243,7 +229,7 @@
        */
       public void verbose( String message )
       {
  -        m_logger.info( message );
  +        m_frame.getLogger().info( message );
       }
   
       /**
  @@ -254,7 +240,7 @@
        */
       public void verbose( String message, Throwable throwable )
       {
  -        m_logger.info( message, throwable );
  +        m_frame.getLogger().info( message, throwable );
       }
   
       /**
  @@ -264,7 +250,7 @@
        */
       public boolean isVerboseEnabled()
       {
  -        return m_logger.isInfoEnabled();
  +        return m_frame.getLogger().isInfoEnabled();
       }
   
       /**
  @@ -274,7 +260,7 @@
        */
       public void info( final String message )
       {
  -        m_logger.warn( message );
  +        m_frame.getLogger().warn( message );
       }
   
       /**
  @@ -285,7 +271,7 @@
        */
       public void info( final String message, final Throwable throwable )
       {
  -        m_logger.warn( message, throwable );
  +        m_frame.getLogger().warn( message, throwable );
       }
   
       /**
  @@ -295,7 +281,7 @@
        */
       public boolean isInfoEnabled()
       {
  -        return m_logger.isWarnEnabled();
  +        return m_frame.getLogger().isWarnEnabled();
       }
   
       /**
  @@ -305,7 +291,7 @@
        */
       public void warn( final String message )
       {
  -        m_logger.error( message );
  +        m_frame.getLogger().error( message );
       }
   
       /**
  @@ -316,7 +302,7 @@
        */
       public void warn( final String message, final Throwable throwable )
       {
  -        m_logger.error( message, throwable );
  +        m_frame.getLogger().error( message, throwable );
       }
   
       /**
  @@ -326,7 +312,7 @@
        */
       public boolean isWarnEnabled()
       {
  -        return m_logger.isErrorEnabled();
  +        return m_frame.getLogger().isErrorEnabled();
       }
   
       /**
  @@ -336,7 +322,7 @@
        */
       public void error( final String message )
       {
  -        m_logger.fatalError( message );
  +        m_frame.getLogger().fatalError( message );
       }
   
       /**
  @@ -347,7 +333,7 @@
        */
       public void error( final String message, final Throwable throwable )
       {
  -        m_logger.fatalError( message, throwable );
  +        m_frame.getLogger().fatalError( message, throwable );
       }
   
       /**
  @@ -357,6 +343,6 @@
        */
       public boolean isErrorEnabled()
       {
  -        return m_logger.isFatalErrorEnabled();
  +        return m_frame.getLogger().isFatalErrorEnabled();
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message