Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can CDI inject remote instances of my Bean?

Can CDI inject EJB references in my remote EJB client?

Actually I've a JUnit test case that runs locally on my system and access a EJB running on a standalone JBoss AS. I'm currently using JNDI to access remote business interface of the bean and testing the same.

I would like to know, If @Inject can help me here injecting my EJB instance directly to my test case so that I could avoid JNDI lookups and still access the EJB?

like image 698
Vicky Avatar asked Jun 17 '11 03:06

Vicky


1 Answers

Not portably. From the CDI specification:

The unrestricted set of bean types for a session bean contains all local interfaces of the bean and their superinterfaces. If the session bean has a bean class local view, the unrestricted set of bean types contains the bean class and all superclasses. In addition, java.lang.Object is a bean type of every session bean.

Remote interfaces are not included in the set of bean types.

like image 139
Brett Kail Avatar answered Sep 23 '22 22:09

Brett Kail