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, 28 May 2002 02:04:14 GMT
donaldp     02/05/27 19:04:14

  Modified:    container/src/java/org/apache/myrmidon/components/workspace
                        DefaultTaskContext.java
  Log:
  Removed all the isXEnabled implementations and cleaned up internal structure a little
  
  Revision  Changes    Path
  1.50      +27 -114   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.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- DefaultTaskContext.java	24 May 2002 04:30:59 -0000	1.49
  +++ DefaultTaskContext.java	28 May 2002 02:04:14 -0000	1.50
  @@ -29,7 +29,7 @@
    * Default implementation of TaskContext.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.49 $ $Date: 2002/05/24 04:30:59 $
  + * @version $Revision: 1.50 $ $Date: 2002/05/28 02:04:14 $
    */
   public class DefaultTaskContext
       implements TaskContext
  @@ -42,6 +42,7 @@
       private final File m_baseDirectory;
       private final String m_location;
       private TaskEventManager m_eventManager;
  +    private PropertyStore m_propertyStore;
   
       /**
        * Constructor that takes adapts TaskContext to a particular frame.
  @@ -68,6 +69,7 @@
           m_baseDirectory = frame.getBaseDirectory();
           m_location = location;
           m_eventManager = (TaskEventManager)getService( TaskEventManager.class );
  +        m_propertyStore = (PropertyStore)getService( PropertyStore.class );
       }
   
       /**
  @@ -216,8 +218,7 @@
       {
           try
           {
  -            final PropertyStore store = m_frame.getPropertyStore();
  -            return store.getProperty( name );
  +            return m_propertyStore.getProperty( name );
           }
           catch( final TaskException te )
           {
  @@ -233,7 +234,7 @@
       public Map getProperties()
           throws TaskException
       {
  -        return getPropertyStore().getProperties();
  +        return m_propertyStore.getProperties();
       }
   
       /**
  @@ -245,7 +246,7 @@
       public void setProperty( final String name, final Object value )
           throws TaskException
       {
  -        getPropertyStore().setProperty( name, value );
  +        m_propertyStore.setProperty( name, value );
       }
   
       /**
  @@ -266,25 +267,7 @@
        */
       public void debug( final String message, final Throwable throwable )
       {
  -        final TaskEvent event =
  -            new TaskEvent( m_frame.getName(),
  -                           getName(),
  -                           m_location,
  -                           message,
  -                           throwable,
  -                           LogLevel.DEBUG,
  -                           0 );
  -        getEventManager().fireTaskMessage( event );
  -    }
  -
  -    /**
  -     * Determine if messages of priority "debug" will be logged.
  -     *
  -     * @return true if "debug" messages will be logged
  -     */
  -    public boolean isDebugEnabled()
  -    {
  -        return m_frame.getLogger().isDebugEnabled();
  +        fireMessage( LogLevel.DEBUG, message, throwable );
       }
   
       /**
  @@ -305,25 +288,7 @@
        */
       public void verbose( final String message, final Throwable throwable )
       {
  -        final TaskEvent event =
  -            new TaskEvent( m_frame.getName(),
  -                           getName(),
  -                           m_location,
  -                           message,
  -                           throwable,
  -                           LogLevel.VERBOSE,
  -                           0 );
  -        getEventManager().fireTaskMessage( event );
  -    }
  -
  -    /**
  -     * Determine if messages of priority "verbose" will be logged.
  -     *
  -     * @return true if "verbose" messages will be logged
  -     */
  -    public boolean isVerboseEnabled()
  -    {
  -        return m_frame.getLogger().isInfoEnabled();
  +        fireMessage( LogLevel.VERBOSE, message, throwable );
       }
   
       /**
  @@ -344,25 +309,7 @@
        */
       public void info( final String message, final Throwable throwable )
       {
  -        final TaskEvent event =
  -            new TaskEvent( m_frame.getName(),
  -                           getName(),
  -                           m_location,
  -                           message,
  -                           throwable,
  -                           LogLevel.INFO,
  -                           0 );
  -        getEventManager().fireTaskMessage( event );
  -    }
  -
  -    /**
  -     * Determine if messages of priority "info" will be logged.
  -     *
  -     * @return true if "info" messages will be logged
  -     */
  -    public boolean isInfoEnabled()
  -    {
  -        return m_frame.getLogger().isWarnEnabled();
  +        fireMessage( LogLevel.INFO, message, throwable );
       }
   
       /**
  @@ -383,25 +330,7 @@
        */
       public void warn( final String message, final Throwable throwable )
       {
  -        final TaskEvent event =
  -            new TaskEvent( m_frame.getName(),
  -                           getName(),
  -                           m_location,
  -                           message,
  -                           throwable,
  -                           LogLevel.WARN,
  -                           0 );
  -        getEventManager().fireTaskMessage( event );
  -    }
  -
  -    /**
  -     * Determine if messages of priority "warn" will be logged.
  -     *
  -     * @return true if "warn" messages will be logged
  -     */
  -    public boolean isWarnEnabled()
  -    {
  -        return m_frame.getLogger().isErrorEnabled();
  +        fireMessage( LogLevel.WARN, message, throwable );
       }
   
       /**
  @@ -422,44 +351,28 @@
        */
       public void error( final String message, final Throwable throwable )
       {
  -        final TaskEvent event =
  -            new TaskEvent( m_frame.getName(),
  -                           getName(),
  -                           m_location,
  -                           message,
  -                           throwable,
  -                           LogLevel.ERROR,
  -                           0 );
  -        getEventManager().fireTaskMessage( event );
  -    }
  -
  -    /**
  -     * Determine if messages of priority "error" will be logged.
  -     *
  -     * @return true if "error" messages will be logged
  -     */
  -    public boolean isErrorEnabled()
  -    {
  -        return m_frame.getLogger().isFatalErrorEnabled();
  -    }
  -
  -    /**
  -     * Utility method to aquire PropertyStore service.
  -     *
  -     * @return the PropertyStore service
  -     */
  -    private PropertyStore getPropertyStore()
  -    {
  -        return m_frame.getPropertyStore();
  +        fireMessage( LogLevel.ERROR, message, throwable );
       }
   
       /**
  -     * Utility method to aquire TaskEventManager service.
  +     * Fire a message originating with task.
        *
  -     * @return the TaskEventManager service
  +     * @param logLevel the log level at which to log message
  +     * @param message the message (may be null)
  +     * @param throwable the throwable (may be null)
        */
  -    private TaskEventManager getEventManager()
  +    private void fireMessage( final LogLevel logLevel,
  +                              final String message,
  +                              final Throwable throwable )
       {
  -        return m_eventManager;
  +        final TaskEvent event =
  +            new TaskEvent( m_frame.getName(),
  +                           getName(),
  +                           getLocation(),
  +                           message,
  +                           throwable,
  +                           logLevel,
  +                           0 );
  +        m_eventManager.fireTaskMessage( event );
       }
   }
  
  
  

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