• 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
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

about EPractice Lab mock 2 question 9, stateless/stateful bean

 
Bartender
Posts: 2402
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EPractice Lab, mock 2 exam question 9 ,


ATMEJB has method withdrawal() with Required transaction attribute and it is calling AccountEJB method getAmount(). At the same time, ChequeProcessorSessionEJB is calling getAmount() method of AccountEJB without any transaction context.
The algorithm for getAmount() is to deduct the amount from account balance, calculate interest, update history and return the requested amount to the caller.

What best describes the AccountEJB component?
a: AccountEJB should be stateless session EJB with Requires New transaction attribute for getAmount();
b: AccountEJB should be implemented as stateful session bean with Requires transaction attribute for getAmount();
c: AccountEJB should be implemented as message driven bean with support attribute for getAmount();
d: AccountEJB should be implemented as stateless session EJB with RequiresNew transaction attribute for getAmount();



First , I think choice a and d are the same.
Second, I think AccountEJB can be a stateful bean and getAmount() can have Require attribute .
Reasons:
1. getAmount() will executed either in the withdrawal()'s transaction or starts its own transaction.
2. It is fine to have two different AccountEJB instances for ATMEJB and ChequeProcessorSessionEJB respectively. The two instances of bean can access the database of a bank account at the same time to handle the amount deduction. The database can handle concurrent access.

Of course, AccountEJB can also be stateless, as I believe.
 
Pay attention! Tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic