2 Replies Latest reply on Oct 12, 2007 8:43 AM by pmuir

    ManagedEntityIdentityInterceptor and Stateful Session Beans

    wschwendt

      Can anyone enlighten me why the ManagedEntityIdentityInterceptor is only added to a Seam component when the scope of the component is CONVERSATION? (-> org.jboss.seam.Component.initDefaultInterceptors() )


      My understanding of the ManagedEntityIdentityInterceptor (which could be wrong) is that it serves to ensure that Entities referenced by a stateful component such as a stateful session bean (SFSB) maintain their object identity within the JVM even across passivations and reactivations of this stateful component.


      Let's assume that we have a stateful session bean (SFSB) referencing an Entity instance, and the the scope of the SFSB is EVENT_Scope. Since the scope is EVENT Scope and not CONVERSATION scope, no ManagedEntityIdentityInterceptor is added to this SFSB.

      Let's imagine further a situation where this SFSB is called multiple times during the life time of the EVENT scope. For example, the SFSB could serve as backing bean for multiple JSF view components and be called multiple times during the render response JSF phase.

      This raises the question: Can it happen that the EJB container passivates and then reactivates this SFSB between the different calls to this SFSB? (I'd assume yes, but could be wrong).

      If I'm not wrong with my "yes"-assumption, don't we need the ManagedEntityIdentityInterceptor added to this event-scoped SFSB component to maintain the object identity of any Entity instances referenced by the SFSB?

      Thanks in advance for any answers.

        • 1. Re: ManagedEntityIdentityInterceptor and Stateful Session Be
          wschwendt

          ok, it was strategically stupid to post the my question at the weekend.

          But now that the weekend is over, does anyone have an opinion as to whether it is sufficient to add the ManagedEntityIdentityInterceptor just to conversation-scoped components?

          Why is this interceptor not added to a stateful session bean (SFSB) when the SFSB is request-scoped? (after all, execution of a request can encompass multiple calls to the same SFSB, and can't passivation of this SFSB happen between one of these calls?).

          • 2. Re: ManagedEntityIdentityInterceptor and Stateful Session Be
            pmuir

             

            "wschwendt" wrote:
            My understanding of the ManagedEntityIdentityInterceptor (which could be wrong) is that it serves to ensure that Entities referenced by a stateful component such as a stateful session bean (SFSB) maintain their object identity within the JVM even across passivations and reactivations of this stateful component.


            Exactly.


            This raises the question: Can it happen that the EJB container passivates and then reactivates this SFSB between the different calls to this SFSB? (I'd assume yes, but could be wrong).

            If I'm not wrong with my "yes"-assumption, don't we need the ManagedEntityIdentityInterceptor added to this event-scoped SFSB component to maintain the object identity of any Entity instances referenced by the SFSB?


            The default timeout in JBoss AS is 6 minutes and its very unlikely the event scope would be this long. I think we are assuming some sense on the part of the developer here ;) And of course for every interceptor on a bean there is a performance overhead.

            WDYT?