Hi,

I'm heavily using <presetdef> to override/customize tasks. It annoys me 
and users
of my framework to see messages like

        Trying to override old definition of task junit

and so I had the idea to write my "own" ComponentHelper and to hook it in 
via
reference "ant.ComponentHelper".

The idea is - theoretically - simple, just inherit from ComponentHelper 
and override
method 

        updateDataTypeDefinition()

and  get  rid of this project.log() statement (which should be a verbose 
message
after all).

In practice however I run into serious problems and I have no real clue 
how to do
it:
 - updateDataType() is private, so I need to change addTaskDefinition() as 
well (
   I really wonder why updateDataTypeDefinition() is private and not 
protected).

-  updateDataType() uses lot's of private variables and methods like 
     rebuildTaskClassDefinitions
     antTypeTable
     sameDefinition
     project
     invalidateCreatedTasks
   and it appears that most of this private staff does not even have a 
"read"
   method.

Therfore customization by inheritance appears not to work.

In a second approach I copied ComponentHelper.java  in my own package 
structure,
added a couple of import statements, and finally got stuck because of 

        Task t = (Task) ref.get();
            //being a weak ref, it may be null by this point
            if (t != null) {
                t.markInvalid();            // <= package access only 
            }

Ok, so do I need to put ComponentHelper.java  in org.apache.tools.ant to 
make javac
happy? This was then my third approach. I  saved  a copy of 
ComponentHelper.java  as
MyComponentHelper.java  in "your" namespace and now I'm stuck because of 

 for (Iterator i = helper.checkedNamespaces.iterator(); i.hasNext();) 
 {
    // ..
 }

Here checkedNamespaces is private (again) and there's no way to access it.

Now for my final question (thanks for reading so far):

How do I ever have a chance to replace ComponentHelper with my own version 
if
basically everything is "private" ? 

And here's my proposal for Ant 1.6.6:

        1. $ perl -pi -e 's,\sprivate\s, protected ,g' `find -name 
\*.java`
        2. provide at least a "getter" for each "non-public" attribute

Cheers,
Wolfgang.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to