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

EJB Spec violationg for session bean rules.

 
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Result:
17:44:51,781 INFO [Server] JBoss (MX MicroKernel) [4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)] Started in 27s:938ms

17:46:51,796 INFO [STDOUT] Enter:HelloUserBean.init()
17:46:51,796 INFO [STDOUT] [PostConstruct]
17:46:51,796 INFO [STDOUT] Exit:HelloUserBean.init()

17:46:51,828 INFO [STDOUT] Enter:HelloUserBean.sayHello()
17:46:51,828 INFO [STDOUT] Hello Curious George !
17:46:51,828 INFO [STDOUT] Exit:HelloUserBean.sayHello()

17:54:52,625 INFO [STDOUT] Enter:HelloUserBean.passivate()
17:54:52,765 INFO [STDOUT] [PrePassivate]
17:54:52,765 INFO [STDOUT] Exit:HelloUserBean.passivate()

18:01:14,796 INFO [STDOUT] Enter:HelloUserBean.activate()
18:01:14,796 INFO [STDOUT] [PostActivate]
18:01:14,796 INFO [STDOUT] Exit:HelloUserBean.activate()

18:01:14,984 INFO [STDOUT] Enter:HelloUserBean.sendMessage()
18:01:14,984 INFO [STDOUT] The client slept for 10 minutes and woke up to test passivation and activation concept.
18:01:14,984 INFO [STDOUT] Exit:HelloUserBean.sendMessage()

18:02:15,062 INFO [STDOUT] Enter:HelloUserBean.die()
18:02:15,062 INFO [STDOUT] After this method, the sfsb instance will be removed.
18:02:15,062 INFO [STDOUT] Exit:HelloUserBean.die()

18:02:15,218 INFO [STDOUT] Enter:HelloUserBean.destroy()
18:02:15,218 INFO [STDOUT] [PreDestroy]
18:02:15,218 INFO [STDOUT] Exit:HelloUserBean.destroy()



EJB Core specification:
Statement#1: This specification requires that the ejbRemove, ejbActivate, and ejbPassivate methods of the SessionBean interface, and the ejbCreate method of a stateless session bean be treated as PreDestroy, PostActivate, PrePassivate and PostConstruct life cycle callback interceptor
methods, respectively.

Statement#2:
If the session bean implements the SessionBean interface, the PreDestroy annotation can only be applied to the ejbRemove method; the PostActivate annotation can only be applied to the ejbActivate method; the PrePassivate annotation can only be applied to the ejbPassivate method. Similar requirements apply to use of deployment descriptor metadata as an alternative to the use of annotations.

Statement#3:
The setSessionContext method is called by the bean�s container to associate a session bean instance with its context maintained by the container. Typically a session bean instance retains its session context as part of its state.
----------
Questions
----------
1) The result shows that ejbRemove, ejbActivate, and ejbPassivate methods of the SessionBean interface, and the ejbCreate method are never invoked. Clearly violating
Statement # 1.

Answer: ejbCreate methods are intended for use only with the EJB 2.1 components.

2) HelloUserBean implements SessionBean init(), destroy(), passivate() and activate() methods are annotated with PostConstruct,PreDestroy, PrePassivate and PostActivate annotations. ejbRemove,
ejbActivate, and ejbPassivate methods of the SessionBean interface, and the ejbCreate method are not annotated with PreDestroy, PostActivate, PrePassivate, and PostConstruct annotations.
The result violate statement #2.
3) setSessionContext() of HelloUserBean was never invoked, hence statement #3 is violated.

If i have understood the three statements of the specification correctly, the specification is setting rules on the container to follow them and the container must obey these rules. Can someone correct the code or
let me know where is the issue?

To test passivation and activation i made the standalone java client to sleep for 10 mins and invoke other business methods,unless i could figure out how to change the passivation timeout value in JBOSS AS.
For JBOSS AS the stateful session will be passivated after 10 minutes [found out by testing].


****************************************
---------------
Environment
---------------
EJB Version : 3.0
Application Server: JBOSS 4.2.3.GA
J2SE: 1.5 or 5.0
OS: Windows XP
****************************************
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Experts, Please take time and reply.
reply
    Bookmark Topic Watch Topic
  • New Topic