Message-ID: <1244050205.6189.1416667639777.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_6188_1298888280.1416667639777" ------=_Part_6188_1298888280.1416667639777 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Gynamo is a lightweight mechanism for extending classes with discrete pa= ckages of functionality similar to mixins in languages like Ruby.=20
To make things easier (hopefully) to understand, the following is a defi= nition of terms used:=20
Hopefully that illustrates the point.=20
You can also grab the buildable source from the SVN repository= a>.=20
Gynamo is released under the same license terms as Groovy.=20
All classes in the Gynamo library are in the package "gynamo".==20
Gynamos can contain fields (which will be public when injected) and meth= ods (which Gynamos define as closures). All methods and properties are atta= ched via ExpandoMetaClass = so all the usual rules apply there.=20
Methods and properties are attached via the '=3D' operator so any existi= ng methods or properties with a matching name will be overridden. This is s= omething to watch out for.=20
A Gynamo is any class that extends the gynamo.Gynamo class. Gynamo inher= itance is not supported, all Gynamos must directly extend the Gynamo class.==20
Methods (as closures) or fields to be injected must be accessible via ge= tters. Groovy makes this too easy by generating getters for any fields that= you don't specify the visiblity of.=20 =20
You can even add fields and methods statically to a class ...=20 =20
Gynamo class defines the static method
code> which takes a Gynamee class and a Gynamo class and performs the injec=
Or alternatively using categories ...=20 =20
If your Gynamo needs to do anything before or after Gynamization of a cl= ass there are optional hooks for it=20 =20
Sometimes you want to add bean like properties to a Gynamee. This is a l=
ittle awkward but you can make it work using the provided
rtyStorage class. Another caveat is that you have to define the gett=
er and/or setter for each such property. Here is an example ...
You would use the above like so ...=20 =20
If you have a gynamo that depends on another Gynamee being injected then= you can specify that with annotations ...=20 =20
@GynamoDependency annotation takes a single parameter o=
Class which must be another Gynamo. The specified Gynam=
o will be injected automatically *before* this Gynamo gets=
injected. Therefore, the methods and fields of the dependency are availabl=
e on the Gynamee at time of Gynamization.
If your Gynamo depends on multiple Gynamos, you can use the
oDependencies annotation to specify a list of Gynamos that need to b=
e injected before.
*Note:* Be careful of circular dependencies. The depend= ency handling is pretty simple so if you do have a a circular dependency, y= our code will blow up with a StackOverflowError. If anyone has any suggesti= ons on how this can be improved please let me know.