We're using EJBs as for our Model. Is it correct for the Action to know about the Model interfaces?

Ted Husted

If you are using EJBs for the business logic layer, then yes, it's perfectly all right to bind your Actions to the EJB interfaces.

Though, some people do prefer to use EJBs as a persistence layer and then put a Facade between something like a Struts Action and the actual EJB interfaces.

It's mainly how sold you are on the EJBs. If you use a Facade it would be easier to use something else later, since you would just rewrite the Facade rather than all the Actions.

Some people also find that a Facade actually simplifies much of the Action/EJB programming, and it can pay for itself even if you never use anything else.

In general, it is in fact the Actions job to know about the Model interfaces, and well as which View to call depending on how the calls to the Model turn out.

In practice, there are usually distinct Business Logic layer and Data Persistance layer with the Model. Ideally, the Action should just call the Business Logic portion of the Model, so that it is not coupled to the Data Persistance portion. Data Persistance is one of those implementation details that people like to change over time.

In this case, a Facade (or Session Facade) could handle the Business Logic and might be able to hide other EJB details from the Action.

HTH, Ted.
Struts in Action

About | Sitemap | Contact