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/embeddor ExecutionFrame.java
Date Tue, 02 Jul 2002 07:40:32 GMT
donaldp     2002/07/02 00:40:32

  Modified:    container/src/test/org/apache/myrmidon/components
                        AbstractComponentTest.java
               container/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java DefaultExecutionFrame.java
               container/src/java/org/apache/myrmidon/components/workspace
                        DefaultTaskContext.java DefaultWorkspace.java
               container/src/java/org/apache/myrmidon/components/context
                        DefaultTaskContextManager.java
               container/src/java/org/apache/myrmidon/interfaces/embeddor
                        ExecutionFrame.java
  Log:
  Remove the core of ExecutionFrame so that it is just a simple facade around AnteServiceKernel.
  
  Moved partition/child context creation mamangement code to DefaultTaskContextManager.
  
  This start of simplification that will see the end of the ExecutionFrame
  
  Revision  Changes    Path
  1.54      +9 -24     jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/AbstractComponentTest.java
  
  Index: AbstractComponentTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/AbstractComponentTest.java,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- AbstractComponentTest.java	30 Jun 2002 11:09:11 -0000	1.53
  +++ AbstractComponentTest.java	2 Jul 2002 07:40:32 -0000	1.54
  @@ -29,7 +29,6 @@
   import org.apache.myrmidon.components.converter.DefaultMasterConverter;
   import org.apache.myrmidon.components.deployer.DefaultDeployer;
   import org.apache.myrmidon.components.event.DefaultTaskEventManager;
  -import org.apache.myrmidon.components.embeddor.DefaultExecutionFrame;
   import org.apache.myrmidon.components.executor.DefaultExecutor;
   import org.apache.myrmidon.components.extensions.DefaultExtensionManager;
   import org.apache.myrmidon.components.library.DefaultLibraryManager;
  @@ -38,12 +37,12 @@
   import org.apache.myrmidon.components.property.DefaultPropertyStore;
   import org.apache.myrmidon.components.service.DefaultAntServiceKernel;
   import org.apache.myrmidon.components.type.DefaultTypeManager;
  +import org.apache.myrmidon.components.workspace.DefaultTaskContext;
   import org.apache.myrmidon.interfaces.builder.ModelBuilder;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
   import org.apache.myrmidon.interfaces.converter.ConverterRegistry;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.event.TaskEventManager;
  -import org.apache.myrmidon.interfaces.embeddor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.executor.Executor;
   import org.apache.myrmidon.interfaces.extensions.ExtensionManager;
   import org.apache.myrmidon.interfaces.library.LibraryManager;
  @@ -53,8 +52,8 @@
   import org.apache.myrmidon.interfaces.role.RoleInfo;
   import org.apache.myrmidon.interfaces.role.RoleManager;
   import org.apache.myrmidon.interfaces.role.RoleRegistry;
  -import org.apache.myrmidon.interfaces.service.ServiceFactory;
   import org.apache.myrmidon.interfaces.service.AntServiceKernel;
  +import org.apache.myrmidon.interfaces.service.ServiceFactory;
   import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeManager;
   import org.apache.myrmidon.interfaces.type.TypeRegistry;
  @@ -231,7 +230,6 @@
           return (TypeManager)lookup( TypeManager.ROLE );
       }
   
  -
       /**
        * Returns the type manager.
        */
  @@ -241,34 +239,21 @@
           return (TypeRegistry)lookup( TypeRegistry.ROLE );
       }
   
  -
       /**
        * Utility method to create a task context.
        */
       protected TaskContext createContext()
           throws Exception
       {
  -        final ExecutionFrame frame = createExecutionFrame( null );
  -        return frame.createTaskContext( "test", "gen:///test:0:0" );
  -    }
  -
  -    /**
  -     * Utility method to create an execution frame.
  -     */
  -    protected ExecutionFrame createExecutionFrame( final PropertyStore props )
  -        throws Exception
  -    {
           final DefaultAntServiceKernel serviceKernel = getServiceKernel();
  -
  -        PropertyStore propStore = props;
  -        if( propStore == null )
  -        {
  -            propStore = createPropertyStore();
  -        }
  +        final PropertyStore propStore = createPropertyStore();
           serviceKernel.registerService( PropertyStore.ROLE, propStore );
   
  -        final File baseDir = getTestDirectory();
  -        return new DefaultExecutionFrame( "", baseDir, serviceKernel );
  +        return new DefaultTaskContext( "test",
  +                                       "/",
  +                                       "gen:///test:0:0",
  +                                       getTestDirectory(),
  +            serviceKernel );
       }
   
       /**
  
  
  
  1.116     +28 -14    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.115
  retrieving revision 1.116
  diff -u -r1.115 -r1.116
  --- DefaultEmbeddor.java	2 Jul 2002 02:18:09 -0000	1.115
  +++ DefaultEmbeddor.java	2 Jul 2002 07:40:32 -0000	1.116
  @@ -32,6 +32,7 @@
   import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.components.service.DefaultAntServiceKernel;
   import org.apache.myrmidon.components.service.InstantiatingServiceManager;
  +import org.apache.myrmidon.components.workspace.DefaultTaskContext;
   import org.apache.myrmidon.components.workspace.DefaultWorkspace;
   import org.apache.myrmidon.interfaces.builder.ProjectBuilder;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
  @@ -73,7 +74,6 @@
       private AntServiceKernel m_serviceKernel;
   
       private Context m_context;
  -    private ExecutionFrame m_rootFrame;
       private TaskContext m_rootContext;
       private PropertyStore m_rootProps;
   
  @@ -103,7 +103,7 @@
               (ProjectBuilder)getService( context, ProjectBuilder.class );
           /*       final TypeFactory factory = m_typeManager.getFactory( ModelBuilder.ROLE
);
                  final ModelBuilder modelBuilder =
  -                   (ModelBuilder)factory.create( project.getType() );
  +                   (ModelBuilder)factory.create( project.getName() );
                  final ModelElement model = modelBuilder.build( project.getUri() );*/
           return builder.build( project );
       }
  @@ -117,6 +117,7 @@
       {
           final DefaultAntServiceKernel serviceKernel =
               new DefaultAntServiceKernel( m_serviceKernel );
  +        serviceKernel.registerService( AntServiceKernel.ROLE, serviceKernel );
   
           // Create the property store
           final PropertyStore propStore = m_rootProps.createChildStore();
  @@ -135,16 +136,14 @@
               }
           }
   
  -        return new DefaultExecutionFrame( "",
  -                                          new File( "." ),
  -                                          serviceKernel );
  +        return new DefaultExecutionFrame( serviceKernel );
       }
   
       /**
        * Creates a task listener.
        */
       public TaskListener createListener( final ModelElement model,
  -                                       final TaskContext context )
  +                                        final TaskContext context )
           throws Exception
       {
           // Create the listener, contextualise it, and then configure it using
  @@ -196,13 +195,22 @@
   
           m_rootProps = (PropertyStore)m_serviceKernel.getService( PropertyStore.ROLE );
   
  -        m_rootFrame =
  -            new DefaultExecutionFrame( "", new File( "." ), m_serviceKernel );
  -        m_rootContext =
  -            m_rootFrame.createTaskContext( "<init>", "<init>" );
  +        setupRootContext();
  +
           setupBaseStore( m_rootProps );
       }
   
  +    private void setupRootContext()
  +        throws TaskException
  +    {
  +        m_rootContext =
  +            new DefaultTaskContext( "<init>",
  +                                    "",
  +                                    "<init>",
  +                                    new File( "." ),
  +                                    m_serviceKernel );
  +    }
  +
       public void start()
           throws Exception
       {
  @@ -269,7 +277,12 @@
                            final String[] targets )
           throws TaskException
       {
  -        final Workspace workspace = createWorkspace( frame );
  +        final AntServiceKernel serviceKernel =
  +            (AntServiceKernel)frame.lookup( AntServiceKernel.ROLE );
  +        final DefaultTaskContext context =
  +            new DefaultTaskContext( "", "", "", new File("."), serviceKernel );
  +
  +        final Workspace workspace = createWorkspace( context );
           if( targets == null || targets.length == 0 )
           {
               workspace.execute( project, null );
  @@ -286,11 +299,12 @@
       /**
        * Creates a new workspace to execute this project in.
        */
  -    private Workspace createWorkspace( final ExecutionFrame frame )
  +    private Workspace createWorkspace( final TaskContext context )
  +        throws TaskException
       {
           final DefaultWorkspace workspace = new DefaultWorkspace();
           setupLogger( workspace );
  -        workspace.setFrame( frame );
  +        workspace.setTaskContext( context );
           return workspace;
       }
   
  
  
  
  1.2       +2 -104    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/DefaultExecutionFrame.java
  
  Index: DefaultExecutionFrame.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/DefaultExecutionFrame.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultExecutionFrame.java	30 Jun 2002 10:49:40 -0000	1.1
  +++ DefaultExecutionFrame.java	2 Jul 2002 07:40:32 -0000	1.2
  @@ -7,19 +7,10 @@
    */
   package org.apache.myrmidon.components.embeddor;
   
  -import java.io.File;
   import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.myrmidon.components.workspace.DefaultTaskContext;
  -import org.apache.myrmidon.interfaces.event.TaskEventManager;
   import org.apache.myrmidon.interfaces.embeddor.ExecutionFrame;
  -import org.apache.myrmidon.interfaces.property.PropertyStore;
  -import org.apache.myrmidon.interfaces.role.RoleManager;
  -import org.apache.myrmidon.interfaces.role.RoleRegistry;
   import org.apache.myrmidon.interfaces.service.AntServiceKernel;
  -import org.apache.myrmidon.interfaces.type.TypeManager;
  -import org.apache.myrmidon.interfaces.type.TypeRegistry;
   
   /**
    * Frames in which tasks are executed.
  @@ -30,16 +21,10 @@
   public class DefaultExecutionFrame
       implements ExecutionFrame
   {
  -    private final String m_name;
  -    private final File m_baseDirectory;
       private final AntServiceKernel m_serviceKernel;
   
  -    public DefaultExecutionFrame( final String name,
  -                                  final File baseDirectory,
  -                                  final AntServiceKernel serviceKernel )
  +    public DefaultExecutionFrame( final AntServiceKernel serviceKernel )
       {
  -        m_name = name;
  -        m_baseDirectory = baseDirectory;
           m_serviceKernel = serviceKernel;
       }
   
  @@ -57,92 +42,5 @@
           {
               throw new TaskException( se.getMessage(), se );
           }
  -    }
  -
  -    private Object lookup2( String role )
  -        throws TaskException
  -    {
  -        try
  -        {
  -            return m_serviceKernel.getService( role );
  -        }
  -        catch( final ServiceException se )
  -        {
  -            throw new TaskException( se.getMessage(), se );
  -        }
  -    }
  -
  -
  -    /**
  -     * Create a {@link org.apache.myrmidon.api.TaskContext} object for current frame.
  -     *
  -     * @param taskName the name of task
  -     * @param location the location of task
  -     * @return the new TaskContext
  -     */
  -    public TaskContext createTaskContext( String taskName, String location )
  -        throws TaskException
  -    {
  -        final TaskEventManager eventManager =
  -            (TaskEventManager)lookup2( TaskEventManager.ROLE );
  -        final PropertyStore propertyStore =
  -            (PropertyStore)lookup2( PropertyStore.ROLE );
  -        final AntServiceKernel serviceKernel =
  -            (AntServiceKernel)lookup2( AntServiceKernel.ROLE );
  -        return new DefaultTaskContext( this,
  -                                       taskName,
  -                                       m_name,
  -                                       location,
  -                                       m_baseDirectory,
  -                                       eventManager,
  -                                       propertyStore,
  -                                       serviceKernel );
  -
  -    }
  -
  -    public ExecutionFrame createPartition( final String name,
  -                                           final File baseDirectory )
  -    {
  -        //What an UGLY Hack!!!
  -        // TODO - we never dispose of these services.  That's bad
  -        try
  -        {
  -            final PropertyStore basePS = (PropertyStore)lookup2( PropertyStore.ROLE );
  -            final PropertyStore ps = basePS.createChildStore();
  -
  -            final TypeManager baseTM = (TypeManager)lookup2( TypeManager.ROLE );
  -            final TypeManager tm = baseTM.getChildTypeManager();
  -
  -            final AntServiceKernel baseSK = (AntServiceKernel)lookup2( AntServiceKernel.ROLE
);
  -            final AntServiceKernel sk = baseSK.createChild();
  -
  -            sk.registerService( PropertyStore.ROLE, ps );
  -            sk.registerService( AntServiceKernel.ROLE, sk );
  -            sk.registerService( RoleManager.ROLE, tm );
  -            sk.registerService( RoleRegistry.ROLE, tm );
  -            sk.registerService( TypeManager.ROLE, tm );
  -            sk.registerService( TypeRegistry.ROLE, tm );
  -
  -            return new DefaultExecutionFrame( m_name + "/" + name,
  -                                              baseDirectory,
  -                                              sk );
  -        }
  -        catch( final Exception e )
  -        {
  -            throw new IllegalStateException( e.toString() );
  -        }
  -    }
  -
  -    public ExecutionFrame createChildFrame( String name )
  -    {
  -        final String newName = m_name + "/" + name;
  -        return new DefaultExecutionFrame( newName,
  -                                          m_baseDirectory,
  -                                          m_serviceKernel );
  -    }
  -
  -    public String toString()
  -    {
  -        return "Frame: " + m_name + ",id=" + System.identityHashCode( this );
       }
   }
  
  
  
  1.63      +25 -28    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.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- DefaultTaskContext.java	30 Jun 2002 10:49:40 -0000	1.62
  +++ DefaultTaskContext.java	2 Jul 2002 07:40:32 -0000	1.63
  @@ -18,7 +18,6 @@
   import org.apache.myrmidon.api.event.LogLevel;
   import org.apache.myrmidon.api.event.TaskEvent;
   import org.apache.myrmidon.interfaces.event.TaskEventManager;
  -import org.apache.myrmidon.interfaces.embeddor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
   import org.apache.myrmidon.interfaces.property.PropertyStore;
   import org.apache.myrmidon.interfaces.service.AntServiceKernel;
  @@ -35,7 +34,6 @@
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultTaskContext.class );
   
  -    private final ExecutionFrame m_frame;
       private final String m_name;
       private final String m_path;
       private final File m_baseDirectory;
  @@ -47,20 +45,13 @@
       /**
        * Constructor that takes adapts TaskContext to a particular frame.
        */
  -    public DefaultTaskContext( final ExecutionFrame frame,
  -                               final String name,
  +    public DefaultTaskContext( final String name,
                                  final String path,
                                  final String location,
                                  final File baseDirectory,
  -                               final TaskEventManager eventManager,
  -                               final PropertyStore propertyStore,
                                  final AntServiceKernel serviceKernel )
           throws TaskException
       {
  -        if( null == frame )
  -        {
  -            throw new NullPointerException( "frame" );
  -        }
           if( null == name )
           {
               throw new NullPointerException( "name" );
  @@ -73,27 +64,26 @@
           {
               throw new NullPointerException( "location" );
           }
  -        if( null == eventManager )
  -        {
  -            throw new NullPointerException( "eventManager" );
  -        }
  -        if( null == propertyStore )
  -        {
  -            throw new NullPointerException( "propertyStore" );
  -        }
           if( null == baseDirectory )
           {
               throw new NullPointerException( "baseDirectory" );
           }
   
  -        m_frame = frame;
           m_name = name;
           m_path = path;
           m_baseDirectory = baseDirectory;
           m_location = location;
  -        m_eventManager = eventManager;
  -        m_propertyStore = propertyStore;
           m_serviceKernel = serviceKernel;
  +
  +        try
  +        {
  +            m_eventManager = (TaskEventManager)serviceKernel.getService( TaskEventManager.ROLE
);
  +            m_propertyStore = (PropertyStore)serviceKernel.getService( PropertyStore.ROLE
);
  +        }
  +        catch( ServiceException e )
  +        {
  +            throw new TaskException( e.getMessage(), e );
  +        }
       }
   
       /**
  @@ -120,6 +110,18 @@
       }
   
       /**
  +     * Return the fully qualified name of task.
  +     *
  +     * @return the fully qualified name of task
  +     * @see #getName
  +     * @see #getPath
  +     */
  +    public String getQualifiedName()
  +    {
  +        return getPath() + TaskContext.SEPARATOR + getName();
  +    }
  +
  +    /**
        * Get the location of task in physical medium.
        *
        * @return the location of task in physical medium
  @@ -153,12 +155,7 @@
       public Object getService( final Class clazz )
           throws TaskException
       {
  -        //TODO: Should not occur but done for the time being to simplify evolution.
  -        if( clazz == ExecutionFrame.class )
  -        {
  -            return m_frame;
  -        }
  -        else if( clazz == AntServiceKernel.class )
  +        if( clazz == AntServiceKernel.class )
           {
               return m_serviceKernel;
           }
  
  
  
  1.107     +32 -38    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.106
  retrieving revision 1.107
  diff -u -r1.106 -r1.107
  --- DefaultWorkspace.java	30 Jun 2002 10:49:40 -0000	1.106
  +++ DefaultWorkspace.java	2 Jul 2002 07:40:32 -0000	1.107
  @@ -16,16 +16,16 @@
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.api.metadata.ModelElement;
  +import org.apache.myrmidon.interfaces.context.TaskContextManager;
   import org.apache.myrmidon.interfaces.embeddor.Embeddor;
  -import org.apache.myrmidon.interfaces.embeddor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.executor.Executor;
   import org.apache.myrmidon.interfaces.model.Project;
  -import org.apache.myrmidon.interfaces.workspace.ProjectRefs;
   import org.apache.myrmidon.interfaces.model.Target;
   import org.apache.myrmidon.interfaces.property.PropertyStore;
  +import org.apache.myrmidon.interfaces.service.AntServiceKernel;
   import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
  +import org.apache.myrmidon.interfaces.workspace.ProjectRefs;
   import org.apache.myrmidon.interfaces.workspace.Workspace;
  -import org.apache.myrmidon.interfaces.service.AntServiceKernel;
   
   /**
    * This is the default implementation of Workspace.
  @@ -41,25 +41,31 @@
           ResourceManager.getPackageResources( DefaultWorkspace.class );
   
       /**
  -     * The root execution frame.
  +     * The root execution context.
        */
  -    private ExecutionFrame m_frame;
  +    private TaskContext m_taskContext;
   
       /**
        * Map from ProjectDescriptor to ProjectEntry for that project.
        */
       private final Map m_entries = new HashMap();
  +
       private AntServiceKernel m_serviceKernel;
   
  +    private TaskContextManager m_taskContextManager;
  +
       /**
        * Sets the root execution frame for this workspace.
        */
  -    public void setFrame( final ExecutionFrame frame )
  +    public void setTaskContext( final TaskContext taskContext )
  +        throws TaskException
       {
  -        m_frame = frame;
  +        m_taskContext = taskContext;
  +        m_taskContextManager = (TaskContextManager)taskContext.getService( TaskContextManager.class
);
  +        m_serviceKernel = (AntServiceKernel)taskContext.getService( AntServiceKernel.class
);
  +
           try
           {
  -            m_serviceKernel = (AntServiceKernel)m_frame.lookup( AntServiceKernel.ROLE );
               m_serviceKernel.registerService( Workspace.ROLE, this );
           }
           catch( Exception e )
  @@ -135,23 +141,6 @@
           return name;
       }
   
  -    /**
  -     * Creates an execution frame for a project.
  -     */
  -    private ExecutionFrame createExecutionFrame( final Project project,
  -                                                 final ExecutionFrame frame )
  -        throws TaskException
  -    {
  -        try
  -        {
  -            return frame.createPartition( project.getName(), project.getBaseDirectory()
);
  -        }
  -        catch( final Exception e )
  -        {
  -            throw new TaskException( e.getMessage(), e );
  -        }
  -    }
  -
       private ProjectEntry getProjectEntry( final ProjectDescriptor descriptor )
           throws TaskException
       {
  @@ -159,7 +148,7 @@
           if( entry == null )
           {
               final Project project = getProject( descriptor );
  -            entry = createProjectEntry( project, m_frame );
  +            entry = createProjectEntry( project, m_taskContext );
               m_entries.put( descriptor, entry );
           }
   
  @@ -207,24 +196,28 @@
       }
   
       /**
  -     * Create a ProjectEntry for Project in specified frame.
  +     * Create a ProjectEntry for Project in specified context.
        *
        * @param project the project
  -     * @param frame the frame
  +     * @param context the context
        * @return the new ProjectEntry
        * @throws TaskException if unable to create entry
        */
       private ProjectEntry createProjectEntry( final Project project,
  -                                             final ExecutionFrame frame )
  +                                             final TaskContext context )
           throws TaskException
       {
  -        final ExecutionFrame projectFrame =
  -            createExecutionFrame( project, frame );
  -        final ProjectEntry entry = new ProjectEntry( project, projectFrame );
  +        final TaskContext projectContext =
  +            m_taskContextManager.createPartitionContext( context,
  +                                                         project.getName(),
  +                                                         project.getProjectDescriptor().getUri(),
  +                                                         project.getBaseDirectory() );
  +
  +        final ProjectEntry entry = new ProjectEntry( project, projectContext );
   
           // Set the project entry as a property, so that tasks can get at it
           final PropertyStore propertyStore =
  -            (PropertyStore)projectFrame.lookup( PropertyStore.ROLE );
  +            (PropertyStore)projectContext.getService( PropertyStore.class );
           propertyStore.setProperty( Project.KEY, project );
           propertyStore.setProperty( ProjectRefs.KEY, entry );
   
  @@ -282,11 +275,12 @@
           throws TaskException
       {
           final ModelElement targetModel = target.getModel();
  -        final ExecutionFrame frame =
  -            entry.getFrame().createChildFrame( target.getName() );
  -        final Executor executor = (Executor)frame.lookup( Executor.ROLE );
           final TaskContext context =
  -            frame.createTaskContext( targetModel.getName(), targetModel.getLocation() );
  +            m_taskContextManager.createContext( entry.getContext(),
  +                                                target.getName(),
  +                                                targetModel.getLocation() );
  +
  +        final Executor executor = (Executor)context.getService( Executor.class );
           executor.execute( targetModel, context );
       }
   }
  
  
  
  1.3       +58 -6     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/context/DefaultTaskContextManager.java
  
  Index: DefaultTaskContextManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/context/DefaultTaskContextManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultTaskContextManager.java	27 Jun 2002 05:13:34 -0000	1.2
  +++ DefaultTaskContextManager.java	2 Jul 2002 07:40:32 -0000	1.3
  @@ -7,9 +7,18 @@
    */
   package org.apache.myrmidon.components.context;
   
  -import org.apache.myrmidon.interfaces.context.TaskContextManager;
  +import java.io.File;
  +import org.apache.avalon.framework.service.ServiceException;
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.components.workspace.DefaultTaskContext;
  +import org.apache.myrmidon.interfaces.context.TaskContextManager;
  +import org.apache.myrmidon.interfaces.property.PropertyStore;
  +import org.apache.myrmidon.interfaces.role.RoleManager;
  +import org.apache.myrmidon.interfaces.role.RoleRegistry;
  +import org.apache.myrmidon.interfaces.service.AntServiceKernel;
  +import org.apache.myrmidon.interfaces.type.TypeManager;
  +import org.apache.myrmidon.interfaces.type.TypeRegistry;
   
   /**
    * Basic implementation of the {@link TaskContextManager} service.
  @@ -22,15 +31,58 @@
   public class DefaultTaskContextManager
       implements TaskContextManager
   {
  -    public TaskContext createPartitionContext( TaskContext context, String name, String
location )
  +    public TaskContext createPartitionContext( final TaskContext context,
  +                                               final String name,
  +                                               final String location,
  +                                               final File baseDirectory )
           throws TaskException
       {
  -        return null;
  +        // TODO - we never dispose of these services.  That's bad
  +        try
  +        {
  +            final PropertyStore basePS =
  +                (PropertyStore)context.getService( PropertyStore.class );
  +            final PropertyStore ps = basePS.createChildStore();
  +
  +            final TypeManager baseTM =
  +                (TypeManager)context.getService( TypeManager.class );
  +            final TypeManager tm = baseTM.getChildTypeManager();
  +
  +            final AntServiceKernel baseSK =
  +                (AntServiceKernel)context.getService( AntServiceKernel.class );
  +            final AntServiceKernel sk = baseSK.createChild();
  +
  +            sk.registerService( PropertyStore.ROLE, ps );
  +            sk.registerService( AntServiceKernel.ROLE, sk );
  +            sk.registerService( RoleManager.ROLE, tm );
  +            sk.registerService( RoleRegistry.ROLE, tm );
  +            sk.registerService( TypeManager.ROLE, tm );
  +            sk.registerService( TypeRegistry.ROLE, tm );
  +
  +            return new DefaultTaskContext( name,
  +                                           "",
  +                                           location,
  +                                           baseDirectory,
  +                                           sk );
  +        }
  +        catch( final ServiceException e )
  +        {
  +            throw new IllegalStateException( e.toString() );
  +        }
       }
   
  -    public TaskContext createContext( TaskContext context, String name, String location
)
  +    public TaskContext createContext( final TaskContext context,
  +                                      final String name,
  +                                      final String location )
           throws TaskException
       {
  -        return null;
  +        final AntServiceKernel serviceKernel =
  +            (AntServiceKernel)context.getService( AntServiceKernel.class );
  +
  +        return new DefaultTaskContext( name,
  +                                       context.getQualifiedName(),
  +                                       location,
  +                                       context.getBaseDirectory(),
  +                                       serviceKernel );
       }
   }
  
  
  
  1.2       +1 -34     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/embeddor/ExecutionFrame.java
  
  Index: ExecutionFrame.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/embeddor/ExecutionFrame.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExecutionFrame.java	30 Jun 2002 10:49:40 -0000	1.1
  +++ ExecutionFrame.java	2 Jul 2002 07:40:32 -0000	1.2
  @@ -7,8 +7,6 @@
    */
   package org.apache.myrmidon.interfaces.embeddor;
   
  -import java.io.File;
  -import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
   
   /**
  @@ -33,35 +31,4 @@
        */
       Object lookup( String role )
           throws TaskException;
  -
  -    /**
  -     * Create a {@link org.apache.myrmidon.api.TaskContext} object for current frame.
  -     *
  -     * @param taskName the name of task
  -     * @param location the location of task
  -     * @return the new TaskContext
  -     */
  -    TaskContext createTaskContext( String taskName, String location )
  -        throws TaskException;
  -
  -    /**
  -     * Create a child execution frame. The name of child frame
  -     * is this frame's name concaternated with "/" and the
  -     * specified name.
  -     *
  -     * <p>If partition is true then this frame is considered a
  -     * partitioning frame. A partitioning frame is one which
  -     * creates child instances of certain scoped data stores. These scoped
  -     * stores will inherit values from the parent object but any modifications
  -     * (ie additions or removals) will be local to this frame
  -     * (and child frames).</p>
  -     *
  -     * @param name the name of child frame relative to this frame.
  -     * @param baseDirectory the directory from which the child frame operates.
  -     *        If null will use this frame's base directory.
  -     * @return the new child ExecutionFrame.
  -     */
  -    ExecutionFrame createPartition( String name, File baseDirectory );
  -
  -    ExecutionFrame createChildFrame( String name );
   }
  
  
  

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