Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.1-beta-2
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
Sam introduced the "use" keyword but I'd like to have a somewhat more permanent ways because "use" is quite noisy in scripts and can get overused quite easily.
I quickly developed a simple way to add methods just like the DefaultGroovyMethods does. Its not perfect cause it requires a system property but it works quite nicely.
See patch&testcase here:
http://lists.codehaus.org/pipermail/groovy-dev/2004q2/002055.html
A couple of ways to avoid using a special system property:
1. The Groovy runtime designate a special package (e.g., groovy.lang.extension) as a namespace where any class in the package is considered Groovy runtime extensions. Anytime a user would add his own new methods for java classes, he/she creats a new class in that namespace.
2. The Groovy runtime designate a special directory in the fielsystem and any class files or jars files are searched for
extensions. This is similar to java lib/ext mechanism.
Of course, all these are subjected to groovy runtime security policy.