Closed GoogleCodeExporter closed 8 years ago
May I ask why do you want to DI resource class instances somewhere? Or do I get
that wrong? Resources should only be accessed by the JAX-RS runtime.
Original comment by krass...@googlemail.com
on 5 Aug 2011 at 5:22
Or do you mean something like
http://code.google.com/p/grails-jaxrs/wiki/AdvancedFeatures#Service_injection
for generated resources?
Original comment by krass...@googlemail.com
on 5 Aug 2011 at 5:40
exactly what i meant yes, the service won't get injected if
ResourceCollection instanciate Resource
Original comment by stest...@gmail.com
on 5 Aug 2011 at 5:54
Ah ok. Will take a look.
Original comment by krass...@googlemail.com
on 5 Aug 2011 at 6:14
In generated resources, I plan to delegate all CRUD actions to a (generated)
service class. The generated service is then used by the Resource and
ResourceCollection classes. This means that the actual CRUD work is done inside
service methods which allows better control over transaction boundaries and you
can also inject any additional dependencies into that service.
Would this fit your needs?
Alternatively, you can still autowire dependencies into CollectionResource
classes and pass them as arguments to the Resource constructor if you want
(which requires a little modification to the generated code though).
Original comment by krass...@googlemail.com
on 28 Aug 2011 at 7:08
An example how to do programmatic dependency injection with Grails is described
at
http://stackoverflow.com/questions/1675399/grails-dependency-injection-in-regula
r-groovy-class, for example
Original comment by krass...@googlemail.com
on 28 Aug 2011 at 7:20
That would be perfect, right now i just use one resource class and
everything work well
Original comment by stest...@gmail.com
on 29 Aug 2011 at 12:57
This is now implemented with the that commit on master:
https://github.com/krasserm/grails-jaxrs/commit/955c77be0ba17fd2ba5e75028e9a0be6
f63a265b.
Original comment by krass...@googlemail.com
on 30 Aug 2011 at 9:15
Original issue reported on code.google.com by
stest...@gmail.com
on 5 Aug 2011 at 1:11