Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 31418 invoked from network); 20 Jun 2002 07:54:55 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 20 Jun 2002 07:54:55 -0000 Received: (qmail 21598 invoked by uid 97); 20 Jun 2002 07:55:07 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 21580 invoked by uid 97); 20 Jun 2002 07:55:06 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 21569 invoked by uid 97); 20 Jun 2002 07:55:06 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 20 Jun 2002 07:54:45 -0000 Message-ID: <20020620075445.8619.qmail@icarus.apache.org> From: donaldp@apache.org To: jakarta-ant-myrmidon-cvs@apache.org Subject: cvs commit: jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework AbstractContainerTask.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N donaldp 2002/06/20 00:54:44 Modified: container/src/java/org/apache/myrmidon/components/executor DefaultExecutionFrame.java container/src/java/org/apache/myrmidon/components/workspace DefaultWorkspace.java container/src/java/org/apache/myrmidon/interfaces/executor ExecutionFrame.java framework/src/java/org/apache/myrmidon/framework AbstractContainerTask.java Added: antlib/src/java/org/apache/antlib/template TemplateTask.java Log: Split child frame creation into two methods. One creates a partitioned frame and another doesn't ... Revision Changes Path 1.1 jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/template/TemplateTask.java Index: TemplateTask.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.antlib.template; import java.util.HashMap; import java.util.Map; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.metadata.ModelElement; import org.apache.myrmidon.api.metadata.ModelException; import org.apache.myrmidon.api.metadata.Modeller; import org.apache.myrmidon.framework.AbstractContainerTask; /** * Task used to execute a template that has been defined * via { @link TemplateDefTask}. * * @author Peter Donald */ class TemplateTask extends AbstractContainerTask implements Modeller { private static final Resources REZ = ResourceManager.getPackageResources( TemplateTask.class ); /** * The {@link TemplateDef} that this task is executing. */ private final TemplateDef m_template; /** * Model specified by user. */ private ModelElement m_model; public TemplateTask( final TemplateDef template ) { m_template = template; } public void model( final ModelElement model ) throws ModelException { m_model = model; } public void execute() throws TaskException { final Map attributes = getAttributeMap(); //elements are ignored for the time being ... attributes.size(); } /** * Retrieve a map containing the attributes resolved to * their correct types. * * @return the attribute map * @throws TaskException if required attributes are missing, * extra attributes are present or unable to convert * to correct attribute type */ private Map getAttributeMap() throws TaskException { final Map attributes = new HashMap(); final FeatureDef[] attributeDefs = m_template.getAttributes(); for( int i = 0; i < attributeDefs.length; i++ ) { final FeatureDef attributeDef = attributeDefs[ i ]; final String name = attributeDef.getName(); final String defaultValue = attributeDef.getDefaultValue(); final String strValue = m_model.getAttribute( name, defaultValue ); if( null == strValue ) { if( !attributeDef.isOptional() ) { final String message = REZ.getString( "template.missing-attribute.error", name ); throw new TaskException( message ); } else { continue; } } final Object value = createValue( attributeDef.getType(), strValue ); attributes.put( name, value ); } final String[] attributeNames = m_model.getAttributeNames(); for( int i = 0; i < attributeNames.length; i++ ) { final String name = attributeNames[ i ]; if( !attributes.containsKey( name ) ) { final String message = REZ.getString( "template.extra-attribute.error", name ); throw new TaskException( message ); } } return attributes; } /** * Get the type coresponding tyo specified type. Note that * this mechanism is a complete hack and something more * useful needs to be done in future to allow classes * to be loaded from arbitrary classloaders. */ private Object createValue( final String typeName, final String strValue ) throws TaskException { try { final Class type = Class.forName( typeName ); return convert( type, strValue ); } catch( final Exception e ) { throw new TaskException( e.getMessage(), e ); } } } 1.16 +23 -40 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/DefaultExecutionFrame.java Index: DefaultExecutionFrame.java =================================================================== RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/DefaultExecutionFrame.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- DefaultExecutionFrame.java 20 Jun 2002 07:12:02 -0000 1.15 +++ DefaultExecutionFrame.java 20 Jun 2002 07:54:44 -0000 1.16 @@ -15,8 +15,8 @@ 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.property.PropertyStore; import org.apache.myrmidon.interfaces.executor.ExecutionFrame; +import org.apache.myrmidon.interfaces.property.PropertyStore; /** * Frames in which tasks are executed. @@ -110,57 +110,40 @@ } } - /** - * Create a child execution frame. - * - * @param name the name of child frame relative to current frame - * @param partition true if frame is partition frame - * @return the new child ExecutionFrame - */ public ExecutionFrame createChildFrame( final String name, final File baseDirectory, - final ServiceManager newServiceManager, - final boolean partition ) + final ServiceManager newServiceManager ) { - String newName = getName() + "/" + name; - - File dir = baseDirectory; - if( null == dir ) - { - dir = getBaseDirectory(); - } - - ServiceManager serviceManager; - if( newServiceManager != null ) - { - serviceManager = newServiceManager; - } - else - { - serviceManager = m_serviceManager; - } + final String newName = getName() + "/" + name; + ServiceManager serviceManager = newServiceManager; try { - if( partition ) - { - //What an UGLY Hack!!! - final PropertyStore basePropertyStore = - (PropertyStore)serviceManager.lookup( PropertyStore.ROLE ); - final PropertyStore propertyStore = basePropertyStore.createChildStore(); - final DefaultServiceManager defaultServiceManager = new DefaultServiceManager( serviceManager ); - defaultServiceManager.put( PropertyStore.ROLE, propertyStore ); - serviceManager = defaultServiceManager; - } + //What an UGLY Hack!!! + final PropertyStore basePropertyStore = + (PropertyStore)newServiceManager.lookup( PropertyStore.ROLE ); + final PropertyStore propertyStore = basePropertyStore.createChildStore(); + final DefaultServiceManager defaultServiceManager = + new DefaultServiceManager( newServiceManager ); + defaultServiceManager.put( PropertyStore.ROLE, propertyStore ); + serviceManager = defaultServiceManager; } catch( final ServiceException se ) { - //throw new IllegalStateException( se.toString() ); + throw new IllegalStateException( se.toString() ); } return new DefaultExecutionFrame( newName, - dir, + baseDirectory, serviceManager ); + } + + public ExecutionFrame createChildFrame( String name ) + { + final String newName = getName() + "/" + name; + return new DefaultExecutionFrame( newName, + m_baseDirectory, + m_serviceManager ); } public String toString() 1.92 +3 -3 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.91 retrieving revision 1.92 diff -u -r1.91 -r1.92 --- DefaultWorkspace.java 20 Jun 2002 07:12:53 -0000 1.91 +++ DefaultWorkspace.java 20 Jun 2002 07:54:44 -0000 1.92 @@ -158,7 +158,7 @@ final String projectName = project.getProjectName(); final File baseDirectory = project.getBaseDirectory(); final ExecutionFrame childFrame = - frame.createChildFrame( projectName, baseDirectory, serviceManager, true ); + frame.createChildFrame( projectName, baseDirectory, serviceManager ); final PropertyStore propertyStore = (PropertyStore)childFrame.lookup( PropertyStore.ROLE ); @@ -354,7 +354,7 @@ { final ModelElement targetModel = target.getModel(); final ExecutionFrame frame = - entry.getFrame().createChildFrame( target.getName(), null, null, false ); + entry.getFrame().createChildFrame( target.getName() ); final Executor executor = (Executor)frame.lookup( Executor.ROLE ); executor.execute( targetModel, frame ); } 1.20 +4 -4 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/executor/ExecutionFrame.java Index: ExecutionFrame.java =================================================================== RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/executor/ExecutionFrame.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- ExecutionFrame.java 20 Jun 2002 07:12:02 -0000 1.19 +++ ExecutionFrame.java 20 Jun 2002 07:54:44 -0000 1.20 @@ -85,11 +85,11 @@ * If null will use this frame's base directory. * @param serviceManager the services to use in the child frame. If null * will use this frame's services. - * @param partition true If frame is partition frame. * @return the new child ExecutionFrame. */ ExecutionFrame createChildFrame( String name, File baseDirectory, - ServiceManager serviceManager, - boolean partition ); + ServiceManager serviceManager ); + + ExecutionFrame createChildFrame( String name ); } 1.10 +3 -12 jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/AbstractContainerTask.java Index: AbstractContainerTask.java =================================================================== RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/AbstractContainerTask.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- AbstractContainerTask.java 20 Jun 2002 07:30:38 -0000 1.9 +++ AbstractContainerTask.java 20 Jun 2002 07:54:44 -0000 1.10 @@ -167,7 +167,8 @@ protected final void executeTask( final ModelElement task ) throws TaskException { - final ExecutionFrame frame = getExecutionFrame().createChildFrame( task.getName(), null, null, false ); + final ExecutionFrame frame = + m_frame.createChildFrame( task.getName() ); m_executor.execute( task, frame ); } @@ -243,15 +244,5 @@ final String message = REZ.getString( "container.no-factory.error", roleName ); throw new TaskException( message, te ); } - } - - /** - * Return frame that can be used to execute tasks. - * - * @return the frame - */ - protected ExecutionFrame getExecutionFrame() - { - return m_frame; } } -- To unsubscribe, e-mail: For additional commands, e-mail: