Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: first try

Abstract

Alternate way to integrate Groovy in a Java-Application using Spring, without the usage of <lang:groovy/>-Tags.

Advantages

...

  • Works with Spring-AOP

...

  • You can use other Groovy-Classes e.g. internal datatypes, in your Beans without the need to inject them.

Example

Code Block
java
java
titleJava Code that's create the App-Context
        ...
private GenericApplicationContext createAppContext(String path) {
		GenericApplicationContext ctx = new GenericApplicationContext();
		
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ctx);
		    GroovyClassLoader defaultClassLoader = new GroovyClassLoader(this.getClass().getClassLoader());
		
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ctx);
	reader.setBeanClassLoader(defaultClassLoader);
		reader.loadBeanDefinitions(path);
		ctx.refresh();
		return ctx;
	}
...
Code Block
javaxmljava
xml
titleAn example GynamoSample beans.xml
import gynamo.*
class AreaGynamo extends Gynamo
{
	def getArea = {->
		return delegate.size * delegate.size
	}
}
<bean id="tm" class="de.sdm.ticketing.bo.impl.TicketManagerImpl"/>
Code Block
java
java
titleGynamizationde/sdm/ticketing/bo/impl/TicketAssemblerImpl.groovy
importclass gynamo.*TicketAssemblerImpl 
Gynamo.gynamize(Square, AreaGynamo)

def s = new Square(size: 10)
assert s.area == 100

Hopefully that illustrates the point.

Download

You can also grab the buildable source from the SVN repository.

Gynamo is released under the same license terms as Groovy.

Documentation

implements IBaseAssembler {
 ...
}

Hopefully that is of use.