SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
SCJP, SCJD, SCWCD, OCPJBCD
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Look at us ... look at what they make you give ...
SCJP 5, SCWCD 5, SCBCD 5, SCEA 5, SCDJWS 5
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Paul Kay wrote:Hey Jothi,
You are quite right there.
@Resource can inject a resource as well as a bean.
The resource can not be an 'unregistered' POJO.
You can inject registered POJOs. for eg, JSF managed beans.
You would be able to inject 'any' POJOs in the future release(most probably). Thats really gonna help a lot.
Anything registered in the JNDI and managed by the container can be injected. ( Container needs to create it )
@EJB can only inject local and remote beans.
@Resource can be used anywhere for eg. web tier to inject resources.
Interestingly, EJBs can also be injected into Application clients in ACC 'static' ally.
@Inject is also for DI. Its getting amusing now, isnt it?
OK, @Inject is like generic and takes only the jndiName whereas @Resource and @EJB are more specific and more configurable with attributes like sharable, resourceType , authenticationType etc.
@Resource can be used at class level whereas @Inject and @EJB are method and field level.
Hope this helps you.
Wish you a happy and successful New Year.
- Paul
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
The Bean Provider uses the EJB annotation to annotate a field or setter property method of the bean
class as a target for the injection of an EJB reference. The reference may be to a session bean’s business
interface or to the local home interface or remote home interface of a session bean or entity bean.
....However the (Resource) annotation can be also used for e-mails servers resources, environmennts entries, Orb references or even for EJB instances.
SCJP, SCJD, SCWCD, OCPJBCD
SCJP, SCJD, SCWCD, OCPJBCD
Look at us ... look at what they make you give ...
SCJP 5, SCWCD 5, SCBCD 5, SCEA 5, SCDJWS 5