• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Business Delegate in JEE5

 
Bartender
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a very basic question.
My solution will be having this layered architecture(following JEE5)

JSP->Controller->Business Delegate->Session Bean->DAO->entity

I am using JSF at the web tier. Session Beans means stateless and stateful session beans and they are following Service Facade design pattern.

Seperate DAO layer as i didn't wanted to clutter Session Beans with entitymanager.

I am using Business Delegate for two reasons:
1) Exception handling and converting unchecked exceptions appropriately.
2) In case when the device is something else than thin client(web browser)
following Adam's blog and not using any retired patterns

Question
1) Can the Session Beans(Service Facade) be injected directly into Business Delegate? or do i have to have service locator pattern?
2) Is this okay or i am making some real blunder?
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ashutosh,

Such details are not allowed in this forum. It is against Oracle policy

Regards,
Amit
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quite frankly I don't feel that the question violates any policy. Its a general question on how to use patterns. The problem domain is not mentioned anyway, so I don't see any issues.

Ashutosh, Coming to the issue:-
First of all, You need to be sure if you really want to go with a Business delegate for your case. The reason being, after EJB3.0 both delegator and service locator becomes redundant(Until unless your web layer and EJBs are deployed on 2 separate servers). So decide on this one before.
Second, if you decide to go ahead with Delegator, it is recommended to use Service locator to get the EJB.


Regards,
Anil Chowdary K
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A Business Delegate on the Presentation-tier and a Business Delegate on the Business-tier serve different purposes.

1) Can the Session Beans(Service Facade) be injected directly into Business Delegate? or do i have to have service locator pattern?



Yes, a Presentation-tier Business Delegate can and should have a reference to the Session Facade object.

No, you do not have to implement the Service Locator pattern here. I suggest that you do not use Service Locator here.
 
Sharma Ashutosh
Bartender
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Anil and Jimmy for your answers.
Have you gone thru the book from Adam-Bien(Real World JEE patterns)? Good amount of J2EE(1.4 or prior) patterns has been retired in JEE5 onwards - Business Delegate and Service locator is also retired now.
For all the non managed components(not managed by the application server)-like Business Delegate-we can't rely on DI and inject the Service Facade or Service into them. And that is the reason-we need to use the Service Locator pattern here.

I already mentioned my reasons for using Business Delegate pattern:
1) Exception handling and converting unchecked exceptions appropriately.
2) In case when the device is something else than thin client(web browser).


I asked the same question to Adam Bien via email and he also confirmed this. when we are using non-managed components like Business Delegate-we can't use DI and we have to do lookup via ServiceLocator Design pattern.
 
Anil Chowdary
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ashutosh,

Thats correct, You can't DI components which are not managed. So using service locator is a good option.

Regards,
Anil Chowdary K
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could certainly apply Dependecy Injection with Service Locator and a Business Delegate. There is no dependency on something called a
"managed" or "non-managed" aspect.

Aside, object-oriented design patterns are not dependent on, and do not specifiy any technology. They are not dependent upon any particular programming language.

JNDI code directly in the Business Delegate eliminates the need for a Service Locator implementation.
 
I don't always make ads but when I do they're tiny
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic