|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.tools.ant.ComponentHelper
it.haefelinger.flaka.CompH
public class CompH
This whole class just exists to get rid of some anoying warnings * issued by
Ant. Here's an example situation: * *
Executing this command would
issue a warning like * *
Overriding previous definition of type javac
Unfortunatly there is no easy way to
remove such warnings. Looking * how this is implemented, it appears that
method * *
ComponentHelper.updateDataTypeDefinition()
is the guilty part. It is rather easy to exchange this
faulty * ComponentHelper instance by a customized on. All that needs to be *
done is to save a reference to a customized instance via property * name
"ant.ComponentHelper". Unfortunatly our faulty method is made * private. So
how can we change the behaviour? This is how it's done: * * 1. Make a new
class using ComponentHelper as base class. * 2. The new class contains a
pointer to the original instance (dlgt) * 3. Delegate all public methods to
dlgt except those public methods * (indirectly) call our faulty method. * 4.
Implement our faulty method again without issuing a warning. * 5. Implement
non-delegation public methods in such a way that they * are using my improved
method. * * Steps 4. and 5. are problematic of course and are using Java's *
reflection API to access private methods and fields. While this * works with
Ant 1.6.3 - 1.6.5 it may not work with newer versions * of Ant. * * There are
other approaches to solve the problem: * a.) override the setProject() method
and wrap the project's instance * with a wrapper overriding Project.log().
Since there's no * factory methods for Projects a delegation technique
similar to * the one used in this class needs to be applied. * b.) what was
the other approach again?? * * *
| Field Summary | |
|---|---|
protected static boolean |
applicable
|
protected ComponentHelper |
dlgt
|
protected static Method |
invalidateCreatedTasks
|
protected static Field |
project
|
protected static Field |
rebuildTaskClassDefinitions
|
protected static Field |
rebuildTypeClassDefinitions
|
protected static Method |
sameDefinition
|
| Fields inherited from class org.apache.tools.ant.ComponentHelper |
|---|
COMPONENT_HELPER_REFERENCE |
| Constructor Summary | |
|---|---|
CompH()
|
|
| Method Summary | |
|---|---|
void |
addDataTypeDefinition(AntTypeDefinition def)
Describe addDataTypeDefinition method here. |
void |
addDataTypeDefinition(String typeName,
Class typeClass)
Adds a new datatype definition. |
void |
addTaskDefinition(String taskName,
Class taskClass)
Adds a new task definition to the project. |
void |
checkTaskClass(Class taskClass)
Checks whether or not a class is suitable for serving as Ant task. |
Object |
createComponent(String componentName)
Create an object for a component. |
Object |
createComponent(UnknownElement ue,
String ns,
String componentType)
Factory method to create the components. |
Object |
createDataType(String typeName)
Creates a new instance of a data type. |
Task |
createTask(String taskType)
Creates a new instance of a task, adding it to a list of created tasks for later invalidation. |
void |
enterAntLib(String uri)
Called at the start of processing an antlib. |
void |
exitAntLib()
Called at the end of processing an antlib. |
Hashtable |
getAntTypeTable()
Returns the current datatype definition hashtable. |
protected Object |
getattr(Field field)
|
Class |
getComponentClass(String componentName)
Return the class of the component name. |
String |
getCurrentAntlibUri()
|
Hashtable |
getDataTypeDefinitions()
Returns the current type definition hashtable. |
AntTypeDefinition |
getDefinition(String componentName)
Return the antTypeDefinition for a componentName. |
String |
getElementName(Object element)
Returns a description of the type of the given element. |
ComponentHelper |
getNext()
Get the next chained component helper. |
Hashtable |
getTaskDefinitions()
Returns the current task definition hashtable. |
void |
initDefaultDefinitions()
This method is initialization code implementing the original ant component loading from /org/apache/tools/ant/taskdefs/default.properties and /org/apache/tools/ant/types/default.properties. |
void |
initSubProject(ComponentHelper helper)
Used with creating child projects. |
static boolean |
install(Project P)
Installs this ComponentHandler in project given. |
protected Object |
invoke(Method method,
Object[] args)
|
static boolean |
isapplicable()
Checks whether it is possible to use this Class as replacement * for class ComponentHelper. |
protected boolean |
sameDefinition(AntTypeDefinition def,
AntTypeDefinition old)
|
protected void |
setattr(Field field,
Object val)
|
void |
setNext(ComponentHelper next)
Set the next chained component helper. |
void |
setProject(Project project)
Sets the project for this component helper. |
static boolean |
uninstall(Project P)
Checks whether current component handler is instance of this * particular class (or a subclass). |
| Methods inherited from class org.apache.tools.ant.ComponentHelper |
|---|
diagnoseCreationFailure, getComponentHelper, getElementName, getElementName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static Field project
protected static Field rebuildTaskClassDefinitions
protected static Field rebuildTypeClassDefinitions
protected static Method invalidateCreatedTasks
protected static Method sameDefinition
protected static boolean applicable
protected ComponentHelper dlgt
| Constructor Detail |
|---|
public CompH()
| Method Detail |
|---|
public void setNext(ComponentHelper next)
setNext in class ComponentHelpernext - the next chained component helper.public ComponentHelper getNext()
getNext in class ComponentHelperpublic void setProject(Project project)
setProject in class ComponentHelperproject - the project for this helper.public void initSubProject(ComponentHelper helper)
initSubProject in class ComponentHelperhelper - the component helper of the parent project.
public Object createComponent(UnknownElement ue,
String ns,
String componentType)
throws BuildException
createComponent in class ComponentHelperue - The Unknown Element creating this component.ns - Namespace URI. Also available as ue.getNamespace().componentType - The component type, Also available as ue.getComponentName().
BuildException - if an error occurs.public Object createComponent(String componentName)
createComponent in class ComponentHelpercomponentName - the name of the component, if the component is in a namespace, the
name is prefixed with the namespace uri and ":".
public Class getComponentClass(String componentName)
getComponentClass in class ComponentHelpercomponentName - the name of the component, if the component is in a namespace, the
name is prefixed with the namespace uri and ":".
public AntTypeDefinition getDefinition(String componentName)
getDefinition in class ComponentHelpercomponentName - the name of the component.
public void initDefaultDefinitions()
initDefaultDefinitions in class ComponentHelper
public void checkTaskClass(Class taskClass)
throws BuildException
checkTaskClass in class ComponentHelpertaskClass - The class to be checked. Must not be null.
BuildException - if the class is unsuitable for being an Ant task. An error
level message is logged before this exception is thrown.public Hashtable getTaskDefinitions()
getTaskDefinitions in class ComponentHelperpublic Hashtable getDataTypeDefinitions()
getDataTypeDefinitions in class ComponentHelperpublic Hashtable getAntTypeTable()
getAntTypeTable in class ComponentHelper
public Task createTask(String taskType)
throws BuildException
createTask in class ComponentHelpertaskType - The name of the task to create an instance of. Must not be
null.
null if the task
name is not recognised.
BuildException - if the task name is recognised but task creation fails.
public Object createDataType(String typeName)
throws BuildException
createDataType in class ComponentHelpertypeName - The name of the data type to create an instance of. Must not be
null.
null if the
data type name is not recognised.
BuildException - if the data type name is recognised but instance creation
fails.public String getElementName(Object element)
This is useful for logging purposes.
getElementName in class ComponentHelperelement - The element to describe. Must not be null.
public void enterAntLib(String uri)
enterAntLib in class ComponentHelperuri - the uri that is associated with this antlib.public String getCurrentAntlibUri()
getCurrentAntlibUri in class ComponentHelperpublic void exitAntLib()
exitAntLib in class ComponentHelper
public void addDataTypeDefinition(String typeName,
Class typeClass)
addDataTypeDefinition in class ComponentHelpertypeName - The name of the datatype. Must not be null.typeClass - The full name of the class implementing the datatype. Must not be
null.public void addDataTypeDefinition(AntTypeDefinition def)
addDataTypeDefinition method here.
addDataTypeDefinition in class ComponentHelperdef - an AntTypeDefinition value.
public void addTaskDefinition(String taskName,
Class taskClass)
addTaskDefinition in class ComponentHelpertaskName - The name of the task to add. Must not be null.taskClass - The full name of the class implementing the task. Must not be
null.
BuildException - if the class is unsuitable for being an Ant task. An error
level message is logged before this exception is thrown.checkTaskClass(Class)
protected boolean sameDefinition(AntTypeDefinition def,
AntTypeDefinition old)
protected Object invoke(Method method,
Object[] args)
protected Object getattr(Field field)
protected void setattr(Field field,
Object val)
public static boolean isapplicable()
public static boolean install(Project P)
P - not null * *
public static boolean uninstall(Project P)
P - not null * *
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||