what is the difference between jndi binding of module and app in Java ee 6/7?

不羁的心 提交于 2020-07-10 03:27:07

问题


We migrated from Jboss EAP 5 to EAP 6 in our development environment.

I now see the following in my JBOSS logs. I am trying to understand how this binding happens. I have read JBOSS docs on JNDI namespace binding. Still I am not totally clear how it works. Here is my log.

java:global/customerCare/services/UserDaoImpl!com.example.services.UserDao
java:app/services/UserDaoImpl!com.example.services.UserDao
java:module/UserDaoImpl!com.services.UserDao
java:global/customerCare/services/UserDaoImpl
java:app/services/UserDaoImpl
java:module/UserDaoImpl

Here are my EJBs

@Local
public interface UserDao {

    public static final String JNDI_NAME = "java:global/customCare/services/UserDaoImpl";

//interface methods here

}

@Stateless
public class UserDaoImpl implements UserDao {
// implement methods
}

My doubts are:

  1. I explicitly had JNDI binding to be java:global/customCare/services/UserDaoImpl in my UserDao interface. Then why do I see I binding for others such as app and module.

  2. what is the difference between app and module? when would binding to these components be needed? some example here to illustrate will be very helpful

  3. The last three lines of log show binding to UserDaoImpl. Is it something that JBoss does without I ask it to bind? ( I set only UserDao but not UserDaoImpl for JNDI binding).

I am a bit illiterate on JNDI Namespace binding. Reading docs helped me but not to great extent.

Thanks


回答1:


I can answer doubt 2: All the names are the same thing but with different contexts.

The global name is a full JNDI context that is used to bind globally, ie. from a client or from another EAR file

The module name can be used to bind within the same application, ie different EJBs within the same EAR

The local name is used to bind locally, ie within an jar or war.

It is slightly more efficient to use the shorter names to bind locally than specifying a full global name each time.

From what I have seen JBoss EAP 6 will always list the three / six names for every enterprise bean during deployment. It is intended to help you as a developer identify the JNDI name(s) for the bean.



来源:https://stackoverflow.com/questions/29039353/what-is-the-difference-between-jndi-binding-of-module-and-app-in-java-ee-6-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!