Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

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();

        GroovyClassLoader defaultClassLoader = new GroovyClassLoader(this.getClass().getClassLoader());

        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ctx);
	reader.setBeanClassLoader(defaultClassLoader);
	reader.loadBeanDefinitions(path);
	ctx.refresh();
	return ctx;
}
...
Code Block
xml
xml
titleSample beans.xml
<bean id="tm" class="ticketing.bo.impl.TicketManagerImpl"/>
Code Block
java
java
titleticketing/bo/impl/TicketAssemblerImpl.groovy
class TicketAssemblerImpl implements IBaseAssembler {
 ...
}

Hopefully that is helpful...