开发者

JavaEE 6: @EJB(beanInterface="")

开发者 https://www.devze.com 2023-04-11 14:09 出处:网络
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

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.


the beanInterface attribute of the @EJB annotation is used for different purposes depending on the EJB version you are using:

  • In EJB 3.X you can use it to specify whether you want to use the remote of local reference of the EJB you are referring to, which is your case.
  • In EJB 2.X it is used to specify the Home/LocalHome interface of the session/entity bean

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号