Hi,
I have a several Grails services that are invoked from Flex code using Spring BlazeDS integration. I wanted to add some general debug logging using the groovy metaClass. I have the following in a bootstrap class:
class MyBootStrap {
def grailsApplication
def init = { servletContext ->
initServiceCallLogging()
}
def destroy = {
}
private def initServiceCallLogging() {
grailsApplication.serviceClasses.each { serviceClass ->
serviceClass.metaClass.invokeMethod = { name, args ->
log.debug "Method $name invoked"
def metaMethod = delegate.metaClass.getMetaMethod(name, args)
def result = metaMethod.invoke(delegate, args)
return result
}
}
}
}
This works fine as long as the Service method is called from e.g. a Grails Controller or Service but when directly called from Flex (via BlazeDS), the method calls are not intercepted.
Anyone an idea how this can be solved or is this not possible via metaprogramming and should Spring AOP be used?
Thx