How to use existing java class from grails

grails, groovy, java

Solution

Put your source in src/java. Then in conf/spring/resources.groovy, you can do, for example:

// Place your Spring DSL code here
beans = {
    myJavaFunction(com.my.javafunction)

}

Then you can inject it into your controllers or services with:

def myJavaFunction

Problem

how can I call a method residing in an existing Java class from Grails app ? Is it necessary/recommended to wrap that up in a service?

Original source