The @Resource annotation has two attributes as name and mappedName. I've seen some books uses "name" attribute, and some books uses "mappedName" attribute, especially for JMS client examples. Please look at the following two examples:
I'm really confused with above two attributes. Are they same?
I try already to submit this post but it seams that this system want something else.
So, the @Resource is heavy overloaded and this make it a little bit fuzzy. I identify 3 main ways to use it :
1.the container resource which is not attached in the container context - like ServeltContext or the TimeService. For this you don't need the name parameter.
2.inject a resource and bound it to a certain ENC name (if this resource is not already bounded). In this way other classes (and beans) can reach this resource via jndi lookup using the given ENC name.
2.1.the vendor specific name mapping. There are cases when a vendor map some resource under some vendor specific name. If you use this resources then the you get a dependency on a specific container. So you need to map this vendor specific to a ENC name.
Here you map the vendor specific "vendor" name to a container independent ENC name ("myDS")
3.The class level - used to defines which resources will be located via JNDI in a specific class.
the logic is similar with the one on the 2 and 2.1