padcom / grails-routing

Apache License 2.0
30 stars 31 forks source link

make services available in Route #4

Closed geemang2000 closed 12 years ago

geemang2000 commented 12 years ago

I'd like to reference a service in a process method. There are times where the bean syntax doesn't cut it and you need to reference a service directly.

e.g.

.process(new Processor() {
   public void process(Exchange exchange) throws Exception {
     myService.doSomethingWithaLotOfArgs('sdf', 'sdf', [])
})

Can the Route closure be enhanced to allow definition of a service ??

class MyRoute = {
def myService

}
geemang2000 commented 12 years ago

Editing snafu... Issue should be open...

padcom commented 12 years ago

You can always create a bean that implements the Processor interface (really simple) and use it instead. That way you can have dependency injection for your processor and inject service reference.

Hope it helps.

Best regards, Matthias

2011/12/1 geemang2000 < reply@reply.github.com

I'd like to reference a service in a process method. There are times where the bean syntax doesn't cut it and you need to reference a service directly.

e.g.

.process(new Processor() {
  public void process(Exchange exchange) throws Exception {
    myService.doSomethingWithaLotOfArgs('sdf', 'sdf', [])
})

Can we

class MyRoute = {

}

Reply to this email directly or view it on GitHub: https://github.com/padcom/grails-routing/issues/4

padcom commented 12 years ago

FYI: I've extended the routing-jms example so that it contains such a processor referenced from Spring context.

Here's the commit: https://github.com/padcom/grails-routing-jms-example/commit/13125a00a293e8266e0dd021f3e70c0b68f8ebab