• 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

Looking at code how to differentiate between Stateless and Stateful

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Can any one tell me how do i differentiate looking at the code if the code is for stateless or stateful bean in j2ee/ejb environment.
I know the entry in xml file helps in doing this but other then this is there any difference in the code.
Thanks
Harsh
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am new to ejb ,
but I think without knowing the intent of the code , it would be almost impossible to say whether this particular bean can be stateful or stateless, i mean the only difference as i see is that if you can re initialize the bean to its earlier state it essentially would end up being a stateful bean ? wouldn't it ?(ignoring the fact of course that activation/passivation wont' occur) and you manage to do it in your code without the containers help to achieve statefulness ?
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usually in stateful session bean u'll pass a paramter to the create method of the bean which would be used in maintaining the state of the bean.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't tell from the code (unless the bean implements the SessionSynchronization interface, in which case you know it's stateful, but that's a rare case). The only way to know is by looking at the deployment descriptor.
Kyle
 
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can see it in your ejb-jsr.xml file ->
<session-type> tag showas if it's Stateful or
Stateless..
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is difference in the ejbCreate method signature. The ejbCreate method of stateless session bean is empty where as that of stateful session bean is not. The other difference is in the deployment descriptor.
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Parsuram panigrahi:
There is difference in the ejbCreate method signature. The ejbCreate method of stateless session bean is empty where as that of stateful session bean is not. The other difference is in the deployment descriptor.


Actually, it is possible to have a stateful session bean with an empty ejbCreate() signature, too, which is why I didn't bring it up. But you're right that if you find an ejbCreate() and ejbPostCreate() signature that's not empty then it's a sure sign it's a stateful bean.
Kyle
[ March 18, 2003: Message edited by: Kyle Brown ]
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think, the concerete way to find out if a bean is stateful or stateless is only deployment descriptor. As Kyle said, stateful bean's create method not necessarily has a parameter.
 
Space pants. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic