-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Providers are not exposed correctly when layering Spring and Guice #48
Comments
So I understand a Spring config which uses Wouldn't it be simpler for those modules binding Let me know if I'm just missing something here. It sounds like this may be fixable, but I want to be sure I'm understanding what you're doing. |
We use Guice-Servlet, Guice-Persist, and Guice-Struts. So, we extend ServletModule and set up a PersistFilter, which will manage transactions on each request, then StrutsPrepareFilter and StrutsExecuteFilter. What we would actually like to do is replace Struts with Spring MVC. However, we would then need to inject a bunch of Guice-controlled objects into our Spring controllers. We could perhaps do that with So we've had to go the other way, replacing the data layer - and the service layer, because we need to manage transactions - with Spring, as a prelude to replacing the web layer. Unfortunately, that was complicated by the fact that the Spring module couldn't properly reuse other bits of our Guice config. For example, if we used EnableGuiceModules to pull in a module that bound a Provider for an email Transport, Spring wouldn't be able to autowire that; thus this issue. It also seemed to strip type parameterisation and have trouble autowiring objects that used it. I've actually succeeded in migrating the data and service layers of one of our applications, but in the end I had to dump EnableGuiceModules and just recreate the relevant beans directly in Spring config. And I still have yet to actually replace Struts, which was the original goal. And we have three more applications to migrate after this, each larger and more complex than this one. |
There are some merged but unreleased changes that may help with parameterized types being lost, but I'll need @dsyer's help in getting a release out. I'll see if I can reproduce this issue and make up a fix, but if you have the time and can submit a simplified test case that might speed things along. |
I would think so. We've been testing these last set of changes for a while now and it seems fairly stable. |
Done (1.1.3.RELEASE is out). We can keep this issue open in case @ThrawnCA can provide a sample. |
If a Spring configuration imports a Guice module with
@EnableGuiceModules
, and that module binds aProvider
, but the Spring configuration is in turn packaged in aSpringModule
, then the "outer" injector cannot see the boundProvider
.We're attempting to migrate an application from Guice to Spring in stages, and this is a minor hindrance. Modules that just bind classes can simply be imported for now and dealt with later, but any provider bindings have to be rewritten as Spring beans or moved to different modules.
The text was updated successfully, but these errors were encountered: