1 Reply Latest reply on Jul 12, 2005 10:24 AM by John Singleton

    Optimizing number of ejbLoad() calls

    Deepak Nadig Newbie

      I have not looked at the JBoss code yet, but it looks like the EJB container always calls ejbPassivate() at the end of the transaction. This is unnecessary, especially if the container can determine if nothing has changed in an EJB.

      In this case, the container would leave an EJB in the READY state at the end of the transaction, and can reuse this EJB instance, with same primary key, in another transaction. Thereby, reducing the need for an ejbLoad().

      Some implications of this are
      (i) Violation of EJB spec
      This can be controlled via the use of a 'time-before-passivation' delay that users can configure. If this value is '0', then users can ensure that their application will run on all application servers. If portability is not a requirement, then one can specify a non-zero value and leverage cache opportunities.
      (ii) Introducing a mechanism for the container to determine if anything has changed.
      This can be done with the container invoking a method on the EJB bean instance (hasChanged()).
      Again, the developer can determine portability.

      Nothing new here ... I think WebLogic has been leveraging this for a while.