Thanks for you reply I kind of got the picture however I was inquiring why the restriction of injected the same resource into different fields of the same class.
I deciphered this restriction after reading the below section from Mastering Ejb 3.0.
Please correct me if i am wrong.
Each resource may only be injected into a single field or method for particular bean.If you need to use a resource in more than one spot in the bean class, you need to define that resource at the class level & then look it up explicitly by name
I think that behind this affirmation is the JNDI or more precisely what happen when a resource is injected - the EJB container bounds the injected resource with a name. So if you inject the same resource two time you have the bound two times for the same resource and this can lead to confusions. Is similar with the code :
you will have two variables which are pointing to the same thing.
If you do a look up(how is suggested) then you'll use this mapping (which is doned only one) how many times you need it.
Pretty fast answer, I don't think that this is more not "desirable". The DI mechanism is triggered two times and second time is not justified because in the bean context the resource already exist (with a certain name).
Why you think that this is not permitted ?
Joined: Jun 28, 2007
I guess its not desirable but i was asking this from the exam point of view it should however be allowed i think.
However the quote above implies that it is not allowed :?: