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 | ||||
|---|---|---|---|---|
| ||||
... 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 | ||||
|---|---|---|---|---|
| ||||
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 | ||||
|---|---|---|---|---|
| ||||
importclass gynamo.*TicketAssemblerImpl Gynamo.gynamize(Square, AreaGynamo) def s = new Square(size: 10) assert s.area == 100 |
Hopefully that illustrates the point.
Download
- Gynamo 1.0 (contains source)
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.