You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ignacio de Córdoba <ic...@skios.es> on 2009/12/07 22:02:31 UTC

EJb 3.1 (dependency injection) and Struts2 actions ¿CDI/Weld needed?

Hi there,
I'd like to know if there is a recommended approach to deal with dependency
injection on new EJB 3.1 EJBs.
I am using now a modified version of JBoss Struts2 plugin with works great
but it really does nothing more than regular JNDI lookups on every action
request call.
I wonder if there is a new approach to getting EJB 3.1 session beans
(stateless to be precise) which is what mostly I have to deal with. I've
seen in the DEV forum that a plugin for CDI/Weld is coming (hopefully soon).
Should we have to wait for this plugin or there is a simple approach to just
inject new EJBs in struts2 actions? (@EJB... ? :-) )
Of course, I have already tested new GlassFish v3, even though I'll probably
be using new JBoss 6 (I have already tested it with my previous EJB3 Struts2
projects and works ok, so I'd like to start my new projects directly with
EJB 3.1)

Thanks for any directions.
-- 
View this message in context: http://old.nabble.com/EJb-3.1-%28dependency-injection%29-and-Struts2-actions-%C2%BFCDI-Weld-needed--tp26684100p26684100.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: EJb 3.1 (dependency injection) and Struts2 actions ¿CDI/Weld needed?

Posted by Wes Wannemacher <we...@wantii.com>.
On Mon, Dec 7, 2009 at 4:02 PM, Ignacio de Córdoba <ic...@skios.es> wrote:
>
> Hi there,
> I'd like to know if there is a recommended approach to deal with dependency
> injection on new EJB 3.1 EJBs.
> I am using now a modified version of JBoss Struts2 plugin with works great
> but it really does nothing more than regular JNDI lookups on every action
> request call.

Unfortunately, this is the best mechanism that we have, currently. The
thing about the JEE5 spec is that it specified annotations for
dependency injection, but did not standardize the mechanism for
retrieving the would-be-injected objects (other than JNDI). Struts
uses various different mechanisms for instantiating classes, it has
it's own internal DI, some reflections, and even delegates to other
mechanisms like Spring or Guice. But, the problem is that struts
creates its own objects and it is the Application Server that does the
EJB injection.


> I wonder if there is a new approach to getting EJB 3.1 session beans
> (stateless to be precise) which is what mostly I have to deal with. I've
> seen in the DEV forum that a plugin for CDI/Weld is coming (hopefully soon).

This will most likely be the preferred mechanism in the future. But,
in the same thread you probably saw that this feature is a part of
JEE6.


> Should we have to wait for this plugin or there is a simple approach to just
> inject new EJBs in struts2 actions? (@EJB... ? :-) )

At this point, the only "simple approach" is JNDI lookups. The plugins
that do this currently are as good as you are going to get for now.
Since it is looking like we are going to move our internal DI toward
the specification, you will probably have better support for JEE/EJB
DI in the future.


> Of course, I have already tested new GlassFish v3, even though I'll probably
> be using new JBoss 6 (I have already tested it with my previous EJB3 Struts2
> projects and works ok, so I'd like to start my new projects directly with
> EJB 3.1)
>


-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org