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/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer DefaultConfigurerTest.java
Date Wed, 06 Mar 2002 10:09:45 GMT
donaldp     02/03/06 02:09:45

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/api
                        TaskContext.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace
                        DefaultWorkspace.java DefaultTaskContext.java
               proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer
                        DefaultConfigurerTest.java
  Log:
  Push logging methods into TaskContext.
  
  Revision  Changes    Path
  1.23      +89 -1     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java
  
  Index: TaskContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- TaskContext.java	3 Mar 2002 07:30:38 -0000	1.22
  +++ TaskContext.java	6 Mar 2002 10:09:45 -0000	1.23
  @@ -17,7 +17,7 @@
    * Unlike other APIs the Logging is provided through another interface (LogEnabled).
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.22 $ $Date: 2002/03/03 07:30:38 $
  + * @version $Revision: 1.23 $ $Date: 2002/03/06 10:09:45 $
    */
   public interface TaskContext
   {
  @@ -99,6 +99,94 @@
        */
       void setProperty( String name, Object value )
           throws TaskException;
  +
  +    /**
  +     * Log a debug message.
  +     *
  +     * @param message the message
  +     */
  +    void debug( String message );
  +
  +    /**
  +     * Log a debug message.
  +     *
  +     * @param message the message
  +     * @param throwable the throwable
  +     */
  +    void debug( String message, Throwable throwable );
  +
  +    /**
  +     * Determine if messages of priority "debug" will be logged.
  +     *
  +     * @return true if "debug" messages will be logged
  +     */
  +    boolean isDebugEnabled();
  +
  +    /**
  +     * Log a info message.
  +     *
  +     * @param message the message
  +     */
  +    void info( String message );
  +
  +    /**
  +     * Log a info message.
  +     *
  +     * @param message the message
  +     * @param throwable the throwable
  +     */
  +    void info( String message, Throwable throwable );
  +
  +    /**
  +     * Determine if messages of priority "info" will be logged.
  +     *
  +     * @return true if "info" messages will be logged
  +     */
  +    boolean isInfoEnabled();
  +
  +    /**
  +     * Log a warn message.
  +     *
  +     * @param message the message
  +     */
  +    void warn( String message );
  +
  +    /**
  +     * Log a warn message.
  +     *
  +     * @param message the message
  +     * @param throwable the throwable
  +     */
  +    void warn( String message, Throwable throwable );
  +
  +    /**
  +     * Determine if messages of priority "warn" will be logged.
  +     *
  +     * @return true if "warn" messages will be logged
  +     */
  +    boolean isWarnEnabled();
  +
  +    /**
  +     * Log a error message.
  +     *
  +     * @param message the message
  +     */
  +    void error( String message );
  +
  +    /**
  +     * Log a error message.
  +     *
  +     * @param message the message
  +     * @param throwable the throwable
  +     */
  +    void error( String message, Throwable throwable );
  +
  +    /**
  +     * Determine if messages of priority "error" will be logged.
  +     *
  +     * @return true if "error" messages will be logged
  +     */
  +    boolean isErrorEnabled();
   
       /**
        * Create a Child Context.
  
  
  
  1.30      +7 -7      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java
  
  Index: DefaultWorkspace.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- DefaultWorkspace.java	4 Mar 2002 04:23:37 -0000	1.29
  +++ DefaultWorkspace.java	6 Mar 2002 10:09:45 -0000	1.30
  @@ -45,7 +45,7 @@
    * This is the default implementation of Workspace.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.29 $ $Date: 2002/03/04 04:23:37 $
  + * @version $Revision: 1.30 $ $Date: 2002/03/06 10:09:45 $
    */
   public class DefaultWorkspace
       extends AbstractLogEnabled
  @@ -142,7 +142,7 @@
       private TaskContext createBaseContext()
           throws TaskException
       {
  -        final TaskContext context = new DefaultTaskContext();
  +        final TaskContext context = new DefaultTaskContext( null, null, null );
   
           final String[] names = m_parameters.getNames();
           for( int i = 0; i < names.length; i++ )
  @@ -256,15 +256,15 @@
               serviceManager.put( Project.ROLE + "/" + name, other );
           }
   
  -        // Create and configure the context
  -        final DefaultTaskContext context =
  -            new DefaultTaskContext( m_baseContext, serviceManager );
  -        context.setProperty( TaskContext.BASE_DIRECTORY, project.getBaseDirectory() );
  -
           // Create a logger
           final Logger logger =
               new LogKitLogger( m_hierarchy.getLoggerFor( "project" + m_projectID ) );
           m_projectID++;
  +
  +        // Create and configure the context
  +        final DefaultTaskContext context =
  +            new DefaultTaskContext( m_baseContext, serviceManager, logger );
  +        context.setProperty( TaskContext.BASE_DIRECTORY, project.getBaseDirectory() );
   
           final DefaultExecutionFrame frame = new DefaultExecutionFrame( logger, context,
typeManager );
   
  
  
  
  1.18      +136 -55   jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java
  
  Index: DefaultTaskContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DefaultTaskContext.java	1 Mar 2002 10:34:20 -0000	1.17
  +++ DefaultTaskContext.java	6 Mar 2002 10:09:45 -0000	1.18
  @@ -13,6 +13,7 @@
   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;
  @@ -22,7 +23,7 @@
    * Default implementation of TaskContext.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.17 $ $Date: 2002/03/01 10:34:20 $
  + * @version $Revision: 1.18 $ $Date: 2002/03/06 10:09:45 $
    */
   public class DefaultTaskContext
       implements TaskContext
  @@ -33,64 +34,18 @@
       private final Map m_contextData = new Hashtable();
       private final TaskContext m_parent;
       private ServiceManager m_serviceManager;
  -
  -    /**
  -     * Constructor for Context with no parent contexts.
  -     */
  -    public DefaultTaskContext()
  -    {
  -        this( null, null );
  -    }
  -
  -    /**
  -     * Constructor that specified parent context.
  -     */
  -    public DefaultTaskContext( final TaskContext parent )
  -    {
  -        this( parent, null );
  -    }
  -
  -    /**
  -     * Constructor that specifies the service directory for context.
  -     */
  -    public DefaultTaskContext( final ServiceManager serviceManager )
  -    {
  -        this( null, serviceManager );
  -    }
  +    private Logger m_logger;
   
       /**
        * Constructor that takes both parent context and a service directory.
        */
       public DefaultTaskContext( final TaskContext parent,
  -                               final ServiceManager serviceManager )
  +                               final ServiceManager serviceManager,
  +                               final Logger logger )
       {
           m_parent = parent;
           m_serviceManager = serviceManager;
  -    }
  -
  -    /**
  -     * Retrieve a property.
  -     */
  -    private Object get( final String key )
  -    {
  -        final Object data = m_contextData.get( key );
  -        if( null != data )
  -        {
  -            //            if( data instanceof Resolvable )
  -            //            {
  -            //                return ( (Resolvable)data ).resolve( this );
  -            //            }
  -            return data;
  -        }
  -
  -        // If data was null, check the parent
  -        if( null == m_parent )
  -        {
  -            // There was no parent, and no data
  -            return null;
  -        }
  -
  -        return m_parent.getProperty( key );
  +        m_logger = logger;
       }
   
       /**
  @@ -100,7 +55,7 @@
        */
       public String getName()
       {
  -        return (String)get( NAME );
  +        return (String)m_contextData.get( NAME );
       }
   
       /**
  @@ -110,7 +65,7 @@
        */
       public File getBaseDirectory()
       {
  -        return (File)get( BASE_DIRECTORY );
  +        return (File)m_contextData.get( BASE_DIRECTORY );
       }
   
       /**
  @@ -206,7 +161,7 @@
        */
       public Object getProperty( final String name )
       {
  -        return get( name );
  +        return m_contextData.get( name );
       }
   
       /**
  @@ -233,6 +188,130 @@
       }
   
       /**
  +     * Log a debug message.
  +     *
  +     * @param message the message
  +     */
  +    public void debug( final String message )
  +    {
  +        m_logger.debug( message );
  +    }
  +
  +    /**
  +     * Log a debug message.
  +     *
  +     * @param message the message
  +     * @param throwable the throwable
  +     */
  +    public void debug( final String message, final Throwable throwable )
  +    {
  +        m_logger.debug( message, throwable );
  +    }
  +
  +    /**
  +     * Determine if messages of priority "debug" will be logged.
  +     *
  +     * @return true if "debug" messages will be logged
  +     */
  +    public boolean isDebugEnabled()
  +    {
  +        return m_logger.isDebugEnabled();
  +    }
  +
  +    /**
  +     * Log a info message.
  +     *
  +     * @param message the message
  +     */
  +    public void info( final String message )
  +    {
  +        m_logger.info( message );
  +    }
  +
  +    /**
  +     * Log a info message.
  +     *
  +     * @param message the message
  +     * @param throwable the throwable
  +     */
  +    public void info( final String message, final Throwable throwable )
  +    {
  +        m_logger.info( message, throwable );
  +    }
  +
  +    /**
  +     * Determine if messages of priority "info" will be logged.
  +     *
  +     * @return true if "info" messages will be logged
  +     */
  +    public boolean isInfoEnabled()
  +    {
  +        return m_logger.isInfoEnabled();
  +    }
  +
  +    /**
  +     * Log a warn message.
  +     *
  +     * @param message the message
  +     */
  +    public void warn( final String message )
  +    {
  +        m_logger.warn( message );
  +    }
  +
  +    /**
  +     * Log a warn message.
  +     *
  +     * @param message the message
  +     * @param throwable the throwable
  +     */
  +    public void warn( final String message, final Throwable throwable )
  +    {
  +        m_logger.warn( message, throwable );
  +    }
  +
  +    /**
  +     * Determine if messages of priority "warn" will be logged.
  +     *
  +     * @return true if "warn" messages will be logged
  +     */
  +    public boolean isWarnEnabled()
  +    {
  +        return m_logger.isWarnEnabled();
  +    }
  +
  +    /**
  +     * Log a error message.
  +     *
  +     * @param message the message
  +     */
  +    public void error( final String message )
  +    {
  +        m_logger.error( message );
  +    }
  +
  +    /**
  +     * Log a error message.
  +     *
  +     * @param message the message
  +     * @param throwable the throwable
  +     */
  +    public void error( final String message, final Throwable throwable )
  +    {
  +        m_logger.error( message, throwable );
  +    }
  +
  +    /**
  +     * Determine if messages of priority "error" will be logged.
  +     *
  +     * @return true if "error" messages will be logged
  +     */
  +    public boolean isErrorEnabled()
  +    {
  +        return m_logger.isErrorEnabled();
  +    }
  +
  +    /**
        * Create a Child Context.
        * This allows separate hierarchly contexts to be easily constructed.
        *
  @@ -243,7 +322,9 @@
       public TaskContext createSubContext( final String name )
           throws TaskException
       {
  -        final DefaultTaskContext context = new DefaultTaskContext( this );
  +        final Logger logger = m_logger.getChildLogger( name );
  +        final DefaultTaskContext context =
  +            new DefaultTaskContext( this, m_serviceManager, logger );
   
           context.setProperty( TaskContext.NAME, getName() + "." + name );
           context.setProperty( TaskContext.BASE_DIRECTORY, getBaseDirectory() );
  
  
  
  1.20      +1 -1      jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java
  
  Index: DefaultConfigurerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- DefaultConfigurerTest.java	6 Mar 2002 09:48:28 -0000	1.19
  +++ DefaultConfigurerTest.java	6 Mar 2002 10:09:45 -0000	1.20
  @@ -75,7 +75,7 @@
           m_configurer = (Configurer)getServiceManager().lookup( Configurer.ROLE );
   
           // Setup a context
  -        m_context = new DefaultTaskContext();
  +        m_context = new DefaultTaskContext( null, getServiceManager(), getLogger() );
           final File baseDir = new File( "." ).getAbsoluteFile();
           m_context.setProperty( TaskContext.BASE_DIRECTORY, baseDir );
       }
  
  
  

--
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