You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Simeon Fitch <me...@yahoo.com> on 2000/11/08 04:53:12 UTC

Proposed API Refactoring

The text document below outlines some proposed changes
to the Ant "data model" to make it more friendly as an
API. Although it is somewhat long, I'd really
appreciate any feedback you can provide.

__________________________________________________
Do You Yahoo!?
Thousands of Stores.  Millions of Products.  All in one Place.
http://shopping.yahoo.com/

Re: Proposed API Refactoring

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "NS" == Nico Seessle <Ni...@epost.de> writes:

 >> 5) Create a "DataTypeManager" that is responsible for loading and
 >> initializing the data types based on the property sets.

 NS> Maybe this should be the same way tasks are loaded?

Yes, we should give taskwriters the opportunity to define data types
of their own as well.

Stefan

Re: Proposed API Refactoring

Posted by Nico Seessle <Ni...@epost.de>.
----- Original Message -----
From: "Simeon Fitch" <me...@yahoo.com>
To: <an...@jakarta.apache.org>
Sent: Wednesday, November 08, 2000 4:53 AM
Subject: Proposed API Refactoring


>    4) Create a "AntProperties" class, which takes care of loading an
>       overriding properties based on the default.properties, command
>       line properties and .ant.properties data sets.

Note that the loading of "defaults.properties" loads tasks/types, not "real"
properties.

>    5) Create a "DataTypeManager" that is responsible for loading and
>       initializing the data types based on the property sets.
Maybe this should be the same way tasks are loaded? Load them thru a
<typedef/>-task, or define them in a xml-file inside the archive the tasks
reside in?

Nico



Re: Proposed API Refactoring

Posted by Stefan Bodewig <bo...@apache.org>.
I thought I'd better give a late feedback than none.

Simeon Fitch <me...@yahoo.com> wrote:

> B) The Project.java file also has a lot of fungal growth :-P. It's
>    "init()" method (which is is separate from the constructor, I
>    assume for BuildEvent reasons) executes the following tasks:

Actually I think we've made it that way to help <ant> and <antcall>.

>    2) Loads the default properties from default.properties.

These are not the default properties but the mapping of task names to
implementation classes, but you knew that 8-)

> C) Here is /a/ proposed refactoring:
>    1) Create a class called "Args" that is responsible for:

+1

>    2) Create a "Logger" class. It would be initialized with the
>    return values of Args.getStdOut(), Args.getStdErr(),
>    Args.getLogLevel(), and probably some other log listener
>    method.

Initialized by Main or whom? We should tie the Logger to Args as the
latter will only be used in command line mode while a Logger will be
needed anyway.

>    3) The logging level "static final int" variables (MSG_WARN,
>       MSG_INFO, etc.) belong either in BuildEvent, the Proposed
>       "Logger" class, or in a separate enumeration class.

I'm no big friend of enumeration classes, my preference would be
inside Logger.

>    4) Create a "AntProperties" class, which takes care of loading an
>       overriding properties based on the default.properties, command
>       line properties and .ant.properties data sets.

Not sure about that, maybe an approach of having a PropertyStore that
unifies <property> with references (making <property> just the String
version of a data type) might be the right place to add this
responsibilities.

>    5) Create a "DataTypeManager" that is responsible for loading and
>       initializing the data types based on the property sets.

Could by used for Task creations as well as data type creation, some
kind of Factory.

>    6) Better encapsulation of the event handling. [...] there should
>    be a *single* place for registering BuildListener instances and
>    firing events.
> 
>       I think the Project class is still a good place to have the
>       add/remove listener methods

Agreed.

>       but access to the event firing code needs to be opened up,

Why? Who should be firing what type of events?

>    7) Relocation of XML parser initialization to the
>       ProjectHelper.

Yes.

>    8) The need for separating the initialization code in the Project
>       class into an "init()" method instead of in the constructor
>       can be eliminated

If just reread Ant.java. 

<ant> needs a Project instance at parser time as it uses this one for
the nested <property> elements. Project objects are quite heavy ATM
(speaking of memory consumption) and basically duplicate Hashtables
from the parent project.

What <ant> does right now is to instantiate a minimalistic Project
instance that doesn't know much, it can only create Property tasks and
knows the Java version, that's all. As soon as the <ant> task gets
executed, the Project.init will be called - and the whole project
instance will be left to the garbage collector at the end of execute.

If you have many <ant> tasks in your build file, this saves tons of
memory as opposed to having many full blown Project instances from
parser time to Ant termination.

Following all your proposals Project might end up being quite small,
so this issue might go away.

>    9) [...] moving the
>       "fireBuild{Started|Finished}()" invocation from Main.java into
>       the "executeTarget()" method.

Not sure whether this is the right place but Project should be the one
calling this methods - no question.

>    10) Either colocate the file based utility methods (fileCopy(),
>        getParentFile()),

I'd like to see some stuff like copying of files and filter
replacements to separate classes anyway. Copying of files could be
extended in an operating system dependant manner (copying the resource
fork on Macs for example) a lot easier if it was placed into a class
of its own.

>    11) Create a "TargetCollection" class that manages a set of
>        targets, and knows how to sort them in "target" specific
>        ways.

Agreed.

>    12) There has been a discussion lately about a more general
>        token replacement facility. If this comes to fruition,
>        hopefully the code to do this will be moved out of the
>        Project class.

Yes, yes, yes.

>    14) The API needs to be tuned up for reentrancy and thread
>        safty.

Probably - given that we want to open Ant to a whole bunch of new
frontends (servlets, incremental mode Ants ...) we shouldn't rely on
running a single threaded application.

>    100) Javadoc, javadoc, javadoc.

8-)

Stefan

Re: Proposed API Refactoring

Posted by Peter Donald <do...@apache.org>.
At 02:02  10/11/00 +1030, you wrote:
>On Tue, 7 Nov 2000, Simeon Fitch wrote:
>
>> The text document below outlines some proposed changes
>
>Thanks for putting this together.  There needs to be a better way to
>communicate these ideas amongst the people on the dev list and
>especially the committers.
>
>It would be helpful to prioritize this list as well.
>
>Have people seen www.log4j.org which I have just started to use but
>looks like a much better logger than we currently have with Ant.  It's
>under the IBM Public License (I dont want to start another licensing
>thread *sigh*, but this is "open source certified" :P )

It was going to be hosted at apache a while back. The guy that maintains it
wanted to share the load ;) Either way it is fine to use. Thou there is
another logging framework in Avalon project (java.apache.org/framework)
that is another candidate. 

The main differences between log4j are
* Avalons logging more efficient for light logging (ie jvm local logging)
* Log4j has hierarchial logging (thou Avalon logging will have this soon)
* Avalons logging allows redirecting logs at runtime while log4j can not
* Avalons logging is more easier to use

Thou take that with a grain of salt as I was original author of Avalons
system ;)

>Does anyone have suggestions on how these types of changes get process
>managed in an open source group?

1. if we agree they are desirable then someone does it and commits it ;)
2. If they involve major changes then someone prototypes the changes and if
accepted by the group then a seperate branch/directory created and whoever
wants hacks away at it.
3. if changes can happen without a revolution then the codebase just evolves

I am trying 2 at the moment but I have largely been unsuccessful ;(.

>I would point at Stefan to say he is the one who owns this type of
>role now.

he is probably defacto leader along with duncan and Connor as they have
done the most work ;)

>But how do we go about collating this information and tracking the
>completion of tasks?  It would be nice to be able to work on some
>productive task that has benefit to the entire group rather than to
>just an individual.

Unfortunately apache does not have any productivity tools besides
mailinglist/cvs thou there is the bug tracker and faq but they don't seem
to be used heaps. ;)
Cheers,

Pete

*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power."          |
|       -Abraham Lincoln                               |
*------------------------------------------------------*

Re: Proposed API Refactoring

Posted by Stefan Bodewig <bo...@bost.de>.
Barrie Treloar <Ba...@camtech.com.au> wrote:

> It would be helpful to prioritize this list as well.

probably yes. Unfortunately I'm quite busy at the moment and don't
think I'll find to actually read Simeon's mail completely before next
week.

> But how do we go about collating this information and tracking the
> completion of tasks?

Even though Apache doesn't really have much more than CVS and mailing
lists, these tools can be used very efficiently. See struts for
example, they have a TODO list in CVS and on the website with tasks
assigned to individuals (OK, this is pure theory as Craig is the only
one volunteering for anything).

Let's see. If we can bundle the changes into more or less independent
chunks, lets specify them formally and search for volunteers to work
on them - I think there should always be at least one committer
vaguely responsible.

When the implementation for one of the changes is ready, we are going
to review and then commit it. If the changes are big, it might be
useful to create a branch so that people can easily compare old and
new versions of it.

What Pete was referring to is a thread with the subject "Proposal for
Revolutionaries and Evolutionaries" by Duncan, see
<ma...@jakarta.apache.org> if you're interested
in the details.

The context of that thread is, that Craig proposed a different
architecture for Tomcat, causing heated discussions. His proposal
became Catalina which will be the servlet container in Tomcat 4 - an
example for a successful revolution.

Stefan

Re: Proposed API Refactoring

Posted by Barrie Treloar <Ba...@camtech.com.au>.
On Tue, 7 Nov 2000, Simeon Fitch wrote:

> The text document below outlines some proposed changes

Thanks for putting this together.  There needs to be a better way to
communicate these ideas amongst the people on the dev list and
especially the committers.

It would be helpful to prioritize this list as well.

Have people seen www.log4j.org which I have just started to use but
looks like a much better logger than we currently have with Ant.  It's
under the IBM Public License (I dont want to start another licensing
thread *sigh*, but this is "open source certified" :P )

I dont have any problems with the things you have listed and most make
sense to implement.

Does anyone have suggestions on how these types of changes get process
managed in an open source group?

I would point at Stefan to say he is the one who owns this type of
role now.

But how do we go about collating this information and tracking the
completion of tasks?  It would be nice to be able to work on some
productive task that has benefit to the entire group rather than to
just an individual.

Barrie
--
Barrie Treloar
____________________________________________________________________

  Barrie Treloar                      Phone: +61 8 8303 3300
  Senior Analyst/Programmer           Fax:   +61 8 8303 4403 
  Electronic Commerce Division        Email: barrie@camtech.com.au
  Camtech (SA) Pty Ltd                http://www.camtech.com.au
 --- Level 8, 10 Pulteney Street, Adelaide SA 5000, Australia. ---
____________________________________________________________________