• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"Business Delegate-Session Facade" and "Command Pattern- Session Facade" pattern

 
Giju George
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to understand the difference/use between "Business Delegate-Session Facade" and "Command Pattern- Session Facade" pattern. Just trying to use the petstore as an eg. What have they implemented ? I don't see any BD, except one used for the admin. Does creating different "EVENTS" and passing it to the EJB Tier means they are using the command pattern ???

Also what pattern does the WebController and EJBController uses ???
[ May 23, 2005: Message edited by: Giju George ]
 
vu lee
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to understand the difference/use between "Business Delegate-Session Facade" and "Command Pattern- Session Facade" pattern. Just trying to use the petstore as an eg. What have they implemented ? I don't see any BD, except one used for the admin. Does creating different "EVENTS" and passing it to the EJB Tier means they are using the command pattern ???

Also what pattern does the WebController and EJBController uses ???
 
vu lee
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMO, the main difference between these two are Business Delegate vs. Command patterns since Session Facade is used behind the scence. These two patterns decouple caller from receiver but in a slightly different way. Petstore uses Business Delegate to avoid the complexity when invoking remote method. For instance, a caller does not need to know whether a remote method is implemented by RMI, MDB, or session facade. Command pattern achieves decoupling by encapsulating request as an object and associates it with a receiver. In this case, the receiver is a Session Facade.

Does creating different "EVENTS" and passing it to the EJB Tier means they are using the command pattern ???
yes, it is.
Take a look at the User Creation section in petstore app
 
John Arau
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks.

I think petstore uses the command-pattern.
The interface HTMLAction acts as the "command interface" and the CartHTMLAction for example is one of the "ConcreteCommands".
(A second command pattern is used in Business tier based on EJBAction)
http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/sample-app/images/sample-app1.3.18.gif

They don't have an explicit business delegate (they don't need it, because the WAF framework takes care of comunication with the bussiness tier)
In this case the result is the same as using a business delegate:It doesn't have any code lookups or remote exception handling nor is it coupled with the business tier:
http://java.sun.com/blueprints/code/jps131/src/com/sun/j2ee/blueprints/petstore/controller/web/actions/CartHTMLAction.java.html


"I don't see any BD, except one used for the admin" --


They use Entity beans to write/read to the database and DAO to read (the later as an option).
See the customer for example:
http://reflex.dyndns.info/java/petstore_3.pdf
or
http://reflex.dyndns.info/java/index.html

[ May 23, 2005: Message edited by: John Arau ]
[ May 23, 2005: Message edited by: John Arau ]
 
Deepak Shastri
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,
Can anyone answer to the similar concern raised in this forum

http://www.coderanch.com/t/153461/java-Architect-SCEA/certification/Club-Business-Delegate-Command-Pattern
 
Giju George
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx guys for the replies.

Vu, So according to the petstore user-creation module, the EJB Controller is the receiver for the command right ???

And which one is more reliable to use, a BD or Command Pattern... what do the guys use for the part-2 assignment ??

Also John, had a look your class diagram. Is this the type of class diagram that Sun expects for the part-2 exam??
 
John Arau
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Giju.

You have two Command patterns.
Yes, EJBController is receiver of the first.
http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/sample-app/images/sample-app1.3.13.gif

"And which one is more reliable to use, a BD or Command Pattern... "
I am personaly using the two: Business Delegate and Command Pattern.


Also John, had a look your class diagram. Is this the type of class diagram that Sun expects for the part-2 exam??


I dont think so, too much detail, and also too confusing because it's cluttered.
What you guys think?
[ May 24, 2005: Message edited by: John Arau ]
 
Giju George
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.. understood.

And what pattern is StateMachine (in petstore) implementing ? Why is it used there ?

I see that the EJBController (Command Receiver) is delegating all calls to the StateMachine, passing the event(Command).. why ???
[ May 24, 2005: Message edited by: Giju George ]
 
John Arau
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sort of a State Pattern [GoF],
* the variable actionMap is the "Context"
* the interface EJBAction is the "State"
* the decendents of the EJBActionSupport are the "ConcreteState"

The class StateMachine based on the XML configuration (mappings.xml), will determine which class to call and invoke it. (this is similar to Struts, but in the EJB tier)

e.g XML mappings
<event-class>CartEvent</event-class> <ejb-action-class>CartEJBAction</ejb-action-class>
[ May 24, 2005: Message edited by: John Arau ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic