atinject is only a subset of the dependency injection functionality that is in common between both Guice and Spring, so it's not a 100% solution, but probably a good place to start. As far as @transaction goes, there is no equivalent in Guice. Guice only does dependency injection and doesn't do anything datastore related. I would love to see Struts 2 use Guice though. That might make the problem I'm facing right now a bit easier since the configuration could be done in code instead of xml :o)
On Thu, Dec 2, 2010 at 5:30 PM, Frans Thamura <fr...@meruvian.org> wrote: > we need @transaction example > > but cannot find in atinject > > can help? > > we want to replace spring also in s2 :) > > so the market will be more colourfull > > spring is to strong now, and spring dont have market team here, so that is > better promote guice ;) > > F > > On Fri, Dec 3, 2010 at 8:13 AM, Ben McCann <bmcc...@google.com> wrote: > > > Hi Frans, > > Perhaps the easiest way to migrate from Spring to Guice would be to make > > use > > of the javax.inject annotations <http://code.google.com/p/atinject/> > which > > are compatible with both Spring and Guice. > > > > -Ben > > > > > > On Thu, Dec 2, 2010 at 4:35 PM, Frans Thamura <fr...@meruvian.org> > wrote: > > > > > hi ben > > > > > > any idea to migrate the S2-spring to S2-guice, do there any extra work? > > > > > > we use spring stereotype intensively, any idea for Services object > > > > > > > > > -- > > > Frans Thamura > > > Director > > > Meruvian. > > > The Most Complete Java Services Provider in Indonesia > > > > > > > > > Mobile: +6287885901958 > > > Blog & Profile: http://frans.thamura.info > > > > > > We grow because we share the same belief. > > > > > > > > > On Fri, Dec 3, 2010 at 7:33 AM, Ben McCann <bmcc...@google.com> wrote: > > > > > > > Hi, > > > > > > > > We just updated the Struts 2 Guice plugin so that it will be > compatible > > > > with > > > > Guice 3. However, the main class of the plugin, > > > > Struts2Factory< > > > > > > > > > > http://code.google.com/p/google-guice/source/browse/trunk/extensions/struts2/src/com/google/inject/struts2/Struts2Factory.java > > > > >, > > > > is being created via xwork's injection mechanism and then statically > > > > injected by Guice so that we can get a reference to the Guice > injector. > > > > We'd like to avoid static injection whenever possible, so I'm > > wondering > > > if > > > > anyone more familiar with Struts/XWork has a better idea. > > > > > > > > In struts-plugin.xml< > > > > > > > > > > http://code.google.com/p/google-guice/source/browse/trunk/extensions/struts2/src/struts-plugin.xml > > > > >we > > > > overrode the default ObjectFactory: > > > > <bean type="com.opensymphony.xwork2.ObjectFactory" > > > > name="guice" > > > > class="com.google.inject.struts2.Struts2Factory"/> > > > > > > > > We now require that the user create a > > > > Struts2GuicePluginModule< > > > > > > > > > > http://code.google.com/p/google-guice/source/browse/trunk/extensions/struts2/src/com/google/inject/struts2/Struts2GuicePluginModule.java > > > > >when > > > > setting > > > > up their GuiceServletContextListener< > > > > > > > > > > http://code.google.com/p/google-guice/source/browse/trunk/extensions/struts2/example/src/com/google/inject/struts2/example/ExampleListener.java > > > > > > > > > and > > > > this will statically inject the Guice Injector into the > > > > Struts2Factory< > > > > > > > > > > http://code.google.com/p/google-guice/source/browse/trunk/extensions/struts2/src/com/google/inject/struts2/Struts2Factory.java > > > > > > > > > . > > > > Is there anyway to set the Struts2Factory as the Object factory > without > > > > specifying it in the xml? It be nice if we could do this in code > > somehow > > > > so > > > > that we could provide an instance of the Guice injector. Or perhaps > > > after > > > > the object factory is created, is there some way that we can get a > > > > reference > > > > to it and manually insert the injector ourselves to avoid the use of > > > static > > > > injection? > > > > > > > > Thanks, > > > > Ben > > > > > > > > > >