Activation/Passivation

Discussions

EJB design: Activation/Passivation

  1. Activation/Passivation (7 messages)

    Hi

    The concept of Activation/Passivation is applicable to both Entity as well as Session Beans. This is done internally by the server(as they are factory methods).

    There are two methods getHandle()and getEJBObject() which seems to do the same task as Activation/Passivation. This is controlled by the code(not a factory method).
     
    Are these two similiar???? Pls put some light on this.....

    Threaded Messages (7)

  2. A handle is basically a "dead" reference, similar to a stringified IOR in the CORBA world, while the EJBObject can be thought of as a "live" object reference. What I mean by "dead" reference is that the reference is used to locate another reference, the "live" reference.

    I know, I know, a bad metaphor but I hope you got my point :)
  3. Activation/Passivation[ Go to top ]

    Activation and passivation are actioned performed by the container when it decides to free up resources and save an instances state.

    A handle is a serializable reference to a bean instance.

    So you could send the handle across VMs for example, perhaps via a JMS message.
  4. Thank U Aaron.

    Agree with ur explanation .

    Activation/Passivation stores the 'state' of the bean in the memory.
    Similarly,getHandle()/getEJBObject does the same. isn't it???
    In this scenario, can we use both ... if so, when to use what?

    Thanks in Advance
  5. Activation/Passivation stores the 'state' of the bean in the memory.


    The spcifications don't state where the state is passivated to, but I'd bet my bottom dollar it's not memory. The whole point of passivation is that the container hits a point where it realises it needs to free some memory up, so it stores the state, probably either to a file store or a database and then destroys the bean instance, releasing the memory.

    > Similarly,getHandle()/getEJBObject does the same. isn't it???

    getEJBObject and getHandle allow you to get a reference to a bean instance. A handle is serializable though, which means you could store it for use later, even in a different VM, that's my understanding.

    Local references don't have handles because you would never synchronise a local reference to use in another VM for example, they are local to the currrent VM.

    Whereas there is a getEJBLocalObject, or something like that.

    > In this scenario, can we use both ... if so, when to use what?

    As a bean provider, you don't 'use' passivation and activation. You would never call ejbActivate or ejbPassivate yourself, these would only ever be used by the container, hence them being known as container callback methods.

    If you wanted a serializable reference to a bean instance then use it's handle, otherwise it's EJBObject.

    > Thanks in Advance
    No worries.
  6. Activation/Passivation stores the 'state' of the bean in the memory.

    >
    > The spcifications don't state where the state is passivated to, but I'd bet my bottom dollar it's not memory. The whole point of passivation is that the container hits a point where it realises it needs to free some memory up, so it stores the state, probably either to a file store or a database and then destroys the bean instance, releasing the memory.
    *** Agree that it stores in some persistent storage. Can we access this info.
    >
    > > Similarly,getHandle()/getEJBObject does the same. isn't it???
    >
    > getEJBObject and getHandle allow you to get a reference to a bean instance. A handle is serializable though, which means you could store it for use later, even in a different VM, that's my understanding.
    >
    > Local references don't have handles because you would never synchronise a local reference to use in another VM for example, they are local to the currrent VM.
    >
    > Whereas there is a getEJBLocalObject, or something like that.
    >
    > > In this scenario, can we use both ... if so, when to use what?
    >
    > As a bean provider, you don't 'use' passivation and activation. You would never call ejbActivate or ejbPassivate yourself, these would only ever be used by the container, hence them being known as container callback methods.
    >
    > If you wanted a serializable reference to a bean instance then use it's handle, otherwise it's EJBObject.
    *** Understood that when u need serializable reference , we need to go getHandle()/getEJBObject() combination. One small suggestion.. these two method are like lock&key. They are used in conjunction when u would like to serialize.

    >
    > > Thanks in Advance
    > No worries.
  7. The handle itself is serializable. But once you've deserialised it, you would call getEJBObject to get the instance to work with. But the thing you serialize is the handle, not the EJBObject. Perhaps I'm not interpreting your question as it is meant, do you want to repost?
  8. Thank You Aaron