This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Business delegate should be used in EJB tier?

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On p. 651 of Charles Lyons book:

6. A doctor's practice is upgrading its infrastructure, allowing patients to book appointments online, clerical staff to access records through a desktop client application, and doctors and surgical staff to maintain patients' records. The data is stored as EJBs, backed by a database. Patients and clerical staff only ever access appointment times and patient address details, while surgical staff requires access to entire patient records. Which collaborative patterns would you implement in the EJB tier to allow both client applications and web applications to access the data?
a. Front controller
b. business delegate
c. service locator
d. transfer object

Answer: B, D
Explanation:
The business delegate can be used to control access to the other EJBs through Java EE's declarative security model, as well as providing a single interface for both client and web applications. Since some staff need entire records, it is sensible for the delegate to collect this data together into a single transfer object when sending large amounts at once; other staff and patients access only one or two pieces of data may not require a transfer object.
A is incorrect, as a front controller can only be used in a web application.
C is incorrect as a service locator is used by (and distributed in ) a web application or desktop client application in order to obtain a reference to a remote EJB as as a delegate; therefore C is not implemented in the EJB tier.


On. p 637, there is a diagram showing that a delegate is inside the EJB container.

My questions are :
why a delegate should be in the EJB tier (or container) ? A delegate is a component which interacts between the web application or client and the business logic. In general, it is not related to any EJB tier.
why a service locator , which is used to look up EJBs by names is not in EJB tier? can an EJB be looked up by a service locator in the EJB tier?
 
K. Tsang
Bartender
Posts: 3585
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well by pattern names, business delegate, service locator and transfer object patterns are all in the business (aka EJB) tier according to the Core J2EE design patterns.

Does the question specify how many answers are needed?

Just guessing, service locator may not apply because in JEE6, do you "really need" a service locator class when there is dependency injection and annotation @EJB etc.

Personally I don't agree with the explanation for service locator.
 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Tsang, thanks for your reply.
The book specifies two answers, business delegate and transfer object. Service locator is not the option as the book says service locator is not implemented in EJB tier.
 
K. Tsang
Bartender
Posts: 3585
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Himai Minh wrote:Hi, Tsang, thanks for your reply.
The book specifies two answers, business delegate and transfer object. Service locator is not the option as the book says service locator is not implemented in EJB tier.


Well if it's only 2, I won't choose service locator given my reason above.

As for phrase "service locator is not implemented in EJB tier" is definitely wrong.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2535
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As for phrase "service locator is not implemented in EJB tier" is definitely wrong.

I agree with K. Tsang here.

Check this website and you can see that it is in the Business (i.e. EJB) tier: corej2eepatterns
 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks for your reply.

A is incorrect, as a front controller can only be used in a web application.


I think front controller is in the presentation layer. So, it can be used in both web application and client application, not only web application.
 
K. Tsang
Bartender
Posts: 3585
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Himai Minh wrote:I think front controller is in the presentation layer. So, it can be used in both web application and client application, not only web application.


Disagree, client application I believe is talking about GUI apps rather than web apps. Of course GUI can access web pages but that's another thing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic