JavaEE 6: @EJB(beanInterface="")
Asked Answered
D

1

7

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.

Dialyser answered 5/10, 2011 at 19:18 Comment(0)
T
6

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.

Table answered 5/10, 2011 at 22:16 Comment(1)
Do you know if jboss 6 supports '@EJB'Metempirics

© 2022 - 2024 — McMap. All rights reserved.