git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269048 13f79535-47bb-0310-9956-ffa450edef68master
@@ -108,7 +108,7 @@ Legal: | |||
<jar jarfile="${build.lib}/myrmidon.jar" | |||
basedir="${build.classes}" | |||
manifest="${manifest.dir}/myrmidon-manifest.mf"> | |||
<include name="org/apache/ant/**" /> | |||
<include name="org/apache/**" /> | |||
<exclude name="org/apache/ant/launcher/*" /> | |||
<exclude name="org/apache/ant/tasks/**" /> | |||
<exclude name="org/apache/ant/convert/core/**" /> | |||
@@ -30,8 +30,8 @@ import org.apache.ant.project.ProjectEngine; | |||
import org.apache.ant.project.ProjectListener; | |||
import org.apache.ant.runtime.AntEngine; | |||
import org.apache.ant.runtime.DefaultAntEngine; | |||
import org.apache.ant.tasklet.JavaVersion; | |||
import org.apache.ant.tasklet.TaskletContext; | |||
import org.apache.myrmidon.api.JavaVersion; | |||
import org.apache.myrmidon.api.TaskContext; | |||
import org.apache.ant.tasklet.engine.TaskletEngine; | |||
import org.apache.avalon.excalibur.cli.CLArgsParser; | |||
import org.apache.avalon.excalibur.cli.CLOption; | |||
@@ -495,7 +495,7 @@ public class Main | |||
//defines.put( AntContextResources.TASKLIB_DIR, m_taskLibDir ); | |||
//defines.put( TaskletContext.JAVA_VERSION, getJavaVersion() ); | |||
final TaskletContext context = project.getContext(); | |||
final TaskContext context = project.getContext(); | |||
addToContext( context, defines ); | |||
//Add system properties second so that they overide user-defined properties | |||
@@ -508,7 +508,7 @@ public class Main | |||
* @param context the context | |||
* @param map the map of names->values | |||
*/ | |||
protected void addToContext( final TaskletContext context, final Map map ) | |||
protected void addToContext( final TaskContext context, final Map map ) | |||
{ | |||
final Iterator keys = map.keySet().iterator(); | |||
@@ -11,9 +11,9 @@ import java.util.ArrayList; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.project.Project; | |||
import org.apache.ant.project.ProjectEngine; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
import org.apache.ant.tasklet.DefaultTaskletContext; | |||
import org.apache.ant.tasklet.TaskletContext; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
import org.apache.myrmidon.api.DefaultTaskContext; | |||
import org.apache.myrmidon.api.TaskContext; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.Composable; | |||
@@ -25,20 +25,20 @@ import org.apache.avalon.framework.context.Context; | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class AntCall | |||
extends AbstractTasklet | |||
extends AbstractTask | |||
implements Composable | |||
{ | |||
protected ProjectEngine m_projectEngine; | |||
protected Project m_project; | |||
protected String m_target; | |||
protected ArrayList m_properties = new ArrayList(); | |||
protected TaskletContext m_childContext; | |||
protected TaskContext m_childContext; | |||
protected ComponentManager m_componentManager; | |||
public void contextualize( final Context context ) | |||
{ | |||
super.contextualize( context ); | |||
m_childContext = new DefaultTaskletContext( getContext() ); | |||
m_childContext = new DefaultTaskContext( getContext() ); | |||
} | |||
public void compose( final ComponentManager componentManager ) | |||
@@ -8,7 +8,7 @@ | |||
package org.apache.ant.modules.basic; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
/** | |||
* This is the echo task to display a message. | |||
@@ -16,7 +16,7 @@ import org.apache.ant.tasklet.AbstractTasklet; | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class Echo | |||
extends AbstractTasklet | |||
extends AbstractTask | |||
{ | |||
protected String m_message; | |||
@@ -13,8 +13,8 @@ import org.apache.ant.configuration.Configurer; | |||
import org.apache.ant.convert.Converter; | |||
import org.apache.ant.tasklet.DataType; | |||
import org.apache.ant.tasklet.engine.DataTypeEngine; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
import org.apache.ant.tasklet.TaskletContext; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
import org.apache.myrmidon.api.TaskContext; | |||
import org.apache.ant.tasklet.engine.TaskletEngine; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
@@ -30,7 +30,7 @@ import org.apache.avalon.framework.context.Resolvable; | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class Property | |||
extends AbstractTasklet | |||
extends AbstractTask | |||
implements Configurable, Composable | |||
{ | |||
protected String m_name; | |||
@@ -158,7 +158,7 @@ public class Property | |||
throw new AntException( "Value must be specified" ); | |||
} | |||
final TaskletContext context = getContext(); | |||
final TaskContext context = getContext(); | |||
Object value = m_value; | |||
@@ -178,7 +178,7 @@ public class Property | |||
} | |||
else | |||
{ | |||
context.setProperty( m_name, value, TaskletContext.PARENT ); | |||
context.setProperty( m_name, value, TaskContext.PARENT ); | |||
} | |||
} | |||
} |
@@ -9,8 +9,8 @@ package org.apache.ant.modules.basic; | |||
import java.io.File; | |||
import org.apache.ant.convert.AbstractConverter; | |||
import org.apache.ant.tasklet.TaskletContext; | |||
import org.apache.avalon.framework.context.Context; | |||
import org.apache.myrmidon.api.TaskContext; | |||
/** | |||
* String to file converter | |||
@@ -28,8 +28,8 @@ public class StringToFileConverter | |||
public Object convert( final Object original, final Context context ) | |||
throws Exception | |||
{ | |||
final TaskletContext taskletContext = (TaskletContext)context; | |||
return taskletContext.resolveFile( (String)original ); | |||
final TaskContext taskContext = (TaskContext)context; | |||
return taskContext.resolveFile( (String)original ); | |||
} | |||
} | |||
@@ -11,7 +11,7 @@ import java.io.File; | |||
import java.net.MalformedURLException; | |||
import java.net.URL; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
import org.apache.ant.tasklet.engine.TaskletEngine; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
@@ -24,7 +24,7 @@ import org.apache.avalon.framework.camelot.RegistryException; | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public abstract class AbstractResourceRegisterer | |||
extends AbstractTasklet | |||
extends AbstractTask | |||
implements Composable | |||
{ | |||
protected String m_lib; | |||
@@ -13,7 +13,7 @@ import java.net.URL; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.convert.engine.ConverterEngine; | |||
import org.apache.ant.convert.engine.DefaultConverterInfo; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
import org.apache.ant.tasklet.engine.TaskletEngine; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
@@ -28,7 +28,7 @@ import org.apache.avalon.framework.camelot.RegistryException; | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class RegisterConverter | |||
extends AbstractTasklet | |||
extends AbstractTask | |||
implements Composable | |||
{ | |||
protected String m_sourceType; | |||
@@ -11,7 +11,7 @@ import java.io.File; | |||
import java.net.MalformedURLException; | |||
import java.net.URL; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
import org.apache.ant.tasklet.engine.TaskletEngine; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
@@ -24,7 +24,7 @@ import org.apache.avalon.framework.camelot.DeploymentException; | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class RegisterTasklib | |||
extends AbstractTasklet | |||
extends AbstractTask | |||
implements Composable | |||
{ | |||
protected String m_lib; | |||
@@ -8,7 +8,7 @@ | |||
package org.apache.ant.modules.test; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
import org.apache.avalon.framework.configuration.Configuration; | |||
import org.apache.avalon.framework.configuration.Configurable; | |||
import org.apache.avalon.framework.configuration.ConfigurationException; | |||
@@ -19,7 +19,7 @@ import org.apache.avalon.framework.configuration.ConfigurationException; | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class ConfigurationTest | |||
extends AbstractTasklet | |||
extends AbstractTask | |||
implements Configurable | |||
{ | |||
private String m_message; | |||
@@ -8,7 +8,7 @@ | |||
package org.apache.ant.modules.test; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
/** | |||
* This is to test whether content is added. | |||
@@ -16,7 +16,7 @@ import org.apache.ant.tasklet.AbstractTasklet; | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class ContentTest | |||
extends AbstractTasklet | |||
extends AbstractTask | |||
{ | |||
public void addContent( final Integer value ) | |||
{ | |||
@@ -31,7 +31,7 @@ public class ContentTest | |||
*/ | |||
public void execute() | |||
throws AntException | |||
throws Exception | |||
{ | |||
} | |||
} |
@@ -9,7 +9,7 @@ | |||
package org.apache.ant.modules.test; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
/** | |||
* Test conversion of all the primitive types. | |||
@@ -17,7 +17,7 @@ import org.apache.ant.tasklet.AbstractTasklet; | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class PrimitiveTypesTest | |||
extends AbstractTasklet | |||
extends AbstractTask | |||
{ | |||
public void setInteger( final Integer value ) | |||
{ | |||
@@ -8,7 +8,7 @@ | |||
package org.apache.ant.modules.test; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
/** | |||
* Test sub-elements addition. | |||
@@ -16,7 +16,7 @@ import org.apache.ant.tasklet.AbstractTasklet; | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class SubElementTest | |||
extends AbstractTasklet | |||
extends AbstractTask | |||
{ | |||
public static final class Beep | |||
{ | |||
@@ -13,8 +13,8 @@ import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.Iterator; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.DefaultTaskletContext; | |||
import org.apache.ant.tasklet.TaskletContext; | |||
import org.apache.myrmidon.api.DefaultTaskContext; | |||
import org.apache.myrmidon.api.TaskContext; | |||
/** | |||
* Default project implementation. | |||
@@ -24,7 +24,7 @@ import org.apache.ant.tasklet.TaskletContext; | |||
public class DefaultProject | |||
implements Project | |||
{ | |||
protected final TaskletContext m_baseContext = new DefaultTaskletContext(); | |||
protected final TaskContext m_baseContext = new DefaultTaskContext(); | |||
protected final HashMap m_targets = new HashMap(); | |||
protected Target m_implicitTarget; | |||
protected String m_defaultTarget; | |||
@@ -87,7 +87,7 @@ public class DefaultProject | |||
* | |||
* @return the context | |||
*/ | |||
public TaskletContext getContext() | |||
public TaskContext getContext() | |||
{ | |||
return m_baseContext; | |||
} | |||
@@ -11,7 +11,7 @@ import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Iterator; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.TaskletContext; | |||
import org.apache.myrmidon.api.TaskContext; | |||
import org.apache.ant.util.Condition; | |||
import org.apache.avalon.framework.ExceptionUtil; | |||
import org.apache.avalon.framework.configuration.Configuration; | |||
@@ -118,8 +118,8 @@ public class DefaultProjectBuilder | |||
project.setDefaultTargetName( defaultTarget ); | |||
//setup basic context of project | |||
final TaskletContext context = project.getContext(); | |||
context.setProperty( TaskletContext.BASE_DIRECTORY, baseDirectory ); | |||
final TaskContext context = project.getContext(); | |||
context.setProperty( TaskContext.BASE_DIRECTORY, baseDirectory ); | |||
context.setProperty( Project.PROJECT_FILE, file ); | |||
context.setProperty( Project.PROJECT, projectName ); | |||
@@ -10,8 +10,8 @@ package org.apache.ant.project; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.DefaultTaskletContext; | |||
import org.apache.ant.tasklet.TaskletContext; | |||
import org.apache.myrmidon.api.DefaultTaskContext; | |||
import org.apache.myrmidon.api.TaskContext; | |||
import org.apache.ant.tasklet.engine.DefaultTaskletEngine; | |||
import org.apache.ant.tasklet.engine.TaskletEngine; | |||
import org.apache.ant.util.Condition; | |||
@@ -87,7 +87,7 @@ public class DefaultProjectEngine | |||
//HACK: should do this a better way !!!!!! | |||
m_componentManager.put( "org.apache.ant.project.Project", project ); | |||
final TaskletContext context = project.getContext(); | |||
final TaskContext context = project.getContext(); | |||
final String projectName = (String)context.getProperty( Project.PROJECT ); | |||
@@ -110,7 +110,7 @@ public class DefaultProjectEngine | |||
* @param context the context | |||
* @exception AntException if an error occurs | |||
*/ | |||
public void execute( Project project, String target, TaskletContext context ) | |||
public void execute( Project project, String target, TaskContext context ) | |||
throws AntException | |||
{ | |||
execute( project, target, context, new ArrayList() ); | |||
@@ -127,7 +127,7 @@ public class DefaultProjectEngine | |||
*/ | |||
protected void execute( final Project project, | |||
final String targetName, | |||
final TaskletContext context, | |||
final TaskContext context, | |||
final ArrayList done ) | |||
throws AntException | |||
{ | |||
@@ -165,7 +165,7 @@ public class DefaultProjectEngine | |||
*/ | |||
protected void executeTarget( final String targetName, | |||
final Target target, | |||
final TaskletContext context ) | |||
final TaskContext context ) | |||
throws AntException | |||
{ | |||
//is this necessary ? I think not but .... | |||
@@ -173,7 +173,7 @@ public class DefaultProjectEngine | |||
//m_componentManager.put( "org.apache.ant.project.Target", target ); | |||
//create project context and set target name | |||
final TaskletContext targetContext = new DefaultTaskletContext( context ); | |||
final TaskContext targetContext = new DefaultTaskContext( context ); | |||
targetContext.setProperty( Project.TARGET, targetName ); | |||
//notify listeners | |||
@@ -196,7 +196,7 @@ public class DefaultProjectEngine | |||
*/ | |||
protected void executeTargetWork( final String name, | |||
final Target target, | |||
final TaskletContext context ) | |||
final TaskContext context ) | |||
{ | |||
//check the condition associated with target. | |||
//if it is not satisfied then skip target | |||
@@ -229,7 +229,7 @@ public class DefaultProjectEngine | |||
* @param context the context | |||
* @exception AntException if an error occurs | |||
*/ | |||
protected void executeTask( final Configuration task, final TaskletContext context ) | |||
protected void executeTask( final Configuration task, final TaskContext context ) | |||
throws AntException | |||
{ | |||
final String name = task.getName(); | |||
@@ -241,7 +241,7 @@ public class DefaultProjectEngine | |||
//final TaskletContext targetContext = new DefaultTaskletContext( context ); | |||
//is setting name even necessary ??? | |||
context.setProperty( TaskletContext.NAME, name ); | |||
context.setProperty( TaskContext.NAME, name ); | |||
//notify listeners | |||
m_listenerSupport.taskletStarted( name ); | |||
@@ -9,7 +9,7 @@ package org.apache.ant.project; | |||
import java.util.Iterator; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.TaskletContext; | |||
import org.apache.myrmidon.api.TaskContext; | |||
import org.apache.avalon.framework.component.Component; | |||
/** | |||
@@ -65,5 +65,5 @@ public interface Project | |||
* | |||
* @return the context | |||
*/ | |||
TaskletContext getContext(); | |||
TaskContext getContext(); | |||
} |
@@ -8,7 +8,7 @@ | |||
package org.apache.ant.project; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.TaskletContext; | |||
import org.apache.myrmidon.api.TaskContext; | |||
import org.apache.ant.tasklet.engine.TaskletEngine; | |||
import org.apache.avalon.framework.component.Component; | |||
@@ -55,6 +55,6 @@ public interface ProjectEngine | |||
* @param context the context | |||
* @exception AntException if an error occurs | |||
*/ | |||
void execute( Project project, String target, TaskletContext context ) | |||
void execute( Project project, String target, TaskContext context ) | |||
throws AntException; | |||
} |
@@ -14,7 +14,7 @@ import org.apache.ant.configuration.Configurer; | |||
import org.apache.ant.convert.engine.ConverterEngine; | |||
import org.apache.ant.project.ProjectBuilder; | |||
import org.apache.ant.project.ProjectEngine; | |||
import org.apache.ant.tasklet.JavaVersion; | |||
import org.apache.myrmidon.api.JavaVersion; | |||
import org.apache.ant.tasklet.engine.DataTypeEngine; | |||
import org.apache.ant.tasklet.engine.TaskletEngine; | |||
import org.apache.ant.tasklet.engine.TskDeployer; | |||
@@ -1,29 +0,0 @@ | |||
/* | |||
* 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 file. | |||
*/ | |||
package org.apache.ant.tasklet; | |||
import org.apache.avalon.framework.component.Component; | |||
/** | |||
* This represents the individual tasks. | |||
* Particular instances can also implement Initializable | |||
* and/or Disposable, in which case init()/dispose() will | |||
* be called at appropriate time. | |||
* The task can also implement Composable in which case required | |||
* facilities will be passed via a ComponentManager. The actual | |||
* facilties is determined by particular task engine but will usually | |||
* include ProjectEngine and TaskEngine. | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public interface Tasklet | |||
extends Component | |||
{ | |||
void execute() | |||
throws Exception; | |||
} |
@@ -14,8 +14,8 @@ import org.apache.ant.configuration.DefaultConfigurer; | |||
import org.apache.avalon.framework.configuration.Configuration; | |||
import org.apache.avalon.framework.configuration.Configurable; | |||
import org.apache.ant.convert.engine.ConverterEngine; | |||
import org.apache.ant.tasklet.Tasklet; | |||
import org.apache.ant.tasklet.TaskletContext; | |||
import org.apache.myrmidon.api.Task; | |||
import org.apache.myrmidon.api.TaskContext; | |||
import org.apache.avalon.framework.logger.AbstractLoggable; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
@@ -98,43 +98,44 @@ public class DefaultTaskletEngine | |||
lookup( "org.apache.ant.convert.engine.ConverterEngine" ); | |||
} | |||
public void execute( final Configuration task, final TaskletContext context ) | |||
public void execute( final Configuration taskData, final TaskContext context ) | |||
throws AntException | |||
{ | |||
getLogger().debug( "Creating" ); | |||
final Tasklet tasklet = createTasklet( task.getName() ); | |||
setupLogger( tasklet ); | |||
final Task task = createTask( taskData.getName() ); | |||
setupLogger( task ); | |||
getLogger().debug( "Contextualizing" ); | |||
doContextualize( tasklet, task, context ); | |||
doContextualize( task, taskData, context ); | |||
getLogger().debug( "Composing" ); | |||
doCompose( tasklet, task ); | |||
doCompose( task, taskData ); | |||
getLogger().debug( "Configuring" ); | |||
doConfigure( tasklet, task, context ); | |||
doConfigure( task, taskData, context ); | |||
getLogger().debug( "Initializing" ); | |||
doInitialize( tasklet, task ); | |||
doInitialize( task, taskData ); | |||
getLogger().debug( "Running" ); | |||
try { tasklet.execute(); } | |||
try { task.execute(); } | |||
catch( final Exception e ) | |||
{ | |||
throw new AntException( "Error executing task", e ); | |||
} | |||
getLogger().debug( "Disposing" ); | |||
doDispose( tasklet, task ); | |||
doDispose( task, taskData ); | |||
} | |||
protected Tasklet createTasklet( final String name ) | |||
protected Task createTask( final String name ) | |||
throws AntException | |||
{ | |||
try | |||
{ | |||
final Locator locator = (Locator)m_locatorRegistry.getInfo( name, Locator.class ); | |||
return (Tasklet)m_factory.create( locator, Tasklet.class ); | |||
return (Task)m_factory.create( locator, Task.class ); | |||
} | |||
catch( final RegistryException re ) | |||
{ | |||
@@ -146,80 +147,80 @@ public class DefaultTaskletEngine | |||
} | |||
} | |||
protected void doConfigure( final Tasklet tasklet, | |||
final Configuration task, | |||
final TaskletContext context ) | |||
protected void doConfigure( final Task task, | |||
final Configuration taskData, | |||
final TaskContext context ) | |||
throws AntException | |||
{ | |||
try { m_configurer.configure( tasklet, task, context ); } | |||
try { m_configurer.configure( task, taskData, context ); } | |||
catch( final Throwable throwable ) | |||
{ | |||
throw new AntException( "Error configuring task " + task.getName() + " at " + | |||
task.getLocation() + "(Reason: " + | |||
throw new AntException( "Error configuring task " + taskData.getName() + " at " + | |||
taskData.getLocation() + "(Reason: " + | |||
throwable.getMessage() + ")", throwable ); | |||
} | |||
} | |||
protected void doCompose( final Tasklet tasklet, final Configuration task ) | |||
protected void doCompose( final Task task, final Configuration taskData ) | |||
throws AntException | |||
{ | |||
if( tasklet instanceof Composable ) | |||
if( task instanceof Composable ) | |||
{ | |||
try { ((Composable)tasklet).compose( m_componentManager ); } | |||
try { ((Composable)task).compose( m_componentManager ); } | |||
catch( final Throwable throwable ) | |||
{ | |||
throw new AntException( "Error composing task " + task.getName() + " at " + | |||
task.getLocation() + "(Reason: " + | |||
throw new AntException( "Error composing task " + taskData.getName() + " at " + | |||
taskData.getLocation() + "(Reason: " + | |||
throwable.getMessage() + ")", throwable ); | |||
} | |||
} | |||
} | |||
protected void doContextualize( final Tasklet tasklet, | |||
final Configuration task, | |||
final TaskletContext context ) | |||
protected void doContextualize( final Task task, | |||
final Configuration taskData, | |||
final TaskContext context ) | |||
throws AntException | |||
{ | |||
try | |||
{ | |||
if( tasklet instanceof Contextualizable ) | |||
if( task instanceof Contextualizable ) | |||
{ | |||
((Contextualizable)tasklet).contextualize( context ); | |||
((Contextualizable)task).contextualize( context ); | |||
} | |||
} | |||
catch( final Throwable throwable ) | |||
{ | |||
throw new AntException( "Error contextualizing task " + task.getName() + " at " + | |||
task.getLocation() + "(Reason: " + | |||
throw new AntException( "Error contextualizing task " + taskData.getName() + " at " + | |||
taskData.getLocation() + "(Reason: " + | |||
throwable.getMessage() + ")", throwable ); | |||
} | |||
} | |||
protected void doDispose( final Tasklet tasklet, final Configuration task ) | |||
protected void doDispose( final Task task, final Configuration taskData ) | |||
throws AntException | |||
{ | |||
if( tasklet instanceof Disposable ) | |||
if( task instanceof Disposable ) | |||
{ | |||
try { ((Disposable)tasklet).dispose(); } | |||
try { ((Disposable)task).dispose(); } | |||
catch( final Throwable throwable ) | |||
{ | |||
throw new AntException( "Error disposing task " + task.getName() + " at " + | |||
task.getLocation() + "(Reason: " + | |||
throw new AntException( "Error disposing task " + taskData.getName() + " at " + | |||
taskData.getLocation() + "(Reason: " + | |||
throwable.getMessage() + ")", throwable ); | |||
} | |||
} | |||
} | |||
protected void doInitialize( final Tasklet tasklet, final Configuration task ) | |||
protected void doInitialize( final Task task, final Configuration taskData ) | |||
throws AntException | |||
{ | |||
if( tasklet instanceof Initializable ) | |||
if( task instanceof Initializable ) | |||
{ | |||
try { ((Initializable)tasklet).initialize(); } | |||
try { ((Initializable)task).initialize(); } | |||
catch( final Throwable throwable ) | |||
{ | |||
throw new AntException( "Error initializing task " + task.getName() + " at " + | |||
task.getLocation() + "(Reason: " + | |||
throw new AntException( "Error initializing task " + taskData.getName() + " at " + | |||
taskData.getLocation() + "(Reason: " + | |||
throwable.getMessage() + ")", throwable ); | |||
} | |||
} | |||
@@ -10,7 +10,7 @@ package org.apache.ant.tasklet.engine; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.convert.engine.ConverterEngine; | |||
import org.apache.ant.tasklet.engine.DataTypeEngine; | |||
import org.apache.ant.tasklet.TaskletContext; | |||
import org.apache.myrmidon.api.TaskContext; | |||
import org.apache.avalon.framework.configuration.Configuration; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
@@ -60,6 +60,6 @@ public interface TaskletEngine | |||
* @param task the configruation data for task | |||
* @exception AntException if an error occurs | |||
*/ | |||
void execute( Configuration task, TaskletContext context ) | |||
void execute( Configuration task, TaskContext context ) | |||
throws AntException; | |||
} |
@@ -5,7 +5,7 @@ | |||
* version 1.1, a copy of which has been included with this distribution in | |||
* the LICENSE file. | |||
*/ | |||
package org.apache.ant.tasklet; | |||
package org.apache.myrmidon.api; | |||
import org.apache.ant.AntException; | |||
import org.apache.avalon.framework.activity.Disposable; | |||
@@ -15,16 +15,16 @@ import org.apache.avalon.framework.context.Contextualizable; | |||
import org.apache.avalon.framework.logger.AbstractLoggable; | |||
/** | |||
* This is abstract base class for tasklets. | |||
* This is the class that Task writers should extend to provide custom tasks. | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public abstract class AbstractTasklet | |||
public abstract class AbstractTask | |||
extends AbstractLoggable | |||
implements Tasklet, Contextualizable, Initializable, Disposable | |||
implements Task, Contextualizable, Initializable, Disposable | |||
{ | |||
///Variable to hold context for use by sub-classes | |||
private TaskletContext m_context; | |||
private TaskContext m_context; | |||
/** | |||
* Retrieve context from container. | |||
@@ -33,7 +33,7 @@ public abstract class AbstractTasklet | |||
*/ | |||
public void contextualize( final Context context ) | |||
{ | |||
m_context = (TaskletContext)context; | |||
m_context = (TaskContext)context; | |||
} | |||
/** | |||
@@ -62,7 +62,7 @@ public abstract class AbstractTasklet | |||
* | |||
* @return the context | |||
*/ | |||
protected final TaskletContext getContext() | |||
protected final TaskContext getContext() | |||
{ | |||
return m_context; | |||
} |
@@ -5,39 +5,38 @@ | |||
* version 1.1, a copy of which has been included with this distribution in | |||
* the LICENSE file. | |||
*/ | |||
package org.apache.ant.tasklet; | |||
package org.apache.myrmidon.api; | |||
import java.io.File; | |||
import org.apache.ant.AntException; | |||
import org.apache.avalon.framework.context.DefaultContext; | |||
import org.apache.avalon.framework.context.ContextException; | |||
import org.apache.avalon.excalibur.property.PropertyException; | |||
import org.apache.avalon.excalibur.property.PropertyUtil; | |||
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.context.ContextException; | |||
import org.apache.avalon.framework.context.DefaultContext; | |||
/** | |||
* Default implementation of TaskletContext. | |||
* It represents the *Context* in which a task can be executed. | |||
* Default implementation of TaskContext. | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class DefaultTaskletContext | |||
public class DefaultTaskContext | |||
extends DefaultContext | |||
implements TaskletContext | |||
implements TaskContext | |||
{ | |||
protected File m_baseDirectory; | |||
private File m_baseDirectory; | |||
/** | |||
* Constructor for Context with no parent contexts. | |||
*/ | |||
public DefaultTaskletContext() | |||
public DefaultTaskContext() | |||
{ | |||
this( null ); | |||
} | |||
/** | |||
* Constructor. | |||
*/ | |||
public DefaultTaskletContext( final TaskletContext parent ) | |||
public DefaultTaskContext( final TaskContext parent ) | |||
{ | |||
super( parent ); | |||
@@ -64,7 +63,7 @@ public class DefaultTaskletContext | |||
} | |||
} | |||
/** | |||
* Retrieve Name of tasklet. | |||
* | |||
@@ -93,10 +92,10 @@ public class DefaultTaskletContext | |||
} | |||
/** | |||
* Resolve filename. | |||
* Resolve filename. | |||
* This involves resolving it against baseDirectory and | |||
* removing ../ and ./ references. It also means formatting | |||
* it appropriately for the particular OS (ie different OS have | |||
* removing ../ and ./ references. It also means formatting | |||
* it appropriately for the particular OS (ie different OS have | |||
* different volumes, file conventions etc) | |||
* | |||
* @param filename the filename to resolve | |||
@@ -110,7 +109,7 @@ public class DefaultTaskletContext | |||
} | |||
/** | |||
* Resolve property. | |||
* Resolve property. | |||
* This evaluates all property substitutions based on current context. | |||
* | |||
* @param property the property to resolve | |||
@@ -151,7 +150,7 @@ public class DefaultTaskletContext | |||
{ | |||
setProperty( name, value, CURRENT ); | |||
} | |||
/** | |||
* Set property value. | |||
* | |||
@@ -164,23 +163,23 @@ public class DefaultTaskletContext | |||
if( CURRENT == scope ) put( name, value ); | |||
else if( PARENT == scope ) | |||
{ | |||
if( null == m_parent ) | |||
if( null == m_parent ) | |||
{ | |||
throw new AntException( "Can't set a property with parent scope when context " + | |||
" has no parent" ); | |||
" has no parent" ); | |||
} | |||
else | |||
{ | |||
((DefaultTaskletContext)m_parent).put( name, value ); | |||
((DefaultTaskContext)m_parent).put( name, value ); | |||
} | |||
} | |||
else if( TOP_LEVEL == scope ) | |||
{ | |||
DefaultTaskletContext context = this; | |||
DefaultTaskContext context = this; | |||
while( null != context.m_parent ) | |||
{ | |||
context = (DefaultTaskletContext)context.m_parent; | |||
context = (DefaultTaskContext)context.m_parent; | |||
} | |||
context.put( name, value ); | |||
@@ -194,7 +193,7 @@ public class DefaultTaskletContext | |||
/** | |||
* put a value in context. | |||
* This put method is overidden so new baseDirectory can be saved | |||
* This put method is overidden so new baseDirectory can be saved | |||
* in member variable. | |||
* | |||
* @param key the key | |||
@@ -228,19 +227,19 @@ public class DefaultTaskletContext | |||
if( BASE_DIRECTORY.equals( name ) && !( value instanceof File ) ) | |||
{ | |||
throw new AntException( "Property " + BASE_DIRECTORY + | |||
" must have a value of type " + | |||
" must have a value of type " + | |||
File.class.getName() ); | |||
} | |||
else if( NAME.equals( name ) && !( value instanceof String ) ) | |||
{ | |||
throw new AntException( "Property " + NAME + | |||
" must have a value of type " + | |||
" must have a value of type " + | |||
String.class.getName() ); | |||
} | |||
else if( JAVA_VERSION.equals( name ) && !( value instanceof JavaVersion ) ) | |||
{ | |||
throw new AntException( "property " + JAVA_VERSION + | |||
" must have a value of type " + | |||
" must have a value of type " + | |||
JavaVersion.class.getName() ); | |||
} | |||
} |
@@ -5,7 +5,7 @@ | |||
* version 1.1, a copy of which has been included with this distribution in | |||
* the LICENSE file. | |||
*/ | |||
package org.apache.ant.tasklet; | |||
package org.apache.myrmidon.api; | |||
import org.apache.avalon.framework.ValuedEnum; | |||
@@ -0,0 +1,39 @@ | |||
/* | |||
* 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 file. | |||
*/ | |||
package org.apache.myrmidon.api; | |||
/** | |||
* This is the interface that tasks implement to be executed in Myrmidon runtime. | |||
* | |||
* Instances can also implement the Avalon lifecycle methods | |||
* Loggable, Contextualizable, Composable, Initializable and Disposable. | |||
* Each of these lifecycle stages will be executed at appropriate time. | |||
* | |||
* Tasks can also choose to implement Configurable if they wish to directly | |||
* receive the Configuration data representing the task. If this interface is | |||
* not implemented then the engine will be responsbil for mapping configuration | |||
* to task object. | |||
* | |||
* The Components passed in via ComponentManager are determined by container. | |||
* Most containers will include the Engine and Registrys. | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public interface Task | |||
{ | |||
/** | |||
* Execute task. | |||
* This method is called to perform actual work associated with task. | |||
* It is called after Task has been Configured and Initialized and before | |||
* beig Disposed (If task implements appropriate interfaces). | |||
* | |||
* @exception Exception if an error occurs | |||
*/ | |||
void execute() | |||
throws Exception; | |||
} |
@@ -5,19 +5,22 @@ | |||
* version 1.1, a copy of which has been included with this distribution in | |||
* the LICENSE file. | |||
*/ | |||
package org.apache.ant.tasklet; | |||
package org.apache.myrmidon.api; | |||
import java.io.File; | |||
import org.apache.avalon.framework.context.Context; | |||
import org.apache.avalon.framework.Enum; | |||
import org.apache.avalon.framework.ValuedEnum; | |||
import org.apache.avalon.framework.context.Context; | |||
/** | |||
* This represents the *Context* in which a task can be executed. | |||
* This interface represents the <em>Context</em> in which Task is executed. | |||
* Like other Component APIs the TaskContext represents the communication | |||
* path between the container and the Task. | |||
* Unlike other APIs the Logging is provided through another interface (Loggable) | |||
* as is access to Peer components (via Composable). | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public interface TaskletContext | |||
public interface TaskContext | |||
extends Context | |||
{ | |||
//these values are used when setting properties to indicate the scope at | |||
@@ -37,14 +40,14 @@ public interface TaskletContext | |||
* @return the version of JVM | |||
*/ | |||
JavaVersion getJavaVersion(); | |||
/** | |||
* Retrieve Name of tasklet. | |||
* | |||
* @return the name | |||
*/ | |||
String getName(); | |||
/** | |||
* Retrieve base directory. | |||
* | |||
@@ -53,10 +56,10 @@ public interface TaskletContext | |||
File getBaseDirectory(); | |||
/** | |||
* Resolve filename. | |||
* Resolve filename. | |||
* This involves resolving it against baseDirectory and | |||
* removing ../ and ./ references. It also means formatting | |||
* it appropriately for the particular OS (ie different OS have | |||
* removing ../ and ./ references. It also means formatting | |||
* it appropriately for the particular OS (ie different OS have | |||
* different volumes, file conventions etc) | |||
* | |||
* @param filename the filename to resolve | |||
@@ -65,7 +68,7 @@ public interface TaskletContext | |||
File resolveFile( String filename ); | |||
/** | |||
* Resolve property. | |||
* Resolve property. | |||
* This evaluates all property substitutions based on current context. | |||
* | |||
* @param property the property to resolve | |||
@@ -88,7 +91,7 @@ public interface TaskletContext | |||
* @param value the value of property | |||
*/ | |||
void setProperty( String name, Object value ); | |||
/** | |||
* Set property value. | |||
* | |||
@@ -96,7 +99,7 @@ public interface TaskletContext | |||
* @param value the value of property | |||
* @param scope the scope at which to set property | |||
*/ | |||
void setProperty( String name, Object value, ScopeEnum scope ); | |||
void setProperty( String name, Object value, ScopeEnum scope ); | |||
/** | |||
* Safe wrapper class for Scope enums. |