You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "vlad.balan" <vl...@gmail.com> on 2011/03/01 18:39:34 UTC

LocalClient question

Hello,

why do you have to call 

initialContext.bind("inject", this);

when using @LocalClient?

Isn't @LocalClient enough to do all the injection when it is discovered: the
so called deploy action?
Why it happens in 2 times?

Is it because at deployment time it is the annotated class bytes that get
modified (independent of any instance) and than, at run time, the instance
(referred by "this") needs some more actions to be fully equiped - actions
taken by bind("inject", this)?


-- 
View this message in context: http://openejb.979440.n4.nabble.com/LocalClient-question-tp3330242p3330242.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: LocalClient question

Posted by David Blevins <da...@gmail.com>.
On Mar 1, 2011, at 9:39 AM, vlad.balan wrote:

> Hello,
> 
> why do you have to call 
> 
> initialContext.bind("inject", this);
> 
> when using @LocalClient?
> 
> Isn't @LocalClient enough to do all the injection when it is discovered: the
> so called deploy action?
> Why it happens in 2 times?
> 
> Is it because at deployment time it is the annotated class bytes that get
> modified (independent of any instance) and than, at run time, the instance
> (referred by "this") needs some more actions to be fully equiped - actions
> taken by bind("inject", this)?

Exactly.  We read the byte code at deploy time and that lets us know what things that class will eventually need and we take the steps to ensure they are properly built and available at runtime.  But was we don't have any roll in actually constructing instances of that class (junit, testng, etc will do that themselves), we offer that hook as a way of saying "I created this instance, but I want you to do injection on it".

-David