Pregunta

When creating an enterprise Java EE application, part of the business logic like messaging (MDBs) has to be put inside the EJB module. However, there are some EJBs which can be placed inside either the EJB module or the web module. I know that separating modules allows the web tier and the business tier to be deployed in different machines. Thus, I would place my @Stateful shopping cart EJB in the web module. However, I cannot think of a standard criteria which can be applied to every piece of business logic, deciding where to put the EJBs enclosing them. Is there a guideline, standard or recommended practice for this?

¿Fue útil?

Solución

This is what I've found out so far.

The EJB module is supposed to enclose the core of the business logic for a large enterprise application. Web module, on the other hand, encloses a full-fledged web application which is supposed to take advantage of the business engine provided by the EJB module. Usually these modules are distributed among different servers for larger applications, and there are client applications (a Swing/JFX desktop application for instance) other than the web application which need to consume services provided by the core business logic which resides in EJB modules.

In other words, one would put the business logic in a separate EJB module if:

  1. It is meant to be used by multiple web or desktop applications, or
  2. Scaling considerations may force the core business logic to be handled by separate servers

In other cases, one may put his EJBs inside the web module and package the whole thing as a WAR file.

Otros consejos

As you stated in your last sentence, that is exactly what I'd propose: Use the WAR packaging for JEE6 applications, as you won't need EARs for most cases.

If you need to share business logic between several applications, then you can deploy that as a separate module. But usually such a thing is not necessary for scaling reasons, since you can as well dimension the application server running your WAR accordingly.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top