Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Stateful Bean

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 questions:
1. What will happen if I put some parameters inside ejbCreate() for a Stateless Bean. Will it compile/deploy.
2. Suppose if I am holding a reference of a stateless bean inside a stateful bean. what will happen during passivation. Is it right to do such a thing??
Please let me know the answers to the above.
 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer to your first question:
Stateless session bean can hold state, but doesn�t hold client-specific state because a client is not guaranteed to use the same session bean instance for different method invocations. The container has the freedom to swap stateless instances back and forth between clients. It means after each method invocation, the stateless EJB clears itself out from the information of the past invocations, therefore, using a stateless EJB, it does not make sense to call the create method with a parameter because immediately after the call, the parameter will be cleared. Client-independent data can be cached in a stateless bean if:
The information being cached will never change, and
The application can tolerate a copy of the same cacher repeated in each stateless bean instance that the container creates
To answer your second question:
The container preserves remote references to other beans with the conversational state when the stateful session bean is passivated. However, I do not understand why your stateful session bean refers to a stateless session bean.
 
    Bookmark Topic Watch Topic
  • New Topic