ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/context DefaultTaskContextManager.java
Date Tue, 02 Jul 2002 07:44:44 GMT
donaldp     2002/07/02 00:44:44

  Modified:    container/src/java/org/apache/myrmidon/components/service
                        DefaultAntServiceKernel.java
               container/src/java/org/apache/myrmidon/components/context
                        DefaultTaskContextManager.java
  Log:
  Move scoping management from DefaultTaskContextManager to  ServiceKernel.
  
  Hacky but getting cleaner...
  
  Revision  Changes    Path
  1.4       +33 -2     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/service/DefaultAntServiceKernel.java
  
  Index: DefaultAntServiceKernel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/service/DefaultAntServiceKernel.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultAntServiceKernel.java	30 Jun 2002 09:58:14 -0000	1.3
  +++ DefaultAntServiceKernel.java	2 Jul 2002 07:44:44 -0000	1.4
  @@ -9,7 +9,12 @@
   
   import java.util.HashMap;
   import org.apache.avalon.framework.service.ServiceException;
  +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;
   
   /**
    * Implementation of {@link AntServiceKernel} service.
  @@ -78,6 +83,32 @@
   
       public AntServiceKernel createChild()
       {
  -        return new DefaultAntServiceKernel( this );
  +        final DefaultAntServiceKernel sk = new DefaultAntServiceKernel( this );
  +
  +        try
  +        {
  +            // TODO - we never dispose of these services.  That's bad
  +            final PropertyStore basePS =
  +                (PropertyStore)getService( PropertyStore.ROLE );
  +            final PropertyStore ps = basePS.createChildStore();
  +
  +            final TypeManager baseTM =
  +                (TypeManager)getService( TypeManager.ROLE );
  +            final TypeManager tm = baseTM.getChildTypeManager();
  +
  +            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 );
  +
  +        }
  +        catch( final ServiceException e )
  +        {
  +            throw new IllegalStateException( e.toString() );
  +        }
  +
  +        return sk;
       }
   }
  
  
  
  1.4       +8 -39     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultTaskContextManager.java	2 Jul 2002 07:40:32 -0000	1.3
  +++ DefaultTaskContextManager.java	2 Jul 2002 07:44:44 -0000	1.4
  @@ -8,17 +8,11 @@
   package org.apache.myrmidon.components.context;
   
   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.
  @@ -37,38 +31,13 @@
                                                  final File baseDirectory )
           throws TaskException
       {
  -        // 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() );
  -        }
  +        final AntServiceKernel serviceKernel =
  +            (AntServiceKernel)context.getService( AntServiceKernel.class );
  +        return new DefaultTaskContext( name,
  +                                       "",
  +                                       location,
  +                                       baseDirectory,
  +                                       serviceKernel.createChild() );
       }
   
       public TaskContext createContext( final TaskContext context,
  
  
  

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