Browse Source

Tasks don't need to worry about location (thats a container concern) nor do they need to worry about their own model (thats also a container concern).

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270172 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
e741c1fe35
2 changed files with 30 additions and 190 deletions
  1. +15
    -95
      proposal/myrmidon/src/main/org/apache/tools/ant/Task.java
  2. +15
    -95
      proposal/myrmidon/src/todo/org/apache/tools/ant/Task.java

+ 15
- 95
proposal/myrmidon/src/main/org/apache/tools/ant/Task.java View File

@@ -15,14 +15,10 @@ public abstract class Task
{
protected Target target;
protected String description;
protected Location location = Location.UNKNOWN_LOCATION;
protected String taskName;
protected String taskType;
private boolean invalid;
protected RuntimeConfigurable wrapper;

private UnknownElement replacement;

/**
* Sets a description of the current action. It will be usefull in
* commenting what we are doing.
@@ -34,16 +30,6 @@ public abstract class Task
description = desc;
}

/**
* Sets the file location where this task was defined.
*
* @param location The new Location value
*/
public void setLocation( Location location )
{
this.location = location;
}

/**
* Sets the target object of this task.
*
@@ -69,16 +55,6 @@ public abstract class Task
return description;
}

/**
* Returns the file location where this task was defined.
*
* @return The Location value
*/
public Location getLocation()
{
return location;
}

/**
* Get the Target to which this task belongs
*
@@ -119,39 +95,22 @@ public abstract class Task
public final void perform()
throws TaskException
{
if( !invalid )
try
{
project.fireTaskStarted( this );
maybeConfigure();
execute();
project.fireTaskFinished( this, null );
}
catch( TaskException te )
{
try
{
project.fireTaskStarted( this );
maybeConfigure();
execute();
project.fireTaskFinished( this, null );
}
catch( TaskException te )
{
if( te instanceof BuildException )
{
BuildException be = (BuildException)te;
if( be.getLocation() == Location.UNKNOWN_LOCATION )
{
be.setLocation( getLocation() );
}
}
project.fireTaskFinished( this, te );
throw te;
}
catch( RuntimeException re )
{
project.fireTaskFinished( this, re );
throw re;
}
project.fireTaskFinished( this, te );
throw te;
}
else
catch( RuntimeException re )
{
UnknownElement ue = getReplacement();
Task task = ue.getTask();
task.perform();
project.fireTaskFinished( this, re );
throw re;
}
}

@@ -208,16 +167,9 @@ public abstract class Task
public void maybeConfigure()
throws TaskException
{
if( !invalid )
if( wrapper != null )
{
if( wrapper != null )
{
wrapper.maybeConfigure( project );
}
}
else
{
getReplacement();
wrapper.maybeConfigure( project );
}
}

@@ -245,37 +197,5 @@ public abstract class Task
{
this.taskType = type;
}

/**
* Mark this task as invalid.
*/
final void markInvalid()
{
invalid = true;
}

/**
* Create an UnknownElement that can be used to replace this task.
*
* @return The Replacement value
*/
private UnknownElement getReplacement()
throws TaskException
{
if( replacement == null )
{
replacement = new UnknownElement( taskType );
replacement.setProject( project );
replacement.setTaskType( taskType );
replacement.setTaskName( taskName );
replacement.setLocation( location );
replacement.setOwningTarget( target );
replacement.setRuntimeConfigurableWrapper( wrapper );
wrapper.setProxy( replacement );
target.replaceChild( this, replacement );
replacement.maybeConfigure();
}
return replacement;
}
}


+ 15
- 95
proposal/myrmidon/src/todo/org/apache/tools/ant/Task.java View File

@@ -15,14 +15,10 @@ public abstract class Task
{
protected Target target;
protected String description;
protected Location location = Location.UNKNOWN_LOCATION;
protected String taskName;
protected String taskType;
private boolean invalid;
protected RuntimeConfigurable wrapper;

private UnknownElement replacement;

/**
* Sets a description of the current action. It will be usefull in
* commenting what we are doing.
@@ -34,16 +30,6 @@ public abstract class Task
description = desc;
}

/**
* Sets the file location where this task was defined.
*
* @param location The new Location value
*/
public void setLocation( Location location )
{
this.location = location;
}

/**
* Sets the target object of this task.
*
@@ -69,16 +55,6 @@ public abstract class Task
return description;
}

/**
* Returns the file location where this task was defined.
*
* @return The Location value
*/
public Location getLocation()
{
return location;
}

/**
* Get the Target to which this task belongs
*
@@ -119,39 +95,22 @@ public abstract class Task
public final void perform()
throws TaskException
{
if( !invalid )
try
{
project.fireTaskStarted( this );
maybeConfigure();
execute();
project.fireTaskFinished( this, null );
}
catch( TaskException te )
{
try
{
project.fireTaskStarted( this );
maybeConfigure();
execute();
project.fireTaskFinished( this, null );
}
catch( TaskException te )
{
if( te instanceof BuildException )
{
BuildException be = (BuildException)te;
if( be.getLocation() == Location.UNKNOWN_LOCATION )
{
be.setLocation( getLocation() );
}
}
project.fireTaskFinished( this, te );
throw te;
}
catch( RuntimeException re )
{
project.fireTaskFinished( this, re );
throw re;
}
project.fireTaskFinished( this, te );
throw te;
}
else
catch( RuntimeException re )
{
UnknownElement ue = getReplacement();
Task task = ue.getTask();
task.perform();
project.fireTaskFinished( this, re );
throw re;
}
}

@@ -208,16 +167,9 @@ public abstract class Task
public void maybeConfigure()
throws TaskException
{
if( !invalid )
if( wrapper != null )
{
if( wrapper != null )
{
wrapper.maybeConfigure( project );
}
}
else
{
getReplacement();
wrapper.maybeConfigure( project );
}
}

@@ -245,37 +197,5 @@ public abstract class Task
{
this.taskType = type;
}

/**
* Mark this task as invalid.
*/
final void markInvalid()
{
invalid = true;
}

/**
* Create an UnknownElement that can be used to replace this task.
*
* @return The Replacement value
*/
private UnknownElement getReplacement()
throws TaskException
{
if( replacement == null )
{
replacement = new UnknownElement( taskType );
replacement.setProject( project );
replacement.setTaskType( taskType );
replacement.setTaskName( taskName );
replacement.setLocation( location );
replacement.setOwningTarget( target );
replacement.setRuntimeConfigurableWrapper( wrapper );
wrapper.setProxy( replacement );
target.replaceChild( this, replacement );
replacement.maybeConfigure();
}
return replacement;
}
}


Loading…
Cancel
Save