aspose file tools*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes VLH of petstore Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "VLH of petstore " Watch "VLH of petstore " New topic
Author

VLH of petstore

Dhiren Joshi
Ranch Hand

Joined: Dec 09, 2003
Posts: 463
In petstore VLH is directly accessed thorugh JSP CatalogHelper is defined as a bean.
Is that generally how VLH r implemented ?

If so then where is the need for a VLH to have to go thru SLSB
if VLH is stored in httpsession ?

Thanks
Dhiren
Deepak Pant
Ranch Hand

Joined: Feb 13, 2004
Posts: 445
Dhiren,

The reference (or handle) of VLH (SFSB) is generally stored in HTTP Session.

JSP->Helper Class->BusinessDelegate->VLH

The business delegate stores the reference in the HTTP Session.

This pattern has its own pros/cons. Caching results doesnot mean that the system will scale and respond well.
Dhiren Joshi
Ranch Hand

Joined: Dec 09, 2003
Posts: 463
Deepak.
VLH petstore According to this CatalogHelper is the VLH.

It doesnt act as an intermeidary class to access VLH via business delegate.

Where /How is the CatalogHelper at all persisted in session in petstore ?
Intially I thought that VLH should be accessible as SFSB as Petstore creates CatalogHelper in ShoppingCart but seeing the JSP brought a new issue which I wasnt aware of and now CatalogHelper is the VLH creates even more confusion. I also read that VLH should be a SFSB but petstore didnt implement like that either. They have used a simple POJO.
Deepak ,can u please explain how a SFSB impl can follow the VLH pattern according to this sequence diagram.


Thanks
Dhiren
Alastair Calderwood
Greenhorn

Joined: Jan 13, 2005
Posts: 22
Dhiren,

VLH can either be a POJO or referenced by a SFSB. The helper could either be the VLH or locate a VLH-SFSB via Business Delegate, as Deepak said. The bottom line is that if you are likely to click on what you want in the results you get (i.e. view=results) it will probably be a POJO, but if you need to refine the search further it will be a SFSB. I suppose for FBN both of these have arguments for and against.

The difference between the two is in the Blueprints, see

http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html


Java Object Strategy

The ValueListHandler can be implemented as an arbitrary Java object. In this case, the ValueListHandler can be used by any client that needs the listing functionality. For applications that do not use enterprise beans, this strategy is useful. For example, simpler applications may be built using servlets, JavaServer Pages (JSP) pages, Business Delegates, and DAOs. In this scenario, the Business Delegates can use a ValueListHandler implemented as a Java object to obtain list of values.

Stateful Session Bean Strategy

When an application uses enterprise beans in the business tier, it may be preferable to implement a session bean that uses the ValueListHandler. In this case, the session bean simply fronts an instance of a ValueListHandler. Thus, the session bean may be implemented as a stateful session bean to hold on to the list handler as its state, and thus may simply act as a facade (see "Session Facade" on page 291) or as a proxy.
Dhiren Joshi
Ranch Hand

Joined: Dec 09, 2003
Posts: 463
Alastair ,
Thanks for clarifying VLH for me.
I am still confused over how petstore mixed EJBActions and they dont have business delegate.
I read in the Core J2EE for VLH pattern that it should have its own facade and business deletgate.
if petstore implemented somthing like EJBActions .. they didnt use BD or is it becuase they used only POJO VLH .
The main confusion is that if I implement as EJBActions a certain VLH based functionality then does my EJBAction call need to go thru a BD or can it go directly to a facade.
In fact BD has nt beeen used in the pet store so I dont see why a BD is always added for VLH pattern.

The way I see is that a VLHEJBAction should go to a facade and then if a JSP invokes the VLH ,using the helper as deepak pointed out we should access the business delegate.

Or is the BD used only when invoking a VLH directly from a JSP using the helper. ?

Thanks
Dhiren
Alastair Calderwood
Greenhorn

Joined: Jan 13, 2005
Posts: 22
Dhiren,

Petstore does seem confusing... I think that what Petstore calls the Web Controller is actually the BD, and the EJB Controller is the facade. The point of this BD is that it simplifies access to services on a different tier, i.e. allows the web tier to access the session facade and POJOs on the business tier.

Another point... the diagrams showing VLH are (over?)simplified as they only show what happens in that particular pattern, not the patterns it relies on such as BD, or the relationships between them. So when you see "Client" in the Petstore Catalogue diagram, IMO it just means any incoming call from the client's direction, which could be from a BD or a JSP or anything.

I think Petstore relies on a framework (WAF) where modules are treated as a black box, and it only describes a few design patterns where the WAF has been extended in an application-specific way. For SCEA I want to show the design patterns in detail and then factor them into modules at the end - but either approach works. I just don't think Petstore is always the best place for detailed examples of using patterns.

Alastair
Dhiren Joshi
Ranch Hand

Joined: Dec 09, 2003
Posts: 463
Alastair

Petstore does seem confusing... I think that what Petstore calls the Web Controller is actually the BD, and the EJB Controller is the facade. The point of this BD is that it simplifies access to services on a different tier, i.e. allows the web tier to access the session facade and POJOs on the business tier.

Ok that clarifies a bit but I read for VLH in core J2EE design pattern that the BD and facade shd not mix the business logic BD and facades so we definitely need to make them separate for best practices.

Another point... the diagrams showing VLH are (over?)simplified as they only show what happens in that particular pattern, not the patterns it relies on such as BD, or the relationships between them. So when you see "Client" in the Petstore Catalogue diagram, IMO it just means any incoming call from the client's direction, which could be from a BD or a JSP or anything.


So the way I interpret it and correct me if I am wrong.
When a VLH is first invoked it whould come thru the EJBActions. and when the browse functionality of VLH is invoked it shd come directly from JSP via the helper class which calls BD.

That way I can correlate how it is implemented as an EJBACtion in petstore and why even thru JSP a direct call to VLH has been made.

Does that make any sense. ?
Thanks
Dhiren
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: VLH of petstore