Top Description Fields Constructors Methods
org.apache.tools.ant

public Class TaskAdapter

extends Task
implements TypeAdapter
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.TypeAdapter
Imports
java.lang.reflect.Method, org.apache.tools.ant.dispatch.DispatchUtils, .Dispatchable

Uses introspection to "adapt" an arbitrary Bean which doesn't itself extend Task, but still contains an execute method and optionally a setProject method.

Field Summary

Modifier and TypeField and Description
private Object
proxy

Object to act as a proxy for.

Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public
TaskAdapter()

No-arg constructor for reflection.

public
TaskAdapter(Object
The object which Ant should use as task.
proxy
)

Constructor for given proxy.

Method Summary

Modifier and TypeMethod and Description
public void
checkProxyClass(Class<?>
the class to check.
proxyClass
)

Implements org.apache.tools.ant.TypeAdapter.checkProxyClass.

Check if the proxy class is a valid class to use with this adapter.
public static void
checkTaskClass(final Class<?>
Class to test for suitability. Must not be null.
taskClass
,
final Project
Project to log warnings/errors to. Must not be null.
project
)

Checks whether or not a class is suitable to be adapted by TaskAdapter.

public void
execute()

Overrides org.apache.tools.ant.Task.execute.

Executes the proxied task.
public Object

Returns:

the target proxy object.
getProxy
()

Implements org.apache.tools.ant.TypeAdapter.getProxy.

Returns the target object being proxied.
public void
setProxy(Object
The target object. Must not be null.
o
)

Implements org.apache.tools.ant.TypeAdapter.setProxy.

Sets the target object to proxy for.
Inherited from org.apache.tools.ant.Task:
bindToOwnergetOwningTargetgetRuntimeConfigurableWrappergetTaskNamegetTaskTypegetWrapperhandleErrorFlushhandleErrorOutputhandleFlushhandleInputhandleOutputinitisInvalidloglogloglogmarkInvalidmaybeConfigureperformreconfiguresetOwningTargetsetRuntimeConfigurableWrappersetTaskNamesetTaskType

Field Detail

proxyback to summary
private Object proxy

Object to act as a proxy for.

Constructor Detail

TaskAdapterback to summary
public TaskAdapter()

No-arg constructor for reflection.

TaskAdapterback to summary
public TaskAdapter(Object proxy)

Constructor for given proxy. So you could write easier code

myTaskContainer.addTask(new TaskAdapter(myProxy));
Parameters
proxy:Object

The object which Ant should use as task.

Method Detail

checkProxyClassback to summary
public void checkProxyClass(Class<?> proxyClass)

Implements org.apache.tools.ant.TypeAdapter.checkProxyClass.

Check if the proxy class is a valid class to use with this adapter. The class must have a public no-arg "execute()" method.

Parameters
proxyClass:Class<?>

the class to check.

checkTaskClassback to summary
public static void checkTaskClass(final Class<?> taskClass, final Project project)

Checks whether or not a class is suitable to be adapted by TaskAdapter. If the class is of type Dispatchable, the check is not performed because the method that will be executed will be determined only at runtime of the actual task and not during parse time. This only checks conditions which are additionally required for tasks adapted by TaskAdapter. Thus, this method should be called by Project.checkTaskClass. Throws a BuildException and logs as Project.MSG_ERR for conditions that will cause the task execution to fail. Logs other suspicious conditions with Project.MSG_WARN.

Parameters
taskClass:Class<?>

Class to test for suitability. Must not be null.

project:Project

Project to log warnings/errors to. Must not be null.

See Also
Project#checkTaskClass(Class)
executeback to summary
public void execute() throws BuildException

Overrides org.apache.tools.ant.Task.execute.

Executes the proxied task.

Exceptions
BuildException:
if the project could not be set or the method could not be executed.
getProxyback to summary
public Object getProxy()

Implements org.apache.tools.ant.TypeAdapter.getProxy.

Returns the target object being proxied.

Returns:Object

the target proxy object.

setProxyback to summary
public void setProxy(Object o)

Implements org.apache.tools.ant.TypeAdapter.setProxy.

Sets the target object to proxy for.

Parameters
o:Object

The target object. Must not be null.