dropwizard-spring-annotations icon indicating copy to clipboard operation
dropwizard-spring-annotations copied to clipboard

Question: Use spring context instead of Reflections?

Open rowanhill opened this issue 11 years ago • 0 comments

Hi,

Thanks for this library - it's exactly what I was looking for! I just have a couple of questions / suggestions (which I'll split out into separate issues) - I haven't spent too long investigating them, so feel free to shoot them down immediately. :)

First up: what's the rationale behind using Reflections to scan for components we want to include, rather than interrogating the spring context? By using Reflections you can end up in a situation where AutoWiredService knows about (say) a resource, but can't get an instance of it (because the dev forgot to annotate it with @Resource, or similar).

I don't know if you've seen it, but there's a project called dropwizard-spring-di-security-onejar-example that has similar goals to this one (but this has the advantage of being easily reusable). The strategy taken there is to use ctx.getBeansOfType / ctx.getBeansWithAnnotation to locate DropWizard beans.

Personally, I think having a "single source of truth" (Spring in this case) makes it a bit clearer what's going on - but perhaps you disagree or otherwise have another perspective? I'd be interested to hear it, if so.

Thanks, Rowan

rowanhill avatar Jan 04 '14 13:01 rowanhill