My approach to a similar problem (allowing incremental refactoring of a large legacy application) was to create a "legacy bridge". A simple class, containing static getters for guice managed singletons, with static injection. (in theory non-singletons could work by injecting a provider but I've never tested this). To bind this static class I've created a LegacyModule with all the possible guardians (@Deprecated, TODO tags, tons of docs etc). Eventually when you're finished refactoring this module and class can be removed. (to be fair this model is recommended in the guice documentation, not my original idea)
Depending on the persistence api you're using you can easily extend guice-persist to hook into some existing transaction manager / threadlocal session/entitymanager pool, allowing the database code to co-exist with existing stuff. This all depends very much on your own application, hard to give generic guidelines but the source of guice-persist is very well structured and easy to follow (although sometimes hard to extend given guice's tendency for defining everything as final...) -- L On Mon, Dec 9, 2013 at 5:07 PM, Benson Margulies <[email protected]>wrote: > I have an application which I do not wish to restructure this week. > However I'd like to begin to allow for injection to solve some modularity > problems. > > If I don't want to restructure the whole thing as a graph managed by > guice, but rather want some code at the top to set up the framework, and > some code at the bottom to be able to receive injections, can I do that? Is > there an example someplace I could look at? > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/google-guice. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-guice. For more options, visit https://groups.google.com/groups/opt_out.
