struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Handy, Steve" <Steve.Ha...@ps.net>
Subject RE: Communicating with EJB's from Action
Date Thu, 29 Mar 2001 23:03:59 GMT
Chris,

What we've done is this:

- Put a layer of business logic session stateless beans above the entity
EJBs.  The beans in this layer have methods that perform specific business
functions.

- Have the Action classes translate the user's click into one or more calls
to the business logic layer.  We don't pass the ActionForm to the business
layer, because the ActionForm is too close to the view.  If we need to pass
a set of related data items to the business layer, we do it with a value
object that represents the kind of businessy attributes you'd find in an
EJB.

So, we partition responsibility like this:

JSPs: rendering. To us this is View.

Actions: translation of user actions into business operations (if necessary)
and always a decision about what to display next.  This layer doesn't
implement business operations, but knows what high level business operation
it needs to call to fulfill the user's request.  We consider this layer to
be Controller.

Business session stateless beans: fulfillment of business function.  For
cross-entity operations, do the details here.  Speak in only business terms,
not in any view terms.  Completely independent of Struts.  Still Controller
for us.

Entity EJBs: Fulfill single-entity business operations here (like basic
value checking of attributes).  Of course, these EJBs also give us all the
entity-bean function we get from the container.  Only this layer knows about
the database.  In general, we don't let an entity EJB interact with another
entity EJB; we leave this to the session stateless beans above.  This is our
Model.

Utility classes:
  ActionForms - for passing view-specific information around between Actions
& JSPs, etc.
  Value objects - for passing entity-specific information around, including
up to and down from the Actions.

Steve

-----Original Message-----
From: Assenza, Chris [mailto:cassenza@Accessdc.com]
Sent: Thursday, March 29, 2001 4:59 PM
To: 'struts-user@jakarta.apache.org'
Subject: Communicating with EJB's from Action


Hello! :) 

Our dev team for a big enterprise app has been going back and forth on how
to send the data from the ActionForm to a Session bean.  We have a number of
options and I was hoping for some feedback because we've had enough talk and
its time to decide! :) (Our architecture is as of now to use only Session
Beans, but we will probably start wrapping Entity beans with Session beans
eventually).

1) Send the ActionForm to the EJB from Action perform()
	Pros: Easy and less work
	Cons: Defeats the purpose of Struts in that the Business Logic is no
longer self-contained and independent of the V in MVC :). If for whatever
reason we overhaul the front end and remove Struts, we're not in the ideal
position to do so. 

2) Create a special utility class that with special methods, that when
invoked from the Action perform() method, will put the data from ActionForm
into a HashTable.  Then, we'll pass that object to the EJB and do whatever
business logic is necessary.  

3) JMS - Sort of an adaptation of the number 2 as JMS uses HashMaps and the
like but it follows a specific spec and has a lot more to it then what we'd
be doing above.  However, none of us really know much about JMS yet. :|
Obviously we can learn, but is it a recommended path to follow from your
experience? (in regards to Struts specifically as well). 

4) RMI or RMI-IIOP.  Create a remote object within the client and pass the
remote reference to the EJB.  The EJB can then use this reference to make
callbacks to the client.  Not sure about this one either, seems rather
inefficient.

Oh, and one other question, since DataTable (Java collection) is basically
made up of vectors, can one use the iterate tag to move through it?

Any thoughts or experiences?? :)

Thanks,

Chris Assenza

Mime
View raw message