Bryan -

Looking at Struts as a Model, View, Controller architecture, EJB access is
a strategy that is generally used IN MODEL COMPONENTS.

 - The View components are primarily the JSP's that are used for
presentation.

 - The Controller components are the Action classes you write. These must
extend  org.apache.struts.action.Action in order for Struts to work.

These two parts of Struts are the basic framework that control the
request/response flow and build the html pages.

 - Model components provide access to back-end data stores or services. The
provide a programming "Model" that make it easy for code in the Action
classes to interact with the back-end data and services. This is where
EJB's generally are useful.

The Event model in Petstore is similar to how Action classes are used in
Struts:

  - In petstore, incoming requests were translated into Events that were
then used to execute the business logic of the request
  - In Struts, Action classes coordinate the execution of the business
logic.

The parallel isn't perfect, but it's reasonable <putting on fire-proof
underwear here in anticipation of flames>. Of course, the real question to
ask is if you really need EJB's anymore once you're using Struts. You may,
but you may not.

Here are some places it may be useful to use EJB's in Struts - note all
these are Model component-based. (Others on the list may have other
thoughts to contribute here...):

- As in the Blueprints, there may be a session-ejb facade that provides a
front-end into a whole series of ejb's in the back-end. This session facade
would be accessed from the Action class. The Session Facade should return
Value Objects similar to petstore - these would be passed to the Views (jsp
pages) for presentation to the end-users.

- Entity beans may be used in a couple ways:
     - In the Action (Controller) class you may directly access an Entity
bean that is itself acting as a model component.
     - From the Action class, you may access a DAO (or some similar
pattern) that in turn access an entity bean
     - In either of these two cases Value Objects (sometimes referred to as
Data Transfer Objects or- DTOs) should be returned.

- From the Action class you may access a web service that is a wrapper for
a stateless bean on some container somewhere.

The common theme is this:

 - The View and Controller components in Struts manage interaction with and
presentation to the User.
 - Model components encapsulate interaction with a back-end service or
data-store. This is where EJB's are most useful.

Best of luck,

Kevin











bryan hansen <[EMAIL PROTECTED]> on 06/26/2002 06:54:33 PM

Please respond to "Struts Users Mailing List"
      <[EMAIL PROTECTED]>

To:   [EMAIL PROTECTED]
cc:    (bcc: Kevin Bedell/Systems/USHO/SunLife)
Subject:  Design question Struts -> EJB.


I was really looking forward to read the chapter in
the book on review at theserverside.com on Struts and
EJBs. We are currently implementing a system and are
going to use struts for the web framework and ejbs for
the model. The java blueprints return an Event from
the would be action class for comparison in struts.
The struts class returns an ActionForward instead of
an Event. I think it is really elegant how they are
handling this because they can just pass an Event to
an EJBController and then get an EventResponse back.

Is there an easy way that just isn't presenting itself
where I am looking? How are other people integrating
EJBs without just opening up the entire model?

Thanks,

Bryan

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>








--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to