EJB Concepts

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

Internal

EJB and JNDI

Session beans are bound to JNDI according to the following naming scheme:

ejb:/<application-name>/<module-name>/<distinct-name>/<bean-name>!<view-class-name>?stateful

where:

application-name

application-name is the name of the EAR application the session bean is deployed as part of.

If the session bean is not deployed as part of an EAR, that part is left blank.

If the session bean deployed as part of an EAR, the part is by default the name of the EAR file, without the .ear suffix. The name can be overridden in the application.xml deployment descriptor by specifying the <application-name> element.


The JNDI bindings for session bean named 'SimpleStatelessBean' in deployment unit 'deployment "stateless-ejb-example.jar"' are as follows:

java:global/stateless-ejb-example/SimpleStatelessBean!io.novaordis.playground.jee.ejb.stateless.SimpleStateless
java:app/stateless-ejb-example/SimpleStatelessBean!io.novaordis.playground.jee.ejb.stateless.SimpleStateless
java:module/SimpleStatelessBean!io.novaordis.playground.jee.ejb.stateless.SimpleStateless
java:jboss/exported/stateless-ejb-example/SimpleStatelessBean!io.novaordis.playground.jee.ejb.stateless.SimpleStateless
java:global/stateless-ejb-example/SimpleStatelessBean
java:app/stateless-ejb-example/SimpleStatelessBean
java:module/SimpleStatelessBean

Invoking into EJBs

TODO https://blog.akquinet.de/2014/09/26/jboss-eap-wildfly-three-ways-to-invoke-remote-ejbs/

EJB Remote Applications

An EJB remote application can be one of the following:

  • a standalone Java application
  • another component that runs within a application server instance, and makes invocations into remote EJBs. In this case, each deployed application will have its own EJB client context, and the application's components will share the EJB client context.

EJB Client API

JBoss EAP 6 introduced the EJB client API for managing remote EJB invocations. The EJB client API uses the EJB Client Context.

EJB Client Context

The EJB client context may be associated with, and used by more than one thread concurrently.

There can potentially be more than one EJB client contexts into a JVM. For deployed applications, each application will have its own EJB client context. Whenever that application invokes another EJB, the corresponding EJB client context is used to find the correct EJB receiver, which then handles the invocation.

For standalone applications, a remote standalone client typically has just one EJB client context backed by any number of EJB receivers

An EJB client context may contain any number of EJB receivers.

The EJB client context is configured with jboss-ejb-client.properties for standalone applications and with jboss-ejb-client.xml for applications deployed within the EAP.

EJB Receiver

An EJB receiver is a component that knows how to communicate with a server that is capable of handling EJB invocations.