What is local / remote and non-interface in EJB?

I’m trying to understand what the purpose is and why we need different client views in EJB. Can someone try to explain?

+69
java java-ee ejb
Oct 11 '11 at 17:18
source share
2 answers

Type of remote client

When your EJB and its clients will be in a distributed environment, that is, EJB and clients will be on separate Java virtual machines. Example: EJBs hosted on a WebSphere application server and servlets that consume EJBs hosted on a Tomcat server.

Local view of the client

Only when it is guaranteed that another enterprise beans or customers will only access the bean within the same JVM. Example: EJB, as well as servlets deployed on the same WebSphere server.

View without interface

Almost the same as the local client, but there are differences. In this case, your bean class is not required to implement client view interfaces. All public methods of the bean class are automatically displayed by the caller. the no-interface view always gets an EJB link - just like local or remote views - either by injection or by JNDI lookup; but the Java type for EJB is a bean class type, not a local interface type. This is a convenience introduced as part of Java EE6.

Difference between local client view and non-interface view

In the absence of an interface, the client and the target bean must be packaged into a single application (EAR). In case of local viewing, the client can be packaged into a separate application, except for the corporate application. Thus, it gives you great flexibility in terms of fine-tuning your components.

Depending on the scenario of using the API, you can use the local client view and view without an interface. It is very likely that the non-interface will receive flexible functions in future specifications.

Cause

Historically or otherwise, a client who wanted to use EJB services had to β€œlook for” a bean in a container (with specific initial contexts). This is because all calls are made using the special EJB (proxy) link provided by the container. This allows the container to provide all additional bean services, such as federation, container-managed transactions, etc. Therefore, the client cannot explicitly create an EJB instance using the new operator. The client presentation is provided through certain interfaces to which the client will have access. Server-side proxy implementation is based on these interfaces. Different customer views are defined for different deployment scenarios, as described above.

+108
Oct 11 '11 at 17:23
source share

In accordance with section 3.2.2 of the EJB 3.1 standard:

Access to the bean enterprise through the local client view is only required to support local clients packaged in the same application as the bean enterprise that the local View client provides. Appropriate implementations of this specification may optionally support access to a local enterprise bean client view from a local client packaged in another application. Configuration requirements for access between applications for local client presentation are vendor specific and are outside the scope of this specification. Applications based on access between applications to the local view client are not portable.

The lack of an interface is just a convenient feature that allows you to bean localized view of the client without declaring a separate interface.

+3
Dec 28 '15 at 12:14
source share



All Articles