Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

lifecycle callback method question

 
leonardo segala
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers!

I have WLC question which probably wrong, but I will post to discuss:

Which statement characterizes stateless session beans?

A - They allow the PostConstruct, PreDestroy, and PrePassivate life-cycle callbacks.
B - They require home interfaces.
C - When a client looks up a stateful session bean in the JNDI, the same bean is returned every time.
D - They are asynchronous message consumers.

The correct answer by WLC is A, but PrePassivate callback is only available for stateful beans. I marked D, because MDB is a special stateless bean which supports asynchronous messages. What yours opinions?
 
Deepika Joshi
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which statement characterizes stateless session beans?
or which statement is true for Stateless Session Bean


B - They require home interfaces.
No
C - When a client looks up a stateful session bean in the JNDI, the same bean is returned every time
No (beans comes from pool, so not always same)
D - They are asynchronous message consumers.
No, because MDB is a special stateless bean which supports asynchronous messages.
A - They allow the PostConstruct, PreDestroy, and PrePassivate life-cycle callbacks.
here is tricky part, PrePassivate does not make sense for Stateless Session bean, if you have it in your bean, it won't be called but won't complain also about abuse use (not following the contract (rule) mentioned in spec).

 
Prasad Kumbhare
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

But quesiton says, Which statement characterizes stateless session beans? If we talk about having @PrePassivate in SLSB then question should have been , what callbacks are valid / allowed/ don't generate error in SLSB, or something like that. Makes sense ??
I think this could be problem in question.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic