On Mon, Dec 7, 2009 at 4:02 PM, Ignacio de Córdoba <icord...@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-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to