"CptnKirk" wrote : "abirkmanis" wrote : Also note that in case of eager 
injections (the current mechanizm) new ComponentA().doStuff() throws an NPE, 
which is hardly better.
  | Had getB() actually been abstract rather than "conceptually" abstract, the 
compiler wouldn't have even let you create an instance of new ComponentA(). 
I meant if I were using the current injections (via setters, not getters), and 
didn't inject anything for B, but just called doStuff(), I would get an NPE.

Just rewrite the code I suggested to return null instead of throwing UOE, and 
the failure will be the same for both patterns - NPE in face of missing 
injection.

Note that I didn't talk about subclassing my component class, Seam could just 
intercept the call to getB, lookup the value of B and return the value - JIT 
injection, not sooner when needed.
This JIT nature of injection via getters is their added value compared to 
injection via setters or fields.
The same effect could be achieved by using Contexts.lookupInStatefulContexts 
and a type cast inside getB, but then why using annotations and interceptors at 
all? :-)


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3947304#3947304

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3947304


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to