O'Reilly logo

Head First EJB by Bert Bates, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Passivation: a stateful bean’s chance at scalability...

image with no caption

When the Container decides a stateful bean is wasting resources, it’ll call the bean’s ejbPassivate() method and then save the bean into temporary storage.

Why do you care about passivation details?

Because the Container uses a special set of rules (nearly identical to Serialization) to passivate your bean, and it’s your job to make sure your instance variables are in a state that works for passivation. And it’s just a tiny bit more subtle than simply making non-Serializable values transient.

Lifecycle overview: bean passivation/activation

  1. Client doesn’t call any methods for a while, so container calls ejbPassivate() on the bean.

    image with no caption
  2. Container calls ejbPassivate() on the bean, then saves the bean to temporary storage (either through serialization or something like it).

    image with no caption
  3. Client calls a business method, so container activates the bean (through something like deserialization), calls ejbActivate(), then invokes the business method (getAdvice()) on the bean.

    image with no caption

Relax

There’s nothing on the exam about vendor-specific passivation settings or behavior.

The only thing on the exam about passivation is what you’re responsible for as a Bean Provider—getting your instance variable values in a passivatable state (we’ll talk about that next). Nothing about passivation goes into the deployment descriptor, so you don’t need to know how passivation parameters are set for any particular server.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required