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/interfaces/workspace Workspace.java
Date Fri, 07 Jun 2002 05:48:20 GMT
donaldp     2002/06/06 22:48:20

  Modified:    antlib/src/java/org/apache/antlib/project
                        AbstractWorkspaceTask.java
               container/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java Resources.properties
               container/src/java/org/apache/myrmidon/components/builder
                        DefaultProject.java
               container/src/java/org/apache/myrmidon/components/workspace
                        DefaultWorkspace.java Resources.properties
               container/src/java/org/apache/myrmidon/interfaces/model
                        TargetMetaData.java
               container/src/java/org/apache/myrmidon/interfaces/workspace
                        Workspace.java
  Log:
  Start process of making workspace the task interface to execution, Module the external interface
and everything else internal implementation details
  
  Revision  Changes    Path
  1.4       +3 -2      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AbstractWorkspaceTask.java
  
  Index: AbstractWorkspaceTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AbstractWorkspaceTask.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractWorkspaceTask.java	2 Jun 2002 14:08:05 -0000	1.3
  +++ AbstractWorkspaceTask.java	7 Jun 2002 05:48:20 -0000	1.4
  @@ -19,7 +19,7 @@
    * An abstract class used to execute Ant files within same workspace.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.3 $ $Date: 2002/06/02 14:08:05 $
  + * @version $Revision: 1.4 $ $Date: 2002/06/07 05:48:20 $
    */
   abstract class AbstractWorkspaceTask
       extends AbstractContainerTask
  @@ -61,7 +61,8 @@
       {
           final Workspace workspace =
               (Workspace)getContext().getService( Workspace.class );
  -        workspace.executeTarget( target );
  +        final String uri = target.getProject().getURI();
  +        workspace.execute( uri, target.getName() );
       }
   
       /**
  
  
  
  1.81      +26 -4     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java
  
  Index: DefaultEmbeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java,v
  retrieving revision 1.80
  retrieving revision 1.81
  diff -u -r1.80 -r1.81
  --- DefaultEmbeddor.java	2 Jun 2002 14:08:06 -0000	1.80
  +++ DefaultEmbeddor.java	7 Jun 2002 05:48:20 -0000	1.81
  @@ -9,6 +9,7 @@
   
   import java.io.File;
   import java.util.ArrayList;
  +import java.util.Arrays;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  @@ -64,7 +65,7 @@
    * Instantiate this to embed inside other applications.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.80 $ $Date: 2002/06/02 14:08:06 $
  + * @version $Revision: 1.81 $ $Date: 2002/06/07 05:48:20 $
    */
   public class DefaultEmbeddor
       extends AbstractLogEnabled
  @@ -207,7 +208,7 @@
   
           // create the root execution frame
           m_rootProps = createBaseStore( m_serviceManager );
  -        m_rootFrame = new DefaultExecutionFrame( "", new File("."), m_serviceManager );
  +        m_rootFrame = new DefaultExecutionFrame( "", new File( "." ), m_serviceManager
);
           m_rootContext = new DefaultTaskContext( m_rootFrame, "<init>", "<init>"
);
       }
   
  @@ -216,15 +217,36 @@
       {
           // Deploy all types found in the container classpath
           final ClassLoader containerClassLoader = getClass().getClassLoader();
  -        final Library containerLib = m_libraryManager.createLibrary( containerClassLoader
);
  -        final TypeLibraryDeployer containerTypeDeployer = m_deployer.createDeployer( containerLib,
CONTAINER_TYPE_NAMESPACE );
  +        final Library containerLib =
  +            m_libraryManager.createLibrary( containerClassLoader );
  +        final TypeLibraryDeployer containerTypeDeployer =
  +            m_deployer.createDeployer( containerLib, CONTAINER_TYPE_NAMESPACE );
           containerTypeDeployer.deployAll();
   
           // Deploy all core type libraries in the lib directory
           final Library[] coreLibs = m_libraryManager.getCoreLibraries();
  +
  +        if( getLogger().isInfoEnabled() )
  +        {
  +            final String message =
  +                REZ.getString( "embeddor.corelib-count.notice",
  +                               new Integer( coreLibs.length ) );
  +            getLogger().info( message );
  +        }
  +
           for( int i = 0; i < coreLibs.length; i++ )
           {
               final Library library = coreLibs[ i ];
  +
  +            if( getLogger().isDebugEnabled() )
  +            {
  +                final String message =
  +                    REZ.getString( "embeddor.corelib-deployed.notice",
  +                                   library.getName(),
  +                                   Arrays.asList( library.getClassPath() ) );
  +                getLogger().debug( message );
  +            }
  +
               final TypeLibraryDeployer libDeployer = m_deployer.createDeployer( library,
library.getName() );
               libDeployer.deployAll();
           }
  
  
  
  1.6       +4 -1      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/Resources.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Resources.properties	3 Apr 2002 10:58:19 -0000	1.5
  +++ Resources.properties	7 Jun 2002 05:48:20 -0000	1.6
  @@ -3,4 +3,7 @@
   no-instantiate.error=Error instantiating class for {0} {1}.
   no-class.error=Could not find the class for {0} ({1}).
   bad-filename.error=Unable to retrieve filename for file {0}.
  -create-project.error=Could not load the project definition from {0}.
  \ No newline at end of file
  +create-project.error=Could not load the project definition from {0}.
  +
  +embeddor.corelib-count.notice=Deploying {0} core librarys.
  +embeddor.corelib-deployed.notice=Deploying Library named "{0}" with ClassPath={1}.
  \ No newline at end of file
  
  
  
  1.20      +3 -2      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProject.java
  
  Index: DefaultProject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProject.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- DefaultProject.java	7 Jun 2002 02:46:31 -0000	1.19
  +++ DefaultProject.java	7 Jun 2002 05:48:20 -0000	1.20
  @@ -28,7 +28,7 @@
    * Default project implementation.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.19 $ $Date: 2002/06/07 02:46:31 $
  + * @version $Revision: 1.20 $ $Date: 2002/06/07 05:48:20 $
    */
   public class DefaultProject
       extends AbstractLogEnabled
  @@ -244,7 +244,8 @@
           throws TaskException
       {
           final Workspace workspace = createWorkspace( frame );
  -        workspace.executeTarget( target );
  +        final String uri = ((Target)target).getProject().getURI();
  +        workspace.execute( uri, target.getName() );
       }
   
       /**
  
  
  
  1.74      +76 -51    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.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- DefaultWorkspace.java	2 Jun 2002 14:08:06 -0000	1.73
  +++ DefaultWorkspace.java	7 Jun 2002 05:48:20 -0000	1.74
  @@ -22,9 +22,9 @@
   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;
   import org.apache.myrmidon.interfaces.executor.Executor;
  -import org.apache.myrmidon.interfaces.model.TargetMetaData;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
   import org.apache.myrmidon.interfaces.oldmodel.Target;
   import org.apache.myrmidon.interfaces.service.ScopedService;
  @@ -36,7 +36,7 @@
    * This is the default implementation of Workspace.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.73 $ $Date: 2002/06/02 14:08:06 $
  + * @version $Revision: 1.74 $ $Date: 2002/06/07 05:48:20 $
    * @todo Merge m_entries and m_projects
    */
   public class DefaultWorkspace
  @@ -62,15 +62,17 @@
           m_frame = frame;
       }
   
  -    /**
  -     * Executes a target.
  -     */
  -    public void executeTarget( final TargetMetaData metaData )
  +    public void execute( final String projectURI,
  +                         final String targetName )
           throws TaskException
       {
  -        final Target target = (Target)metaData;
  -        final Project project = target.getProject();
  -        final ProjectEntry entry = getProjectEntry( project, m_frame );
  +        final ProjectEntry entry = getProjectEntry( projectURI );
  +        final Project project = entry.getProject();
  +        Target target = project.getTarget( targetName );
  +        if( null == target )
  +        {
  +            target = project.getDefaultTarget();
  +        }
           executeTarget( entry, target );
       }
   
  @@ -79,36 +81,43 @@
        */
       private ExecutionFrame createExecutionFrame( final Project project,
                                                    final ExecutionFrame frame )
  -        throws Exception
  +        throws TaskException
       {
  -        // TODO - move all this stuff to a customised ServiceManager, and call
  -        // from ExecutionFrame.createChildFrame( ..., true ).
  +        try
  +        {
  +            // TODO - move all this stuff to a customised ServiceManager, and call
  +            // from ExecutionFrame.createChildFrame( ..., true ).
   
  -        final DefaultServiceManager serviceManager =
  -            new DefaultServiceManager( frame.getServiceManager() );
  +            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 );
  -
  -        // 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 );
  -        serviceManager.put( Project.ROLE, project );
  -
  -        return frame.createChildFrame( project.getMetaData().getName(),
  -                                       project.getBaseDirectory(),
  -                                       serviceManager,
  -                                       true );
  +            // 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 );
  +
  +            // 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 );
  +            serviceManager.put( Project.ROLE, project );
  +
  +            return frame.createChildFrame( project.getMetaData().getName(),
  +                                           project.getBaseDirectory(),
  +                                           serviceManager,
  +                                           true );
  +        }
  +        catch( final Exception e )
  +        {
  +            throw new TaskException( e.getMessage(), e );
  +        }
       }
   
       /**
  @@ -164,28 +173,44 @@
           serviceManager.put( role, childService );
       }
   
  -    private ProjectEntry getProjectEntry( final Project project,
  -                                          final ExecutionFrame frame )
  +    private ProjectEntry getProjectEntry( final String projectURI )
           throws TaskException
       {
  -        ProjectEntry entry = (ProjectEntry)m_entries.get( project.getURI() );
  +        ProjectEntry entry = (ProjectEntry)m_entries.get( projectURI );
  +
           if( null == entry )
           {
  -            try
  -            {
  -                final ExecutionFrame projectFrame =
  -                    createExecutionFrame( project, frame );
  -                entry = new ProjectEntry( project, projectFrame );
  -                m_entries.put( project.getURI(), entry );
  -            }
  -            catch( Exception e )
  -            {
  -                final String message = REZ.getString( "bad-frame.error" );
  -                throw new TaskException( message, e );
  -            }
  +            final Project project = createProject( projectURI );
  +            entry = createProjectEntry( project, m_frame );
  +            m_entries.put( project.getURI(), entry );
           }
   
           return entry;
  +    }
  +
  +    private Project createProject( final String projectURI )
  +        throws TaskException
  +    {
  +        try
  +        {
  +            final ServiceManager serviceManager = m_frame.getServiceManager();
  +            final Embeddor embeddor = (Embeddor)serviceManager.lookup( Embeddor.ROLE );
  +            return embeddor.createProject( projectURI, null, null );
  +        }
  +        catch( final Exception e )
  +        {
  +            final String message =
  +                REZ.getString( "nobuild-project.error", projectURI );
  +            throw new TaskException( message, e );
  +        }
  +    }
  +
  +    private ProjectEntry createProjectEntry( final Project project, final ExecutionFrame
frame )
  +        throws TaskException
  +    {
  +        final ExecutionFrame projectFrame =
  +            createExecutionFrame( project, frame );
  +        return new ProjectEntry( project, projectFrame );
       }
   
       /**
  
  
  
  1.15      +1 -0      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/Resources.properties,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Resources.properties	2 Jun 2002 14:08:06 -0000	1.14
  +++ Resources.properties	7 Jun 2002 05:48:20 -0000	1.15
  @@ -1,4 +1,5 @@
   no-deploy.error=Error deploying type library {0}.
  +nobuild-project.error=Error creating project file at {0}.
   bad-deployer-config.error=Error configuring deployer.
   bad-frame.error=Error setting up ExecutionFrame.
   no-project.error=Project {0} not found.
  
  
  
  1.2       +1 -2      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model/TargetMetaData.java
  
  Index: TargetMetaData.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model/TargetMetaData.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TargetMetaData.java	28 Apr 2002 05:35:53 -0000	1.1
  +++ TargetMetaData.java	7 Jun 2002 05:48:20 -0000	1.2
  @@ -19,9 +19,8 @@
    * is just for organizational purposes and human consumption
    * rather than implying any underlying physical structure.</p>
    *
  - *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/28 05:35:53 $
  + * @version $Revision: 1.2 $ $Date: 2002/06/07 05:48:20 $
    */
   public interface TargetMetaData
   {
  
  
  
  1.16      +8 -4      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/workspace/Workspace.java
  
  Index: Workspace.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/workspace/Workspace.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Workspace.java	2 Jun 2002 14:08:06 -0000	1.15
  +++ Workspace.java	7 Jun 2002 05:48:20 -0000	1.16
  @@ -8,13 +8,12 @@
   package org.apache.myrmidon.interfaces.workspace;
   
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.myrmidon.interfaces.model.TargetMetaData;
   
   /**
    * This is the abstraction through which Modules are executed.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.15 $ $Date: 2002/06/02 14:08:06 $
  + * @version $Revision: 1.16 $ $Date: 2002/06/07 05:48:20 $
    */
   public interface Workspace
   {
  @@ -22,8 +21,13 @@
       String ROLE = Workspace.class.getName();
   
       /**
  -     * Executes a target.
  +     * Execute target in Project file specified by URI.
  +     * If target is null then execute the default target.
  +     *
  +     * @param projectURI the URI of Project file
  +     * @param target the target to execute, can be null
  +     * @throws TaskException if error occurs executing target.
        */
  -    void executeTarget( TargetMetaData target )
  +    void execute( String projectURI, String target )
           throws TaskException;
   }
  
  
  

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