JavaEE 6: @EJB (beanInterface = "")

Can someone help me understand the use of the beanInterface parameter of beanInterface annotations in JavaEE 6?

I have a situation where I have an EJB and I want it to be accessed locally and remotely.

I have MyBaseInterface and then MyEJBLocalInterface and MyEJBRemoteInterface extending MyBaseInterface . Now I have MyEJB that implements both MyEJBLocalInterface and MyEJBRemoteInterface .

Now I have a situation where I want to access only MyEJB locally.

Can I do the same with the following?

 @EJB(beanInterface=MyEJBLocalInterface.class) private MyBaseInterface instanceOfLocallyAccessedMyEJB; 

Can someone help me understand the use of the beanInterface parameter of the beanInterface attribute?

Thanks.

+6
source share
1 answer

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

  • In EJB 3.X, you can use it to indicate whether you want to use remote access to the local EJB link that you are accessing, in your case.
  • In EJB 2.X, it is used to specify the Home / LocalHome interface of a session / bean entity

To summarize, yes. You must use it to enter the desired interface.

This may not be supported in earlier versions of JBoss.

+5
source

Source: https://habr.com/ru/post/898698/


All Articles