Could someone help me understand the use of beanInterface
parameter of @EJB
annotation in JavaEE 6?
I have a situation in which I have an EJB and I want it to be accessed locally and remotely as well.
I have a MyBaseInterface
and then both MyEJBLocalInterface
and MyEJBRemoteInterface
extending MyBaseInterface
. Now I have MyEJB
which is implementing both MyEJBLocalInterface
and MyEJBRemoteInterface
.
Now I have a situation in which I want only to access MyEJB
locally.
Could I achieve the same with the following?
@EJB(beanInterface=MyEJBLocalInterface.class)
private MyBaseInterface instanceOfLocallyAccessedMyEJB;
Could someone help me understand the use of beanInterface
parameter of @EJB
attribute?
Thanks.
Annotations were introduced in Java 5.0. The purpose of having annotations is to attach additional information in the class or a meta-data of a class within its source code. In EJB 3.0, annotations are used to describe configuration meta-data in EJB classes.
javax.ejb The Local annotation is applied to the session bean class or local business interface to designate a local interface of the bean. When used on the bean class, declares the local business interface(s) for a session bean. When used on an interface, designates that interface as a local business interface.
The ejb-name of the Enterprise Java Bean to which this reference is mapped. java.lang.String. description. A string describing the bean.
EJB (Enterprise Java Bean) is used to develop scalable, robust and secured enterprise applications in java. Unlike RMI, middleware services such as security, transaction management etc. are provided by EJB Container to all EJB applications. The current version of EJB is EJB 3.2.
the beanInterface attribute of the @EJB annotation is used for different purposes depending on the EJB version you are using:
To sum up, yes. You should be able to use it to inject the desired interface.
This might not be supported in older versions of JBoss though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With