donaldp 01/12/29 19:30:07
Modified: proposal/myrmidon/src/main/org/apache/tools/ant
TaskAdapter.java
Log:
Cleaned up class and removed some uneeded (and never working ?) cruft
Revision Changes Path
1.9 +21 -52
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/TaskAdapter.java
Index: TaskAdapter.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/TaskAdapter.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- TaskAdapter.java 23 Dec 2001 14:23:47 -0000 1.8
+++ TaskAdapter.java 30 Dec 2001 03:30:07 -0000 1.9
@@ -8,6 +8,7 @@
package org.apache.tools.ant;
import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
import org.apache.myrmidon.api.TaskException;
/**
@@ -16,74 +17,42 @@
*
* @author [EMAIL PROTECTED]
*/
-public class TaskAdapter extends Task
+public class TaskAdapter
+ extends Task
{
- Object proxy;
+ private Object m_proxy;
- /**
- * Set the target object class
- *
- * @param o The new Proxy value
- */
- public void setProxy( Object o )
+ public void setProxy( final Object proxy )
{
- this.proxy = o;
+ this.m_proxy = proxy;
}
- public Object getProxy()
- {
- return this.proxy;
- }
-
- /**
- * Do the execution.
- *
- * @exception TaskException Description of Exception
- */
public void execute()
throws TaskException
{
- Method setProjectM = null;
try
{
- Class c = proxy.getClass();
- setProjectM =
- c.getMethod( "setProject", new Class[]{Project.class} );
- if( setProjectM != null )
- {
- setProjectM.invoke( proxy, new Object[]{getProject()} );
- }
+ final Class clazz = m_proxy.getClass();
+ final Method method = clazz.getMethod( "execute", new Class[ 0 ]
);
+ method.invoke( m_proxy, null );
}
- catch( NoSuchMethodException e )
+ catch( final NoSuchMethodException nsme )
{
- // ignore this if the class being used as a task does not have
- // a set project method.
+ final String message = "No public execute() in " +
m_proxy.getClass();
+ getLogger().error( message );
+ throw new TaskException( message );
}
- catch( Exception ex )
+ catch( final Exception e )
{
- final String message = "Error setting project in " +
proxy.getClass();
- getLogger().error( message, ex );
- throw new TaskException( "Error", ex );
- }
-
- Method executeM = null;
- try
- {
- Class c = proxy.getClass();
- executeM = c.getMethod( "execute", new Class[ 0 ] );
- if( executeM == null )
+ Throwable target = e;
+ if( e instanceof InvocationTargetException )
{
- getLogger().error( "No public execute() in " +
proxy.getClass() );
- throw new TaskException( "No public execute() in " +
proxy.getClass() );
+ target = ((InvocationTargetException)e).getTargetException();
}
- executeM.invoke( proxy, null );
- return;
- }
- catch( Exception ex )
- {
- getLogger().error( "Error in " + proxy.getClass() );
- throw new TaskException( "Error", ex );
- }
+ final String message = "Error invoking " + m_proxy.getClass();
+ getLogger().error( message, target );
+ throw new TaskException( message, target );
+ }
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>