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/java/org/apache/myrmidon/components/aspect AspectManager.java DefaultAspectManager.java
Date Mon, 04 Jun 2001 12:45:33 GMT
donaldp     01/06/04 05:45:33

  Added:       proposal/myrmidon/src/java/org/apache/myrmidon/components/aspect
                        AspectManager.java DefaultAspectManager.java
  Log:
  First sweep of aspect manager.
  
  Revision  Changes    Path
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/aspect/AspectManager.java
  
  Index: AspectManager.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.myrmidon.components.aspect;
  
  import org.apache.myrmidon.aspects.AspectHandler;
  import org.apache.avalon.framework.component.Component;
  
  /**
   * Manage and propogate Aspects.
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public interface AspectManager
      extends Component, AspectHandler
  {
      String ROLE = "org.apache.myrmidon.components.aspect.AspectManager";
  
      void addAspectHandler( AspectHandler handler );
      void removeAspectHandler( AspectHandler handler );
  }
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/aspect/DefaultAspectManager.java
  
  Index: DefaultAspectManager.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.myrmidon.components.aspect;
  
  import java.util.ArrayList;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.log.Logger;
  import org.apache.myrmidon.api.Task;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.aspects.AspectHandler;
  
  /**
   * Manage and propogate Aspects.
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class DefaultAspectManager
      implements AspectManager
  {
      private ArrayList            m_aspectCopy  = new ArrayList();
      private AspectHandler[]      m_aspects     = new AspectHandler[ 0 ];
  
      public synchronized void addAspectHandler( final AspectHandler handler )
      {
          m_aspectCopy.add( handler );
          m_aspects = (AspectHandler[])m_aspectCopy.toArray( m_aspects );
      }
  
      public synchronized void removeAspectHandler( final AspectHandler handler )
      {
          m_aspectCopy.remove( handler );
          m_aspects = (AspectHandler[])m_aspectCopy.toArray( m_aspects );
      }
  
      public Configuration preCreate( final Configuration configuration )
          throws TaskException
      {
          Configuration model = configuration;
  
          final AspectHandler[] aspects = m_aspects;
          for( int i = 0; i < aspects.length; i++ )
          {
              model = aspects[ i ].preCreate( model );
          }
  
          return model;
      }
  
      public void postCreate( final Task task )
          throws TaskException
      {
          final AspectHandler[] aspects = m_aspects;
          for( int i = 0; i < aspects.length; i++ )
          {
              aspects[ i ].postCreate( task );
          }
      }
  
      public void preLoggable( final Logger logger )
          throws TaskException
      {
          final AspectHandler[] aspects = m_aspects;
          for( int i = 0; i < aspects.length; i++ )
          {
              aspects[ i ].preLoggable( logger );
          }
      }
  
      public void preConfigure()
          throws TaskException
      {
          final AspectHandler[] aspects = m_aspects;
          for( int i = 0; i < aspects.length; i++ )
          {
              aspects[ i ].preConfigure();
          }
      }
  
      public void preExecute()
          throws TaskException
      {
          final AspectHandler[] aspects = m_aspects;
          for( int i = 0; i < aspects.length; i++ )
          {
              aspects[ i ].preExecute();
          }
      }
  
      public void preDestroy()
          throws TaskException
      {
          final AspectHandler[] aspects = m_aspects;
          for( int i = 0; i < aspects.length; i++ )
          {
              aspects[ i ].preDestroy();
          }
      }
  
      public boolean error( final TaskException te )
          throws TaskException
      {
          final AspectHandler[] aspects = m_aspects;
          for( int i = 0; i < aspects.length; i++ )
          {
              if( true == aspects[ i ].error( te ) )
              {
                  return true;
              }
          }
  
          return false;
      }
  }
  
  
  

Mime
View raw message