donaldp 01/12/15 19:10:16
Modified: proposal/myrmidon/src/main/org/apache/tools/ant Task.java
Log:
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).
Revision Changes Path
1.4 +15 -95
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/Task.java
Index: Task.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/Task.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Task.java 2001/12/16 01:01:19 1.3
+++ Task.java 2001/12/16 03:10:16 1.4
@@ -15,14 +15,10 @@
{
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.
@@ -35,16 +31,6 @@
}
/**
- * 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.
*
* @param target Target in whose scope this task belongs.
@@ -70,16 +56,6 @@
}
/**
- * 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
*
* @return the task's target.
@@ -119,39 +95,22 @@
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,17 +167,10 @@
public void maybeConfigure()
throws TaskException
{
- if( !invalid )
+ if( wrapper != null )
{
- if( wrapper != null )
- {
- wrapper.maybeConfigure( project );
- }
+ wrapper.maybeConfigure( project );
}
- else
- {
- getReplacement();
- }
}
protected void setRuntimeConfigurableWrapper( RuntimeConfigurable
wrapper )
@@ -244,38 +196,6 @@
void setTaskType( String type )
{
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;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>