ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components AbstractComponentTest.java
Date Thu, 14 Feb 2002 02:12:24 GMT
adammurdoch    02/02/13 18:12:23

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace
                        DefaultExecutionFrame.java DefaultTaskContext.java
                        DefaultWorkspace.java Resources.properties
               proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer
                        DefaultConfigurerTest.java
               proposal/myrmidon/src/testcases/org/apache/myrmidon/components
                        AbstractComponentTest.java
  Log:
  * DefaultTaskContext now uses a ServiceManager to locate services, rather than
    a ComponentManager.  Currently all components are also exposed as services.
  
  * Some tidy up to DefaultExecutionFrame and DefaultWorkspace.
  
  Revision  Changes    Path
  1.4       +10 -25    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultExecutionFrame.java
  
  Index: DefaultExecutionFrame.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultExecutionFrame.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultExecutionFrame.java	7 Feb 2002 13:02:20 -0000	1.3
  +++ DefaultExecutionFrame.java	14 Feb 2002 02:12:23 -0000	1.4
  @@ -8,13 +8,8 @@
   package org.apache.myrmidon.components.workspace;
   
   import org.apache.avalon.framework.component.Component;
  -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.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;
   
  @@ -22,32 +17,22 @@
    * Frames in which tasks are executed.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.3 $ $Date: 2002/02/07 13:02:20 $
  + * @version $Revision: 1.4 $ $Date: 2002/02/14 02:12:23 $
    */
   class DefaultExecutionFrame
  -    implements ExecutionFrame, Component, LogEnabled, Contextualizable
  +    implements ExecutionFrame, Component
   {
  -    private Logger m_logger;
  -    private TaskContext m_context;
  -    private TypeManager m_typeManager;
  +    private final Logger m_logger;
  +    private final TaskContext m_context;
  +    private final TypeManager m_typeManager;
   
  -    public void enableLogging( final Logger logger )
  +    public DefaultExecutionFrame( final Logger logger,
  +                                  final TaskContext context,
  +                                  final TypeManager typeManager )
       {
           m_logger = logger;
  -    }
  -
  -    public void contextualize( final Context context )
  -        throws ContextException
  -    {
  -        m_context = (TaskContext)context;
  -        try
  -        {
  -            m_typeManager = (TypeManager)m_context.getService( TypeManager.class );
  -        }
  -        catch( TaskException te )
  -        {
  -            throw new ContextException( te.getMessage(), te );
  -        }
  +        m_context = context;
  +        m_typeManager = typeManager;
       }
   
       public TypeManager getTypeManager()
  
  
  
  1.12      +14 -29    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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultTaskContext.java	7 Feb 2002 13:02:20 -0000	1.11
  +++ DefaultTaskContext.java	14 Feb 2002 02:12:23 -0000	1.12
  @@ -13,19 +13,18 @@
   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;
   import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.interfaces.service.ServiceException;
  +import org.apache.myrmidon.interfaces.service.ServiceManager;
   
   /**
    * Default implementation of TaskContext.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.11 $ $Date: 2002/02/07 13:02:20 $
  + * @version $Revision: 1.12 $ $Date: 2002/02/14 02:12:23 $
    */
   public class DefaultTaskContext
       extends DefaultContext
  @@ -34,14 +33,14 @@
       private final static Resources REZ =
           ResourceManager.getPackageResources( DefaultTaskContext.class );
   
  -    private ComponentManager m_componentManager;
  +    private ServiceManager m_serviceManager;
   
       /**
        * Constructor for Context with no parent contexts.
        */
       public DefaultTaskContext()
       {
  -        this( (TaskContext)null );
  +        this( null, null );
       }
   
       /**
  @@ -53,21 +52,21 @@
       }
   
       /**
  -     * Constructor that specifies the ComponentManager for context.
  +     * Constructor that specifies the service directory for context.
        */
  -    public DefaultTaskContext( final ComponentManager componentManager )
  +    public DefaultTaskContext( final ServiceManager serviceManager )
       {
  -        this( null, componentManager );
  +        this( null, serviceManager );
       }
   
       /**
        * Constructor that takes both parent context and a service directory.
        */
       public DefaultTaskContext( final TaskContext parent,
  -                               final ComponentManager componentManager )
  +                               final ServiceManager serviceManager )
       {
           super( parent );
  -        m_componentManager = componentManager;
  +        m_serviceManager = serviceManager;
       }
   
       /**
  @@ -121,27 +120,15 @@
       {
           // Try this context first
           final String name = serviceClass.getName();
  -        if( m_componentManager.hasComponent( name ) )
  +        if( m_serviceManager != null && m_serviceManager.hasService( serviceClass
) )
           {
               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;
  +                return m_serviceManager.getService( serviceClass );
               }
  -            catch( final ComponentException ce )
  +            catch( final ServiceException se )
               {
  -                final String message = REZ.getString( "bad-find-service.error", name );
  -                throw new TaskException( message, ce );
  +                throw new TaskException( se.getMessage(), se );
               }
           }
   
  @@ -236,8 +223,6 @@
   
       /**
        * Set property value.
  -     *
  -     * @param property the property
        */
       public void setProperty( final String name, final Object value, final ScopeEnum scope
)
           throws TaskException
  
  
  
  1.22      +40 -51    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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- DefaultWorkspace.java	13 Feb 2002 03:02:54 -0000	1.21
  +++ DefaultWorkspace.java	14 Feb 2002 02:12:23 -0000	1.22
  @@ -37,6 +37,9 @@
   import org.apache.myrmidon.interfaces.model.Project;
   import org.apache.myrmidon.interfaces.model.Target;
   import org.apache.myrmidon.interfaces.model.TypeLib;
  +import org.apache.myrmidon.interfaces.service.ComponentManagerAdaptor;
  +import org.apache.myrmidon.interfaces.service.MultiSourceServiceManager;
  +import org.apache.myrmidon.interfaces.service.ServiceManager;
   import org.apache.myrmidon.interfaces.type.TypeManager;
   import org.apache.myrmidon.interfaces.workspace.Workspace;
   import org.apache.myrmidon.listeners.ProjectListener;
  @@ -45,7 +48,7 @@
    * This is the default implementation of Workspace.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.21 $ $Date: 2002/02/13 03:02:54 $
  + * @version $Revision: 1.22 $ $Date: 2002/02/14 02:12:23 $
    */
   public class DefaultWorkspace
       extends AbstractLogEnabled
  @@ -142,7 +145,7 @@
       private TaskContext createBaseContext()
           throws TaskException
       {
  -        final TaskContext context = new DefaultTaskContext( m_componentManager );
  +        final TaskContext context = new DefaultTaskContext();
   
           final String[] names = m_parameters.getNames();
           for( int i = 0; i < names.length; i++ )
  @@ -220,8 +223,11 @@
           }
       }
   
  +    /**
  +     * Creates an execution frame for a project.
  +     */
       private ExecutionFrame createExecutionFrame( final Project project )
  -        throws TaskException
  +        throws TaskException, ComponentException
       {
           //Create per frame ComponentManager
           final DefaultComponentManager componentManager =
  @@ -232,32 +238,11 @@
           final TypeManager typeManager = m_typeManager.createChildTypeManager();
           componentManager.put( TypeManager.ROLE, typeManager );
   
  -        //try
  -        //{
  -        //    //Add VFS manager
  -        //    // TODO - need to drive this from a typelib descriptor, plus
  -        //    // should be adding services to the root frame, rather than here
  -        //    final DefaultFileSystemManager vfsManager = new DefaultFileSystemManager();
  -        //    vfsManager.setBaseFile( project.getBaseDirectory() );
  -        //    componentManager.put( FileSystemManager.ROLE, vfsManager );
  -        //}
  -        //catch( Exception e )
  -        //{
  -        //    throw new TaskException( e.getMessage(), e );
  -        //}
  -
           //We need to create a new deployer so that it deploys
           //to project specific TypeManager
           final Deployer deployer;
  -        try
  -        {
  -            deployer = m_deployer.createChildDeployer( componentManager );
  -            componentManager.put( Deployer.ROLE, deployer );
  -        }
  -        catch( ComponentException e )
  -        {
  -            throw new TaskException( e.getMessage(), e );
  -        }
  +        deployer = m_deployer.createChildDeployer( componentManager );
  +        componentManager.put( Deployer.ROLE, deployer );
   
           // Deploy the imported typelibs
           deployTypeLib( deployer, project );
  @@ -275,32 +260,28 @@
               componentManager.put( Project.ROLE + "/" + name, other );
           }
   
  +        // Create a service manager that aggregates the contents of the context's
  +        // component manager, and service manager
  +        final MultiSourceServiceManager serviceManager = new MultiSourceServiceManager();
  +        serviceManager.add( (ServiceManager)componentManager.lookup( ServiceManager.ROLE
) );
  +        serviceManager.add( new ComponentManagerAdaptor( componentManager ) );
  +
           // Create and configure the context
           final DefaultTaskContext context =
  -            new DefaultTaskContext( m_baseContext, componentManager );
  +            new DefaultTaskContext( m_baseContext, serviceManager );
           context.setProperty( TaskContext.BASE_DIRECTORY, project.getBaseDirectory() );
   
  -        final DefaultExecutionFrame frame = new DefaultExecutionFrame();
  -
  -        try
  -        {
  -            final Logger logger =
  -                new LogKitLogger( m_hierarchy.getLoggerFor( "project" + m_projectID ) );
  -            m_projectID++;
  -
  -            frame.enableLogging( logger );
  -            frame.contextualize( context );
  -
  -            /**
  -             *  @todo Should no occur but done for the time being to simplify evolution.
  -             */
  -            componentManager.put( ExecutionFrame.ROLE, frame );
  -        }
  -        catch( final Exception e )
  -        {
  -            final String message = REZ.getString( "bad-frame.error" );
  -            throw new TaskException( message, e );
  -        }
  +        // Create a logger
  +        final Logger logger =
  +            new LogKitLogger( m_hierarchy.getLoggerFor( "project" + m_projectID ) );
  +        m_projectID++;
  +
  +        final DefaultExecutionFrame frame = new DefaultExecutionFrame( logger, context,
typeManager );
  +
  +        /**
  +         *  @todo Should no occur but done for the time being to simplify evolution.
  +         */
  +        componentManager.put( ExecutionFrame.ROLE, frame );
   
           return frame;
       }
  @@ -312,9 +293,17 @@
   
           if( null == entry )
           {
  -            final ExecutionFrame frame = createExecutionFrame( project );
  -            entry = new ProjectEntry( project, frame );
  -            m_entrys.put( project, entry );
  +            try
  +            {
  +                final ExecutionFrame frame = createExecutionFrame( project );
  +                entry = new ProjectEntry( project, frame );
  +                m_entrys.put( project, entry );
  +            }
  +            catch( Exception e )
  +            {
  +                final String message = REZ.getString( "bad-frame.error" );
  +                throw new TaskException( message, e );
  +            }
           }
   
           return entry;
  
  
  
  1.6       +0 -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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Resources.properties	25 Jan 2002 11:21:57 -0000	1.5
  +++ Resources.properties	14 Feb 2002 02:12:23 -0000	1.6
  @@ -15,7 +15,6 @@
   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.
  
  
  
  1.12      +1 -1      jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java
  
  Index: DefaultConfigurerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultConfigurerTest.java	8 Feb 2002 22:20:00 -0000	1.11
  +++ DefaultConfigurerTest.java	14 Feb 2002 02:12:23 -0000	1.12
  @@ -52,7 +52,7 @@
           m_configurer = (Configurer)getComponentManager().lookup( Configurer.ROLE );
   
           // Setup a context
  -        m_context = new DefaultTaskContext( getComponentManager() );
  +        m_context = new DefaultTaskContext();
           final File baseDir = new File( "." ).getAbsoluteFile();
           m_context.setProperty( TaskContext.BASE_DIRECTORY, baseDir );
       }
  
  
  
  1.4       +6 -0      jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/AbstractComponentTest.java
  
  Index: AbstractComponentTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/AbstractComponentTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractComponentTest.java	10 Feb 2002 02:34:14 -0000	1.3
  +++ AbstractComponentTest.java	14 Feb 2002 02:12:23 -0000	1.4
  @@ -33,6 +33,7 @@
   import org.apache.myrmidon.components.extensions.DefaultExtensionManager;
   import org.apache.myrmidon.components.role.DefaultRoleManager;
   import org.apache.myrmidon.components.type.DefaultTypeManager;
  +import org.apache.myrmidon.components.service.DefaultServiceManager;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
   import org.apache.myrmidon.interfaces.converter.ConverterRegistry;
   import org.apache.myrmidon.interfaces.converter.MasterConverter;
  @@ -42,6 +43,7 @@
   import org.apache.myrmidon.interfaces.type.TypeManager;
   import org.apache.myrmidon.interfaces.type.TypeException;
   import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
  +import org.apache.myrmidon.interfaces.service.ServiceManager;
   import org.apache.myrmidon.converter.Converter;
   import org.apache.myrmidon.AbstractMyrmidonTest;
   
  @@ -131,6 +133,10 @@
   
           component = new DefaultRoleManager();
           m_componentManager.put( RoleManager.ROLE, component );
  +        components.add( component );
  +
  +        component = new DefaultServiceManager();
  +        m_componentManager.put( ServiceManager.ROLE, component );
           components.add( component );
   
           // Log enable the components
  
  
  

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