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/interfaces/executor ExecutionFrame.java
Date Fri, 25 Jan 2002 11:21:58 GMT
donaldp     02/01/25 03:21:58

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/api
                        AbstractTask.java Task.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/executor
                        AspectAwareExecutor.java DefaultExecutionFrame.java
                        DefaultExecutor.java Resources.properties
               proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace
                        DefaultTaskContext.java DefaultWorkspace.java
                        Resources.properties
               proposal/myrmidon/src/java/org/apache/myrmidon/framework
                        AbstractContainerTask.java AbstractTypeDef.java
                        Resources.properties TypeInstanceTask.java
               proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/executor
                        ExecutionFrame.java
  Log:
  Replace need for Composable tasks with TaskContext.getService()
  
  Submitted By: "Adam Murdoch" <adammurdoch_ml@yahoo.com>
  
  Revision  Changes    Path
  1.15      +7 -2      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/AbstractTask.java
  
  Index: AbstractTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/AbstractTask.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AbstractTask.java	24 Jan 2002 11:35:56 -0000	1.14
  +++ AbstractTask.java	25 Jan 2002 11:21:57 -0000	1.15
  @@ -8,9 +8,7 @@
   package org.apache.myrmidon.api;
   
   import java.io.File;
  -import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.ContextException;
  -import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   
   /**
  @@ -31,6 +29,7 @@
        * @param context the context
        */
       public void contextualize( final TaskContext context )
  +        throws TaskException
       {
           m_context = context;
       }
  @@ -102,6 +101,12 @@
           throws TaskException
       {
           getContext().setProperty( name, value, scope );
  +    }
  +
  +    protected final Object getService( final Class serviceClass )
  +        throws TaskException
  +    {
  +        return getContext().getService( serviceClass );
       }
   
       protected final TaskContext createSubContext( final String name )
  
  
  
  1.13      +2 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/Task.java
  
  Index: Task.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/Task.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Task.java	24 Jan 2002 11:40:58 -0000	1.12
  +++ Task.java	25 Jan 2002 11:21:57 -0000	1.13
  @@ -29,7 +29,8 @@
        * The Task will use the TaskContext to receive information
        * about it's environment.
        */
  -    void contextualize( TaskContext context );
  +    void contextualize( TaskContext context )
  +        throws TaskException;
   
       /**
        * Execute task.
  
  
  
  1.14      +0 -3      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/AspectAwareExecutor.java
  
  Index: AspectAwareExecutor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/AspectAwareExecutor.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- AspectAwareExecutor.java	20 Jan 2002 17:32:56 -0000	1.13
  +++ AspectAwareExecutor.java	25 Jan 2002 11:21:57 -0000	1.14
  @@ -81,9 +81,6 @@
           debug( "contextualizing.notice" );
           doContextualize( task, taskModel, frame.getContext() );
   
  -        debug( "composing.notice" );
  -        doCompose( task, taskModel, frame.getComponentManager() );
  -
           debug( "configuring.notice" );
           getAspectManager().preConfigure( taskModel );
           doConfigure( task, taskModel, frame.getContext() );
  
  
  
  1.10      +13 -24    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/DefaultExecutionFrame.java
  
  Index: DefaultExecutionFrame.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/DefaultExecutionFrame.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultExecutionFrame.java	23 Dec 2001 06:25:35 -0000	1.9
  +++ DefaultExecutionFrame.java	25 Jan 2002 11:21:57 -0000	1.10
  @@ -12,9 +12,11 @@
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.Contextualizable;
  +import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.logger.LogEnabled;
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.myrmidon.api.TaskContext;
  +import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.type.TypeManager;
   
  @@ -24,36 +26,28 @@
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    */
   public class DefaultExecutionFrame
  -    implements ExecutionFrame, LogEnabled, Contextualizable, Composable
  +    implements ExecutionFrame, LogEnabled, Contextualizable
   {
  -    private TypeManager m_typeManager;
  -
       private Logger m_logger;
       private TaskContext m_context;
  -    private ComponentManager m_componentManager;
  +    private TypeManager m_typeManager;
   
       public void enableLogging( final Logger logger )
       {
           m_logger = logger;
       }
   
  -    public void contextualize( final Context context )
  +    public void contextualize( final Context context ) throws ContextException
       {
           m_context = (TaskContext)context;
  -    }
  -
  -    /**
  -     * Retrieve relevent services needed to deploy.
  -     *
  -     * @param componentManager the ComponentManager
  -     * @exception ComponentException if an error occurs
  -     */
  -    public void compose( final ComponentManager componentManager )
  -        throws ComponentException
  -    {
  -        m_componentManager = componentManager;
  -
  -        m_typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE );
  +        try
  +        {
  +            m_typeManager = (TypeManager)m_context.getService( TypeManager.class );
  +        }
  +        catch( TaskException te )
  +        {
  +            throw new ContextException(te.getMessage(), te);
  +        }
       }
   
       public TypeManager getTypeManager()
  @@ -69,10 +63,5 @@
       public TaskContext getContext()
       {
           return m_context;
  -    }
  -
  -    public ComponentManager getComponentManager()
  -    {
  -        return m_componentManager;
       }
   }
  
  
  
  1.21      +0 -26     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java
  
  Index: DefaultExecutor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- DefaultExecutor.java	24 Jan 2002 11:40:58 -0000	1.20
  +++ DefaultExecutor.java	25 Jan 2002 11:21:57 -0000	1.21
  @@ -61,9 +61,6 @@
           debug( "contextualizing.notice" );
           doContextualize( task, taskModel, frame.getContext() );
   
  -        debug( "composing.notice" );
  -        doCompose( task, taskModel, frame.getComponentManager() );
  -
           debug( "configuring.notice" );
           doConfigure( task, taskModel, frame.getContext() );
   
  @@ -112,29 +109,6 @@
                                  taskModel.getLocation(),
                                  throwable.getMessage() );
               throw new TaskException( message, throwable );
  -        }
  -    }
  -
  -    protected final void doCompose( final Task task,
  -                                    final Configuration taskModel,
  -                                    final ComponentManager componentManager )
  -        throws TaskException
  -    {
  -        if( task instanceof Composable )
  -        {
  -            try
  -            {
  -                ( (Composable)task ).compose( componentManager );
  -            }
  -            catch( final Throwable throwable )
  -            {
  -                final String message =
  -                    REZ.getString( "compose.error",
  -                                   taskModel.getName(),
  -                                   taskModel.getLocation(),
  -                                   throwable.getMessage() );
  -                throw new TaskException( message, throwable );
  -            }
           }
       }
   
  
  
  
  1.4       +0 -2      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/Resources.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Resources.properties	24 Jan 2002 11:36:53 -0000	1.3
  +++ Resources.properties	25 Jan 2002 11:21:57 -0000	1.4
  @@ -1,7 +1,6 @@
   creating.notice=Creating.
   logger.notice=Setting Logger.
   contextualizing.notice=Contextualizing.
  -composing.notice=Composing.
   configuring.notice=Configuring.
   initializing.notice=Initializing.
   executing.notice=Executing.
  @@ -9,7 +8,6 @@
   
   no-create.error=Unable to create task {0}.
   config.error=Error configuring task {0} at {1} (Reason: {2}).
  -compose.error=Error composing task {0} at {1} (Reason: {2}).
   contextualize.error=Error contextualizing task {0} at {1} (Reason: {2}).
   dispose.error=Error disposing task {0} at {1} (Reason: {2}).
   init.error=Error initializing task {0} at {1} (Reason: {2}).
  
  
  
  1.10      +63 -12    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java
  
  Index: DefaultTaskContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultTaskContext.java	24 Jan 2002 11:48:40 -0000	1.9
  +++ DefaultTaskContext.java	25 Jan 2002 11:21:57 -0000	1.10
  @@ -8,12 +8,14 @@
   package org.apache.myrmidon.components.workspace;
   
   import java.io.File;
  -import java.util.Map;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.excalibur.io.FileUtil;
   import org.apache.avalon.excalibur.property.PropertyException;
   import org.apache.avalon.excalibur.property.PropertyUtil;
  +import org.apache.avalon.framework.component.Component;
  +import org.apache.avalon.framework.component.ComponentException;
  +import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.myrmidon.api.TaskContext;
  @@ -31,32 +33,44 @@
       private final static Resources REZ =
           ResourceManager.getPackageResources( DefaultTaskContext.class );
   
  +    private ComponentManager m_componentManager;
  +
       /**
        * Constructor for Context with no parent contexts.
        */
  -    public DefaultTaskContext( final Map contextData )
  +    public DefaultTaskContext()
       {
  -        super( contextData );
  +        this( (TaskContext)null );
       }
   
       /**
  -     * Constructor for Context with no parent contexts.
  +     * Constructor that specified parent context.
        */
  -    public DefaultTaskContext()
  +    public DefaultTaskContext( final TaskContext parent )
       {
  -        this( (TaskContext)null );
  +        this( parent, null );
       }
   
       /**
  -     * Constructor.
  +     * Constructor that specifies the ComponentManager for context.
        */
  -    public DefaultTaskContext( final TaskContext parent )
  +    public DefaultTaskContext( final ComponentManager componentManager )
  +    {
  +        this( null, componentManager );
  +    }
  +
  +    /**
  +     * Constructor that takes both parent context and a service directory.
  +     */
  +    public DefaultTaskContext( final TaskContext parent,
  +                               final ComponentManager componentManager )
       {
           super( parent );
  +        m_componentManager = componentManager;
       }
   
       /**
  -     * Retrieve Name of tasklet.
  +     * Retrieve Name of task.
        *
        * @return the name
        */
  @@ -104,7 +118,42 @@
       public Object getService( final Class serviceClass )
           throws TaskException
       {
  -        throw new TaskException( "No services available atm" );
  +        // Try this context first
  +        final String name = serviceClass.getName();
  +        if( m_componentManager.hasComponent( name ) )
  +        {
  +            try
  +            {
  +                final Component service = m_componentManager.lookup( name );
  +                if( !serviceClass.isInstance( service ) )
  +                {
  +                    final String message =
  +                        REZ.getString( "bad-service-class.error",
  +                                       name,
  +                                       service.getClass().getName(),
  +                                       serviceClass.getName() );
  +                    throw new TaskException( message );
  +                }
  +
  +                return service;
  +            }
  +            catch( final ComponentException ce )
  +            {
  +                final String message = REZ.getString( "bad-find-service.error", name );
  +                throw new TaskException( message, ce );
  +            }
  +        }
  +
  +        // Try parent
  +        final TaskContext parent = (TaskContext)getParent();
  +        if( null != parent )
  +        {
  +            return parent.getService( serviceClass );
  +        }
  +
  +        // Not found
  +        final String message = REZ.getString( "bad-find-service.error", name );
  +        throw new TaskException( message );
       }
   
       /**
  @@ -194,9 +243,11 @@
       {
           checkPropertyValid( name, value );
   
  -        if( CURRENT == scope ) {
  +        if( CURRENT == scope )
  +        {
               put( name, value );
  -        } else if( PARENT == scope )
  +        }
  +        else if( PARENT == scope )
           {
               if( null == getParent() )
               {
  
  
  
  1.13      +10 -8     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java
  
  Index: DefaultWorkspace.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultWorkspace.java	20 Jan 2002 17:32:58 -0000	1.12
  +++ DefaultWorkspace.java	25 Jan 2002 11:21:57 -0000	1.13
  @@ -19,7 +19,6 @@
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.component.DefaultComponentManager;
   import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.logger.LogKitLogger;
   import org.apache.avalon.framework.logger.Logger;
  @@ -31,6 +30,7 @@
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.components.deployer.DefaultDeployer;
   import org.apache.myrmidon.components.executor.DefaultExecutionFrame;
  +import org.apache.myrmidon.components.role.DefaultRoleManager;
   import org.apache.myrmidon.framework.Condition;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.deployer.DeploymentException;
  @@ -41,6 +41,7 @@
   import org.apache.myrmidon.interfaces.model.TypeLib;
   import org.apache.myrmidon.interfaces.type.TypeManager;
   import org.apache.myrmidon.interfaces.workspace.Workspace;
  +import org.apache.myrmidon.interfaces.role.RoleManager;
   import org.apache.myrmidon.listeners.ProjectListener;
   
   /**
  @@ -141,7 +142,7 @@
       private TaskContext createBaseContext()
           throws TaskException
       {
  -        final TaskContext context = new DefaultTaskContext();
  +        final TaskContext context = new DefaultTaskContext( m_componentManager );
   
           final String[] names = m_parameters.getNames();
           for( int i = 0; i < names.length; i++ )
  @@ -219,9 +220,6 @@
       private ExecutionFrame createExecutionFrame( final Project project )
           throws TaskException
       {
  -        final TaskContext context = new DefaultTaskContext( m_baseContext );
  -        context.setProperty( TaskContext.BASE_DIRECTORY, project.getBaseDirectory() );
  -
           //Create per frame ComponentManager
           final DefaultComponentManager componentManager =
               new DefaultComponentManager( m_componentManager );
  @@ -267,6 +265,11 @@
               componentManager.put( Project.ROLE + "/" + name, other );
           }
   
  +        // Create and configure the context
  +        final DefaultTaskContext context =
  +            new DefaultTaskContext( m_baseContext, componentManager );
  +        context.setProperty( TaskContext.BASE_DIRECTORY, project.getBaseDirectory() );
  +
           final DefaultExecutionFrame frame = new DefaultExecutionFrame();
   
           try
  @@ -276,7 +279,6 @@
   
               frame.enableLogging( logger );
               frame.contextualize( context );
  -            frame.compose( componentManager );
           }
           catch( final Exception e )
           {
  @@ -401,10 +403,10 @@
                       return;
                   }
               }
  -            catch( final ContextException ce )
  +            catch( final TaskException te )
               {
                   final String message = REZ.getString( "condition-eval.error", name );
  -                throw new TaskException( message, ce );
  +                throw new TaskException( message, te );
               }
           }
   
  
  
  
  1.5       +4 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Resources.properties	5 Jan 2002 03:03:55 -0000	1.4
  +++ Resources.properties	25 Jan 2002 11:21:57 -0000	1.5
  @@ -15,7 +15,10 @@
   no-name.error=No Name in Context.
   no-dir.error=No Base Directory in Context.
   no-parent.error=Can't set a property with parent scope when context has no parent.
  +bad-find-services.error=Unable to find service "{0}".
   bad-scope.error=Unknown property scope! ({0}).
   bad-property.error=Property {0} must have a value of type {1}.
   null-resolved-value.error=Value "{0}" resolved to null.
  -bad-resolve.error=Unable to resolve value "{0}".
  \ No newline at end of file
  +bad-resolve.error=Unable to resolve value "{0}".
  +bad-find-service.error=Could not find service "{0}".
  +bad-service-class.error=Find service "{0}" but it was of type {1} where it was expected
to be of type {2}.
  \ No newline at end of file
  
  
  
  1.11      +36 -12    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/AbstractContainerTask.java
  
  Index: AbstractContainerTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/AbstractContainerTask.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AbstractContainerTask.java	20 Jan 2002 17:32:56 -0000	1.10
  +++ AbstractContainerTask.java	25 Jan 2002 11:21:57 -0000	1.11
  @@ -9,20 +9,21 @@
   
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -
  -
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  -
  +import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.context.ContextException;
   import org.apache.myrmidon.api.AbstractTask;
  +import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.converter.Converter;
   import org.apache.myrmidon.converter.ConverterException;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
   import org.apache.myrmidon.interfaces.converter.MasterConverter;
   import org.apache.myrmidon.interfaces.executor.Executor;
  +import org.apache.myrmidon.interfaces.type.TypeFactory;
  +import org.apache.myrmidon.interfaces.type.TypeManager;
  +import org.apache.myrmidon.interfaces.type.TypeException;
   
   /**
    * This is the class that Task writers should extend to provide custom tasks.
  @@ -31,7 +32,6 @@
    */
   public abstract class AbstractContainerTask
       extends AbstractTask
  -    implements Composable
   {
       private final static Resources REZ =
           ResourceManager.getPackageResources( AbstractContainerTask.class );
  @@ -45,12 +45,18 @@
       ///For executing sub-elements as tasks
       private Executor m_executor;
   
  -    public void compose( final ComponentManager componentManager )
  -        throws ComponentException
  +    /**
  +     * Retrieve context from container.
  +     *
  +     * @param context the context
  +     */
  +    public void contextualize( TaskContext context )
  +        throws TaskException
       {
  -        m_configurer = (Configurer)componentManager.lookup( Configurer.ROLE );
  -        m_converter = (MasterConverter)componentManager.lookup( MasterConverter.ROLE );
  -        m_executor = (Executor)componentManager.lookup( Executor.ROLE );
  +        super.contextualize( context );
  +        m_configurer = (Configurer)getService( Configurer.class );
  +        m_converter = (MasterConverter)getService( MasterConverter.class );
  +        m_executor = (Executor)getService( Executor.class );
       }
   
       /**
  @@ -100,6 +106,24 @@
           throws ConfigurationException
       {
           getConfigurer().configure( object, name, value, getContext() );
  +    }
  +
  +    /**
  +     * Locates a type factory.
  +     */
  +    protected final TypeFactory getTypeFactory( final String role )
  +        throws TaskException
  +    {
  +        final TypeManager typeManager = (TypeManager)getService( TypeManager.class );
  +        try
  +        {
  +            return typeManager.getFactory( role );
  +        }
  +        catch( final TypeException te )
  +        {
  +            final String message = REZ.getString( "container.no-factory.error", role );
  +            throw new TaskException( message, te );
  +        }
       }
   
       /**
  
  
  
  1.12      +4 -20     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/AbstractTypeDef.java
  
  Index: AbstractTypeDef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/AbstractTypeDef.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- AbstractTypeDef.java	20 Jan 2002 17:32:56 -0000	1.11
  +++ AbstractTypeDef.java	25 Jan 2002 11:21:57 -0000	1.12
  @@ -12,9 +12,6 @@
   import java.net.URLClassLoader;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.component.Composable;
   import org.apache.myrmidon.api.AbstractTask;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.interfaces.role.RoleManager;
  @@ -31,7 +28,6 @@
    */
   public abstract class AbstractTypeDef
       extends AbstractTask
  -    implements Composable
   {
       private final static Resources REZ =
           ResourceManager.getPackageResources( AbstractTypeDef.class );
  @@ -39,15 +35,6 @@
       private File m_lib;
       private String m_name;
       private String m_className;
  -    private TypeManager m_typeManager;
  -    private RoleManager m_roleManager;
  -
  -    public void compose( final ComponentManager componentManager )
  -        throws ComponentException
  -    {
  -        m_typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE );
  -        m_roleManager = (RoleManager)componentManager.lookup( RoleManager.ROLE );
  -    }
   
       public void setLib( final File lib )
       {
  @@ -80,15 +67,17 @@
           }
   
           final String typeName = getTypeName();
  -        final String role = m_roleManager.getRoleForName( typeName );
  +        final RoleManager roleManager = (RoleManager)getService( RoleManager.class );
  +        final String role = roleManager.getRoleForName( typeName );
   
           final ClassLoader classLoader = createClassLoader();
           final DefaultTypeFactory factory = new DefaultTypeFactory( classLoader );
           factory.addNameClassMapping( m_name, m_className );
   
  +        final TypeManager typeManager = (TypeManager)getService( TypeManager.class );
           try
           {
  -            m_typeManager.registerType( role, m_name, factory );
  +            typeManager.registerType( role, m_name, factory );
           }
           catch( final TypeException te )
           {
  @@ -114,11 +103,6 @@
               final String message = REZ.getString( "typedef.bad-classloader.error", e );
               throw new TaskException( message, e );
           }
  -    }
  -
  -    protected final TypeManager getTypeManager()
  -    {
  -        return m_typeManager;
       }
   
       protected abstract String getTypeName();
  
  
  
  1.4       +1 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/Resources.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Resources.properties	16 Dec 2001 12:10:29 -0000	1.3
  +++ Resources.properties	25 Jan 2002 11:21:57 -0000	1.4
  @@ -1,6 +1,7 @@
   container.null-value.error=Value ({0}) resolved to null.
   container.bad-resolve.error=Error resolving value ({0}).
   container.bad-config.error=Error converting value.
  +container.no-factory.error=Could not locate the type factory for type "{0}".
   
   typedef.no-name.error=Must specify name parameter.
   typedef.no-classname.error=Must specify classname parameter.
  @@ -11,7 +12,6 @@
   
   pattern.ifelse-duplicate.error=Can only set one of if/else for pattern data type.
   
  -type.no-factory.error=Unable to retrieve DataType factory from TypeManager.
   type.no-create.error=Unable to create datatype.
   type.no-id.error=Id must be specified.
   
  
  
  
  1.9       +2 -23     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/TypeInstanceTask.java
  
  Index: TypeInstanceTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/TypeInstanceTask.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TypeInstanceTask.java	20 Jan 2002 17:32:56 -0000	1.8
  +++ TypeInstanceTask.java	25 Jan 2002 11:21:57 -0000	1.9
  @@ -9,17 +9,13 @@
   
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.myrmidon.interfaces.type.TypeException;
   import org.apache.myrmidon.interfaces.type.TypeFactory;
  -import org.apache.myrmidon.interfaces.type.TypeManager;
   
   /**
    * This is the property "task" to declare a binding of a datatype to a name.
  @@ -36,24 +32,6 @@
       private String m_id;
       private Object m_value;
       private boolean m_localScope = true;
  -    private TypeFactory m_factory;
  -
  -    public void compose( final ComponentManager componentManager )
  -        throws ComponentException
  -    {
  -        super.compose( componentManager );
  -
  -        final TypeManager typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE
);
  -        try
  -        {
  -            m_factory = typeManager.getFactory( DataType.ROLE );
  -        }
  -        catch( final TypeException te )
  -        {
  -            final String message = REZ.getString( "type.no-factory.error" );
  -            throw new ComponentException( message, te );
  -        }
  -    }
   
       public void configure( final Configuration configuration )
           throws ConfigurationException
  @@ -85,7 +63,8 @@
   
           try
           {
  -            m_value = m_factory.create( configuration.getName() );
  +            final TypeFactory typeFactory = getTypeFactory( DataType.ROLE );
  +            m_value = typeFactory.create( configuration.getName() );
           }
           catch( final Exception e )
           {
  
  
  
  1.6       +0 -2      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/executor/ExecutionFrame.java
  
  Index: ExecutionFrame.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/executor/ExecutionFrame.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ExecutionFrame.java	23 Dec 2001 06:25:36 -0000	1.5
  +++ ExecutionFrame.java	25 Jan 2002 11:21:58 -0000	1.6
  @@ -24,6 +24,4 @@
       Logger getLogger();
   
       TaskContext getContext();
  -
  -    ComponentManager getComponentManager();
   }
  
  
  

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