struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben McCann <bmcc...@google.com>
Subject Re: Updating the Struts 2 Guice plugin
Date Fri, 03 Dec 2010 01:13:15 GMT
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 <frans@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 <bmccann@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
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message