Meaningless Drivel is fun!*
The moose likes Architect Certification (SCEA/OCMJEA) 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Stateful Session Bean" Watch "Stateful Session Bean" New topic
Author

Stateful Session Bean

Rama Ghanta
Ranch Hand

Joined: May 28, 2008
Posts: 38
Hello Ranchers,
Can we call a stateless session bean from a StatefulBean. I want to implement my DAO (EAO) as a stateless bean and shopping cart is a stateful bean. Can we use DI to inject stalessBean in Stateful. Please let me know if this architecture makes sense.

Thanks
Rama Zha
[ September 06, 2008: Message edited by: Rama Zha ]

SCJP, SCWCD, SCEA 5
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
้hm, I think what you talking about is not relate to architecture, it's about implementation.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Indeed, this is definitely possible.

For the SCEA exam, I think you'll want to be able to diagram that relationship. I think going down to the part for dependency injection is definitely to low a level of detail for the exam, but regardless, it would definitely work.

I doubt I'd use a stateful session bean if I had a web based client. I'd probably want to shift the burden of state management to the HttpSession, but it's just an alternative.

-Cameron McKenzie
Pratik Das
Greenhorn

Joined: Jun 28, 2008
Posts: 20
You use dependency injection to get rid of service locator. This needs to come out in some form in your architecture.This will also play a role in deciding whether your calling client is a managed component. So is DI a low level detail?
Rama Ghanta
Ranch Hand

Joined: May 28, 2008
Posts: 38
Cameron, Thank you for the reply.
So having the shopping cart as a stateless session bean and maintaining the state with HTTPSession on the web-tier is a valid implementation? The EJB spec says to implement the shopping cart as a StatefulBean. The Java Petstore reference implementation 1.1 has the same logic. I don't have any handson with either technology, I'm just following the literature from Core Patterns and EJB Spec.

Pratik,
I have a business delegate and a service locator in my design. Now that I can use DI, I was thinking of just using JSF Backing bean instead of a Business Delegate.
[ September 07, 2008: Message edited by: Rama Zha ]
Pratik Das
Greenhorn

Joined: Jun 28, 2008
Posts: 20
You donot need a business delegate and service locator as long as your calling client is a managed component(servlet/JSF managed bean). You can introduce a business delegate if you want to introduce flexibility of using a single business layer interface for multiple types of clients (both managed and unmanaged-swing based).
Alexandre Portugal
Greenhorn

Joined: Jul 11, 2008
Posts: 11
Hi Rama Zha.

I doubt this architecture you plan to use (DAO's as Stateless Session Beans) makes sense... Here's what I think:

We should use the Session Bean component model to benefit from the advantages provided by the EJB container, right? I will list here some of these advantages. Do you really need them? If not, why using such a complex model? I would rather implement the DAO's as POJO.

- distribution
Do you plan to distribute your DAO's?

- transaction management
Do your DAO's are aware of transactions? Usually, this would be the Session Facade responsibility...

- thread management / instance pooling
Do you need instance pooling for your DAO's? Aren't they just some very light objects?
 
Consider Paul's rocket mass heater.
 
subject: Stateful Session Bean
 
Similar Threads
Session facade
can we write socket programming inside the bean class business method?
Shopping Cart as Stateful Bean
Stateful session beans or Stateless combined with entity beans
SessionSynchronization interface & session bean