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 DefaultWorkspace.java
Date Tue, 23 Apr 2002 12:41:00 GMT
donaldp     02/04/23 05:41:00

  Modified:    container/src/java/org/apache/myrmidon/components/workspace
                        DefaultWorkspace.java
  Log:
  Use a child frame to propogate the "context" data (ie ServiceManager, PropertyStore, EventManager,
path etc). Use a bit of an ugly hack to achieve. Will need torework this in the future.
  
  Unfortunately this means that task logging is temporarily being redirected to myrmidon logger
and not through the listener architecture.
  
  Revision  Changes    Path
  1.44      +53 -56    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java
  
  Index: DefaultWorkspace.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- DefaultWorkspace.java	23 Apr 2002 07:42:31 -0000	1.43
  +++ DefaultWorkspace.java	23 Apr 2002 12:41:00 -0000	1.44
  @@ -15,7 +15,6 @@
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.service.DefaultServiceManager;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.myrmidon.api.TaskContext;
  @@ -31,18 +30,15 @@
   import org.apache.myrmidon.interfaces.model.Project;
   import org.apache.myrmidon.interfaces.model.Target;
   import org.apache.myrmidon.interfaces.model.TypeLib;
  -import org.apache.myrmidon.interfaces.property.PropertyStore;
   import org.apache.myrmidon.interfaces.type.TypeManager;
   import org.apache.myrmidon.interfaces.workspace.Workspace;
  -import org.apache.myrmidon.interfaces.event.TaskEventManager;
   import org.apache.myrmidon.listeners.ProjectListener;
  -import org.apache.myrmidon.components.event.DefaultTaskEventManager;
   
   /**
    * This is the default implementation of Workspace.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.43 $ $Date: 2002/04/23 07:42:31 $
  + * @version $Revision: 1.44 $ $Date: 2002/04/23 12:41:00 $
    */
   public class DefaultWorkspace
       extends AbstractLogEnabled
  @@ -53,8 +49,6 @@
   
       private Executor m_executor;
       private ProjectListenerSupport m_listenerSupport = new ProjectListenerSupport();
  -    private ServiceManager m_serviceManager;
  -    private PropertyStore m_baseStore;
       private TypeManager m_typeManager;
       private Deployer m_deployer;
       private Context m_context;
  @@ -90,11 +84,10 @@
           throws Exception
       {
           m_frame = frame;
  -        m_baseStore = frame.getPropertyStore();
  -        m_serviceManager = frame.getServiceManager();
  -        m_typeManager = (TypeManager)m_serviceManager.lookup( TypeManager.ROLE );
  -        m_executor = (Executor)m_serviceManager.lookup( Executor.ROLE );
  -        m_deployer = (Deployer)m_serviceManager.lookup( Deployer.ROLE );
  +        final ServiceManager serviceManager = frame.getServiceManager();
  +        m_typeManager = (TypeManager)serviceManager.lookup( TypeManager.ROLE );
  +        m_executor = (Executor)serviceManager.lookup( Executor.ROLE );
  +        m_deployer = (Deployer)serviceManager.lookup( Deployer.ROLE );
       }
   
       public void contextualize( final Context context ) throws ContextException
  @@ -155,7 +148,8 @@
           throw new TaskException( message );
       }
   
  -    private void deployTypeLib( final Deployer deployer, final Project project )
  +    private void deployTypeLib( final Deployer deployer,
  +                                final Project project )
           throws Exception
       {
           final TypeLib[] typeLibs = project.getTypeLibs();
  @@ -163,29 +157,39 @@
           for( int i = 0; i < typeLibs.length; i++ )
           {
               final TypeLib typeLib = typeLibs[ i ];
  -            final File file = findTypeLib( typeLib.getLibrary() );
  +            deployTypeLib( deployer, typeLib );
   
  -            try
  +        }
  +    }
  +
  +    private void deployTypeLib( final Deployer deployer,
  +                                final TypeLib typeLib )
  +        throws Exception
  +    {
  +        final File file = findTypeLib( typeLib.getLibrary() );
  +
  +        try
  +        {
  +            final TypeDeployer typeDeployer = deployer.createDeployer( file );
  +            if( null == typeLib.getRole() )
               {
  -                final TypeDeployer typeDeployer = deployer.createDeployer( file );
  -                if( null == typeLib.getRole() )
  -                {
  -                    // Deploy everything in the typelib
  -                    typeDeployer.deployAll();
  -                }
  -                else
  -                {
  -                    // Deploy the specified type
  -                    typeDeployer.deployType( typeLib.getRole(), typeLib.getName() );
  -                }
  +                // Deploy everything in the typelib
  +                typeDeployer.deployAll();
               }
  -            catch( final DeploymentException de )
  +            else
               {
  -                final String message = REZ.getString( "no-deploy.error",
  -                                                      typeLib.getLibrary(), file );
  -                throw new TaskException( message, de );
  +                // Deploy the specified type
  +                typeDeployer.
  +                    deployType( typeLib.getRole(),
  +                                typeLib.getName() );
               }
           }
  +        catch( final DeploymentException de )
  +        {
  +            final String message = REZ.getString( "no-deploy.error",
  +                                                  typeLib.getLibrary(), file );
  +            throw new TaskException( message, de );
  +        }
       }
   
       /**
  @@ -194,9 +198,21 @@
       private ExecutionFrame createExecutionFrame( final Project project )
           throws Exception
       {
  -        //Create per frame ComponentManager
  +        final ExecutionFrame frame =
  +            m_frame.createChildFrame( project.getProjectName(),
  +                                      true );
  +
  +        //Set up property store indicating BaseDirectory
  +        frame.getPropertyStore().
  +            setProperty( TaskContext.BASE_DIRECTORY,
  +                         project.getBaseDirectory() );
  +
  +        //WARNING: Huge UGly hack on next line
  +        //Need to fix it up so that we are using a mutable
  +        //ServiceManager or maybe more desirably have a separate
  +        //write interface for services/eventManagers
           final DefaultServiceManager serviceManager =
  -            new DefaultServiceManager( m_serviceManager );
  +            (DefaultServiceManager)frame.getServiceManager();
   
           //Add in child type manager so each frame can register different
           //sets of tasks etc
  @@ -210,9 +226,6 @@
           final Deployer deployer = m_deployer.createChildDeployer( serviceManager );
           serviceManager.put( Deployer.ROLE, deployer );
   
  -        // Deploy the imported typelibs
  -        deployTypeLib( deployer, project );
  -
           //We need to place projects and ProjectManager
           //in ComponentManager so as to support project-local call()
           // TODO - add project to properties, not services
  @@ -220,32 +233,16 @@
           serviceManager.put( Project.ROLE, project );
   
           // Create a logger
  -        final Logger logger =
  -            new RoutingLogger( getLogger(), m_listenerSupport );
  -
  -        // Properties
  -        final PropertyStore store = m_baseStore.createChildStore( "" );
  -        store.setProperty( TaskContext.BASE_DIRECTORY, project.getBaseDirectory() );
  -
  -        /*final ExecutionFrame frame =
  -            m_frame.createChildFrame( project.getProjectName(), true );
  -
  -        frame.getPropertyStore().setProperty( TaskContext.BASE_DIRECTORY,
  -                                              project.getBaseDirectory() );
  -        */
  -
  -        final TaskEventManager eventManager = new DefaultTaskEventManager();
  -        final DefaultExecutionFrame frame =
  -            new DefaultExecutionFrame( "/",
  -                                       logger,
  -                                       store,
  -                                       serviceManager,
  -                                       eventManager );
  +        //final Logger logger =
  +        //new RoutingLogger( getLogger(), m_listenerSupport );
   
           /**
            *  @todo Should no occur but done for the time being to simplify evolution.
            */
           serviceManager.put( ExecutionFrame.ROLE, frame );
  +
  +        // Deploy the imported typelibs
  +        deployTypeLib( deployer, project );
   
           return frame;
       }
  
  
  

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