sábado, julio 11, 2009

Groovy Metaclass

One of my favourites Groovy´s features is its MOP architecture. It allow us introducing new methods at runtime thanks to the metaClass.

We can define a new class

class SampleClass {
// class field
def propertyOne
// one sample Closure
def closureOne = {
println "I´m the closure one"

Now we add a new method at runtime

SampleClass.metaClass.runtimeAddedMethod = {
println "I´m runtimeAddedMethod"

Declare a new instance an test all the methods

def instance = new SampleClass()

Call to the closure declared in class definition


Call to the method added at runtime


We add a method to the "instance" too

instance.metaClass.instanceRuntimeAddedMethod = {
println "I´m the method added at runtime to a single instance"



viernes, julio 03, 2009

Amsterdam Photos

Some photos of our last trip to Amsterdam:

Chihi: Art essence (trying to become famous jajajaja)

i amsterdam

all the travelers (I was tooking the photo)


Dam Place

Dam Place

Ita again