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

Stateful Bean

Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic