aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Stateful Session Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Stateful Session Bean" Watch "Stateful Session Bean" New topic
Author

Stateful Session Bean

Ajai
Ranch Hand

Joined: May 29, 2002
Posts: 198
Hi,

In normal shopping cart scenario,i have the below flow.

Servlet->SLSB Facade(Remote) -->SFSB Shopping Cart(Local)

How do I get the handle for SFBS shopping cart stored in my HttpSession given that local interfaces don't have getHandle method .


Thanks.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Why do you need the Handle of SFSB when it is accessed throught the SLSB.You could just store the reference to SFSB in SLSB.


Groovy
Ajai
Ranch Hand

Joined: May 29, 2002
Posts: 198
Thanks Pradip.

Do you mean I should store SFSB as an instance variable in SLSB?
If yes , then how do I make sure that each httpsession in web gets a reference to its own SFSB since SLSB will not distinguish between clients?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Originally posted by Ajai Sandhu:
Thanks Pradip.

Do you mean I should store SFSB as an instance variable in SLSB?
If yes , then how do I make sure that each httpsession in web gets a reference to its own SFSB since SLSB will not distinguish between clients?


I understand your problem now. You should make the facade as stateful as explained in Session facade design pattern.
http://java.sun.com/blueprints/corej2eepatterns/Patterns/SessionFacade.html
Sirish Kumar Gongal Reddy
Ranch Hand

Joined: Oct 25, 2004
Posts: 109
Hi Ajai Sandhu,
I think that you are very clear about Handle right ? Getting the handle in the sense your SFSB will return duplicate copies of remote objects there by your clinet should be use your remote object only.
In EJBHome interface there is one function called
getHomeHabdle() it returns HomeHandle(It's also an interface).
Hope that your Doubt is cleared.
Regards,
G Sirish Reddy.,
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Originally posted by G Sirish Reddy:
Hi Ajai Sandhu,
I think that you are very clear about Handle right ? Getting the handle in the sense your SFSB will return duplicate copies of remote objects there by your clinet should be use your remote object only.
In EJBHome interface there is one function called
getHomeHabdle() it returns HomeHandle(It's also an interface).
Hope that your Doubt is cleared.
Regards,
G Sirish Reddy.,



How is getting the Homehandle useful in the above case?
Sirish Kumar Gongal Reddy
Ranch Hand

Joined: Oct 25, 2004
Posts: 109
Hi Pradip Bhat,
How is getting the Homehandle useful in the above case?
A)First it decrese the no.or Network calls.
* as soon as you obtaining the remote object you are passing that remote object reference to your clients also for to use the same resource which is used by you on the server.this graduvally decrease the Network calls.
If possible plz go thru Mastering EJB by EDRoman.
Thanks,
G Sirish Reddy.,
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Originally posted by G Sirish Reddy:
Hi Pradip Bhat,
How is getting the Homehandle useful in the above case?
A)First it decrese the no.or Network calls.
* as soon as you obtaining the remote object you are passing that remote object reference to your clients also for to use the same resource which is used by you on the server.this graduvally decrease the Network calls.
If possible plz go thru Mastering EJB by EDRoman.
Thanks,
G Sirish Reddy.,



G Sirish Reddy

Home objects are stateless.
Ajai
Ranch Hand

Joined: May 29, 2002
Posts: 198
Hi Pradip,

I posted the que since I read somewhere that SFSB was used behind SLSB facade for shopping case scenario.I feel the only way to get the SFSB handle and save it in session would be to use SFSB(remote) benind SLSB facade .Am I right?


Thanks
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Originally posted by Ajai Sandhu:
Hi Pradip,

I posted the que since I read somewhere that SFSB was used behind SLSB facade for shopping case scenario.I feel the only way to get the SFSB handle and save it in session would be to use SFSB(remote) benind SLSB facade .Am I right?


Thanks


I dont where you read this but their example may be different. Why session are you talking about - http session ? If you use a SLSB facade then how will you ever use the handle ?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

I am curious to know what else does your Facade class do apart from talking to SFSB?
Ajai
Ranch Hand

Joined: May 29, 2002
Posts: 198
Thanks for interest .

I dont where you read this but their example may be different. Why session are you talking about - http session ?
If you use a SLSB facade then how will you ever use the handle ?




I read about this example in a forum in javaranch, I could not find it again ,but It might just be somebody's view which I was trying to understand.
I am talking about HTTPSession.

If we get a handle for remote SFSB and return it to servlet through SLSB facade and store the SFSB handle in httpSession.
Of course we might as well use SFSB as facade itself rather than going through SLSB.

I am curious to know what else does your Facade class do apart from talking to SFSB?


Ok,SLSB facade might be doing all other normal stuff like connecting to entity beans etc. apart
from getting and providing the handle to Servlet.Take the example of a typical on line shopping case where only shopping cart is an SFSB whereas other beans can be SLSB or entity.In this scenaio i was thinking of providing only one SLSB as facade with SFSB behind it
or use two facades
one SFSB and other SLSB

thanks.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

If we get a handle for remote SFSB and return it to servlet through SLSB facade and store the SFSB handle in httpSession.
Of course we might as well use SFSB as facade itself rather than going through SLSB.


One of pupose of Session facade is to hide the client from the business objects (SFSB in your example) and if you are returning the handle to the servlet, the servlet is exposed to SFSB interface, isn't. So SFSB facade is the right way.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stateful Session Bean