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 Thu, 20 Jun 2002 07:12:53 GMT
donaldp     2002/06/20 00:12:53

  Modified:    container/src/java/org/apache/myrmidon/components/workspace
                        DefaultWorkspace.java
  Log:
  Made ExecutionFrame.lookup() throw a TaskException rather than a ServiceException
  
  Store ProjectEntrys in the root PropertyStore
  
  Revision  Changes    Path
  1.91      +38 -59    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.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- DefaultWorkspace.java	20 Jun 2002 06:01:00 -0000	1.90
  +++ DefaultWorkspace.java	20 Jun 2002 07:12:53 -0000	1.91
  @@ -7,6 +7,7 @@
    */
   package org.apache.myrmidon.components.workspace;
   
  +import java.io.File;
   import java.util.Collection;
   import java.util.HashMap;
   import java.util.Iterator;
  @@ -16,11 +17,9 @@
   import org.apache.avalon.framework.container.ContainerUtil;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.service.DefaultServiceManager;
  -import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.api.metadata.ModelElement;
  -import org.apache.myrmidon.interfaces.configurer.Configurer;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.embeddor.Embeddor;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
  @@ -31,7 +30,6 @@
   import org.apache.myrmidon.interfaces.property.PropertyStore;
   import org.apache.myrmidon.interfaces.service.ScopedService;
   import org.apache.myrmidon.interfaces.type.TypeManager;
  -import org.apache.myrmidon.interfaces.type.TypeRegistry;
   import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
   import org.apache.myrmidon.interfaces.workspace.Workspace;
   
  @@ -48,9 +46,6 @@
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultWorkspace.class );
   
  -    /** A map from Project uri -> ProjectEntry for that project. */
  -    private HashMap m_entries = new HashMap();
  -
       /**
        * The root execution frame.
        */
  @@ -68,7 +63,7 @@
                            final String targetName )
           throws TaskException
       {
  -        final ProjectEntry entry = getProjectEntry( descriptor );
  +        final ProjectEntry entry = getProjectEntry( descriptor, m_frame );
           final Project project = entry.getProject();
   
           // First execute the implicit target.
  @@ -145,32 +140,25 @@
               // TODO - move all this stuff to a customised ServiceManager, and call
               // from ExecutionFrame.createChildFrame( ..., true ).
   
  +            // Add child services, for the scoped services.
  +            final Map services = new HashMap();
  +            addChildService( TypeManager.ROLE, frame, services );
  +            addChildService( Deployer.ROLE, frame, services );
  +
               final DefaultServiceManager serviceManager =
                   new DefaultServiceManager( frame.getServiceManager() );
   
  -            // Add child services, for the scoped services.
  -            final Map scopedServices = new HashMap();
  -            addChildService( TypeManager.ROLE, serviceManager, scopedServices );
  -            addChildService( TypeRegistry.ROLE, serviceManager, scopedServices );
  -            addChildService( Deployer.ROLE, serviceManager, scopedServices );
  -            addChildService( Configurer.ROLE, serviceManager, scopedServices );
  -            setupServices( scopedServices.values(), serviceManager );
  +            setupServices( services.values(), serviceManager );
   
               // TODO - Add child role manager and configurer
   
               // TODO - we never dispose of these services.  That's bad
  -
  -            //We need to place projects and ProjectManager
  -            //in ServiceManager so as to support project-local call()
  -            // TODO - add project to properties, not services
               serviceManager.put( Workspace.ROLE, this );
   
  -            //TODO: add to
  +            final String projectName = project.getProjectName();
  +            final File baseDirectory = project.getBaseDirectory();
               final ExecutionFrame childFrame =
  -                frame.createChildFrame( project.getProjectName(),
  -                                        project.getBaseDirectory(),
  -                                        serviceManager,
  -                                        true );
  +                frame.createChildFrame( projectName, baseDirectory, serviceManager, true
);
   
               final PropertyStore propertyStore =
                   (PropertyStore)childFrame.lookup( PropertyStore.ROLE );
  @@ -179,9 +167,9 @@
               final ProjectRef[] refs = project.getProjectRefs();
               for( int i = 0; i < refs.length; i++ )
               {
  -                ProjectRef ref = refs[ i ];
  -                propertyStore.setProperty( ProjectDescriptor.KEY + "-" + ref.getName(),
  -                                           ref.getProject() );
  +                final ProjectRef ref = refs[ i ];
  +                final String key = ProjectDescriptor.KEY + "-" + ref.getName();
  +                propertyStore.setProperty( key, ref.getProject() );
               }
   
               return childFrame;
  @@ -215,18 +203,17 @@
        * Creates a child service for a service, if the specified service is a
        * scoped service.
        * @param role The service to create a child for.
  -     * @param serviceManager The service manager to add the child to.
        * @param scopedServices A map tracking the services for which a child
        *        service has already been created.  This is to deal with service
        *        object which provide more than one service.
        */
       private void addChildService( final String role,
  -                                  final DefaultServiceManager serviceManager,
  +                                  final ExecutionFrame frame,
                                     final Map scopedServices )
           throws Exception
       {
           // Lookup the service, and skip it if it is not a scoped service
  -        final Object service = serviceManager.lookup( role );
  +        final Object service = frame.lookup( role );
           if( !( service instanceof ScopedService ) )
           {
               return;
  @@ -240,20 +227,27 @@
               childService = ( (ScopedService)service ).createChildService();
               scopedServices.put( service, childService );
           }
  -
  -        // Add child to the service manager
  -        serviceManager.put( role, childService );
       }
   
  -    private ProjectEntry getProjectEntry( final ProjectDescriptor descriptor )
  +    private ProjectEntry getProjectEntry( final ProjectDescriptor descriptor,
  +                                          final ExecutionFrame frame )
           throws TaskException
       {
  -        ProjectEntry entry = (ProjectEntry)m_entries.get( descriptor );
  -        if( null == entry )
  +        final PropertyStore propertyStore =
  +            (PropertyStore)frame.lookup( PropertyStore.ROLE );
  +
  +        final String key = ProjectEntry.KEY + "-" + descriptor.toKey();
  +
  +        ProjectEntry entry = null;
  +        try
  +        {
  +            entry = (ProjectEntry)propertyStore.getProperty( key );
  +        }
  +        catch( TaskException e )
           {
               final Project project = getProject( descriptor );
               entry = createProjectEntry( project, m_frame );
  -            m_entries.put( descriptor, entry );
  +            propertyStore.setProperty( key, entry );
           }
   
           return entry;
  @@ -263,22 +257,15 @@
           throws TaskException
       {
           final String key = Project.KEY + '-' + descriptor.toKey();
  -        try
  +        final PropertyStore propertyStore =
  +            (PropertyStore)m_frame.lookup( PropertyStore.ROLE );
  +        if( propertyStore.isPropertySet( key ) )
           {
  -            final PropertyStore propertyStore =
  -                (PropertyStore)m_frame.lookup( PropertyStore.ROLE );
  -            if( propertyStore.isPropertySet( key ) )
  -            {
  -                return (Project)propertyStore.getProperty( key );
  -            }
  -            else
  -            {
  -                return createProject( descriptor );
  -            }
  +            return (Project)propertyStore.getProperty( key );
           }
  -        catch( final ServiceException se )
  +        else
           {
  -            throw new TaskException( se.getMessage(), se );
  +            return createProject( descriptor );
           }
       }
   
  @@ -368,15 +355,7 @@
           final ModelElement targetModel = target.getModel();
           final ExecutionFrame frame =
               entry.getFrame().createChildFrame( target.getName(), null, null, false );
  -        Executor executor;
  -        try
  -        {
  -            executor = (Executor)frame.lookup( Executor.ROLE );
  -        }
  -        catch( final ServiceException se )
  -        {
  -            throw new TaskException( se.getMessage(), se );
  -        }
  +        final Executor executor = (Executor)frame.lookup( Executor.ROLE );
           executor.execute( targetModel, 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