6 Replies Latest reply on Jun 28, 2002 9:43 PM by Alice

    Entity Bean Pooling Question

    Günther Van Roey Newbie

      I was playing around with JBoss3.0RC3 a little when I ran into some behaviour I didn't understand:

      When an instance of my BMP entity bean is used for executing a finder method, or when passivate() is called upon an instance, this instance is garbage collected afterwards.
      (I tested this by outputting from the finalize() method in my bean class, allthough I know the finalize() method shouldn't be implemented by a Bean Class...).

      Shouldn't bean instances in these situations be held in a pool and reused for finder and home method executions, or to activate() again with a new identity ?
      Because next time I execute a finder method, a new instance of my bean class is instantiated AND discarded afterwards!

      Is this a configuration problem, a bug, or did I misunderstood something about the pooling concept of Entity Beans ?

      Regards,

      Günther.

        • 1. Re: Entity Bean Pooling Question
          Dain Sundstrom Master

          I don't think entity beans pool. Why would you need to pool entity beans (We're talking pools not caches)? You are not allowed to hang onto connections between calls (that is what database connection pools are for, JCA in JBoss), so what would you want to do?

          • 2. Re: Entity Bean Pooling Question
            Günther Van Roey Newbie

            It's not that I have problems, all functionality works well.

            But as I'm learning EJB, and reading through several books, I'm getting an explanation about how the lifecycle of each type of EJB looks like.

            The life cycle of an entity bean starts with the instantiation and a call to the setEntityContext method, which brings the new instance in the "pooled" state, from where it can be used to execute finder and home methods, or be given an identity to serve a client's request.

            This differences from the behaviour I'm experiencing on my JBoss server.

            Can it be that the literal implementation of the quoted Entity EJB lifecycle would give a small performance advantage, or is there any specific reason for the difference between the logical life cycle and the actual implementation?

            • 3. Re: Entity Bean Pooling Question
              Falk Newbie

              Hi!

              I'm using JBoss 2.4.4 and I think, that there is Pooling and Caching of EnterpriseContext Objects. These only represents Bean Instances. So I also think, that the ejb life cycle from the spec maybe isn't just implemented in JBoss.

              If you call a findByPrimaryKey to an Object in the JBoss Entity Instance Pool, the create-methode of the bean instance is called. So by calling the create()-Method on an bean instance, the state changed immedeatly to "ready" (these objects where hold in an Instance cache), so that these bean instances are not in a pooled state.

              So I think, Instance Pooling for Bean Instances isn't really implemented (only for Stateless).

              Thats what I found out.

              If I'm thinking the wrong way, it would be very very nice, if somebody may correct me!

              • 4. Re: Entity Bean Pooling Question
                Falk Newbie

                Hi!

                I'm using JBoss 2.4.4 and I think, that there is Pooling and Caching of EnterpriseContext Objects. These only represents Bean Instances. So I also think, that the ejb life cycle from the spec maybe isn't just implemented in JBoss.

                If you call a findByPrimaryKey to an Object in the JBoss Entity Instance Pool, the create-methode of the bean instance is called. So by calling the create()-Method on an bean instance, the state changed immedeatly to "ready" (these objects where hold in an Instance cache), so that these bean instances are not in a pooled state.

                So I think, Instance Pooling for Bean Instances isn't really implemented (only for Stateless).

                Thats what I found out.

                If I'm thinking the wrong way, it would be very very nice, if somebody may correct me!

                • 5. Re: Entity Bean Pooling Question
                  Falk Newbie

                  Hi!

                  I'm using JBoss 2.4.4 and I think, that there is Pooling and Caching of EnterpriseContext Objects. These only represents Bean Instances. So I also think, that the ejb life cycle from the spec maybe isn't just implemented in JBoss.

                  If you call a findByPrimaryKey to an Object in the JBoss Entity Instance Pool, the create-methode of the bean instance is called. So by calling the create()-Method on an bean instance, the state changed immedeatly to "ready" (these objects where hold in an Instance cache), so that these bean instances are not in a pooled state.

                  So I think, Instance Pooling for Bean Instances isn't really implemented (only for Stateless).

                  Thats what I found out.

                  If I'm thinking the wrong way, it would be very very nice, if somebody may correct me!

                  • 6. Re: Entity Bean Pooling Question
                    Alice Newbie

                    JBoss gurus, Any thoughts on this??

                    Thanks.