tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-Louis MONTEIRO <>
Subject Re: Making use of the injection facility?
Date Thu, 07 May 2009 07:07:05 GMT

Awesome ! It's definitely a feature I would like to have.
I've already seen such a feature in OpenEJB, but It's not fully achieved
(from my point of view).

Internally, OpenEJB relies on XBean to perform dependency injections.

Even if it's not part of the specification, I'm quite sure it would help end

Any thoughts ?


ljnelson wrote:
> Hello; I'm writing a JUnit test runner that I would like to perform
> EJB-compliant dependency injection.
> That is, if I have a test class like this:
> @RunWith(MyTestRunner.class)
> public class SomeTest {
>   @EJB
>   protected ArgleBargle bean;
> }
> ...then I want the test runner to, using the local server of OpenEJB,
> inject, if possible, an instance of type ArgleBargle into the bean field.
> I've already checked out the DI example by Jonathan Gallimore (
> but this seems to kind of hack "just enough" DI in there to make it work.
> And I've already overridden the createTest() method of
> BlockJUnit4ClassRunner to create a new InitialContext with the proper
> LocalServer properties.
> That means that in my hands I have the raw materials to make a set of
> org.apache.openejb.Injections: I have a test class, from which I can get
> annotated fields.  And I have an InitialContext all set up with an ENC (at
> least I think there should be one; maybe not), as created by
> If I can get my hands on the Injections, built properly, then I should be
> able to call InjectionProcessor.construct(), right?
> My overall question is: is this the most efficient way to do this, or is
> there some sort of all-in-one munger buried in the OpenEJB codebase
> somewhere that will do this for me?
> I do recognize that I am violating the specification: a test class is
> neither a web module, an ejb module nor an application client module, and
> so
> hence strictly speaking cannot have dependency injection performed on it.
> However, it seems to me that OpenEJB is flexible enough in its innards
> that
> if you supply all the right raw materials there must be some decoupled
> class
> somewhere that will scan an *arbitrary* class and attempt to perform
> injection on it.  Is that the case?
> Best,
> Laird

View this message in context:
Sent from the OpenEJB User mailing list archive at

View raw message