This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

J2EE 5 spec - ch 5 injection ????  RSS feed

 
peter cooke
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After reading the J2EE 5 chapter 5 on JNDI and injection and all the threads in this group on injection. I am more confused than before I started.


When hear the word injection, I visualize, a syringe forcibly pushing something (antibiotics) into some stream (blood vein) that changes the environment (blood), the altered environment then has a behavioral effect on some targeted component (virus dies).


When I first started trying to understand what injection is/was. I envisioned a way for a deployer/assember to specify to the container a new object to pass parameters and return information through accessing existing EJBs. The existing EJB would not need to know that the in/out bound streams were altered in some way that change the way a component behaves.

My understanding of section 5:
Resource injection, Injection of Resource Manager Connection Factories, Injection of Resource Environment References, �� - I find using annotations very useful. I cannot see how this is an injection of information. My problem is component needs to know this information to make the component work normally. We are not adding something to the environment that changes the behavior of the component




What is it?
How is supposed to work?
Why did they add it?
To me it appears to injections are simply using annotations to specify initial deployment descriptor information. Why did they just not call it annotated deployment information?
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter,
When I first started trying to understand what injection is/was. I envisioned a way for a deployer/assember to specify to the container a new object to pass parameters and return information through accessing existing EJBs. The existing EJB would not need to know that the in/out bound streams were altered in some way that change the way a component behaves.

What is it?
How is supposed to work?

This is one type of injection. When writing unit tests on legacy code, this definition is sometimes used.

When injecting a resource, you have something like:

The container is injecting the actual datasource at runtime. Your code doesn't know about any of the details. The component still needs to know, but this is out in the deployment descriptor. So you can change it without a recompile.

Having the resource injected provides the opportunity to change the behavior. In production, you want to use the datasource defined in the deployment descriptor. When testing, you may not want to use the JNDI at all. Resource injection allows you to do this by treating DataSource as an interface.

Why did they add it?

EJB 1 & 2 are complicated. This is an attempt to simplify things.

To me it appears to injections are simply using annotations to specify initial deployment descriptor information. Why did they just not call it annotated deployment information?

Injections are more powerful than simplify annotated deployment information. Consider these two cases: If I inject the fact that my EJB is a stateless session bean, I am just using annotated deployment information. If I inject the fact my EJB uses a datasource, the container is injecting an actual object.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!