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 |
|---|
| title | Java Code that's create the App-Context |
|---|
|
...
private GenericApplicationContext createAppContext(String path) {
GenericApplicationContext ctx = new GenericApplicationContext();
GroovyClassLoader defaultClassLoader = new GroovyClassLoader(this.getClass().getClassLoader());
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ctx);
reader.setBeanClassLoader(defaultClassLoader);
reader.loadBeanDefinitions(path);
ctx.refresh();
return ctx;
}
...
|
| Code Block |
|---|
|
<bean id="tm" class="ticketing.bo.impl.TicketManagerImpl"/>
|
| Code Block |
|---|
| java |
|---|
| title | ticketing/bo/impl/TicketAssemblerImpl.groovy |
|---|
|
class TicketAssemblerImpl implements IBaseAssembler {
...
}
|
Hopefully that is helpful...