2 Replies Latest reply on Apr 27, 2004 6:31 PM by Alexey Loubyansky

    Entity synchronization refactorings

    Alexey Loubyansky Master

      For performance reasons, I want to refactor the following classes:
      - GlobalTxEntityMap
      - Entity[MultiInstance]SynchronizationInterceptor
      - EntityMultiInstanceInterceptor
      - remove TxEntityMap as a class

      * GlobalTxEntityMap

      - two TransactionLocal variables for List and Set with identical contents of instances: list - for fast iteration, set - for fast contains().
      Just List would be enough. It would be more efficient to have a variable in the EntityEnterpriseContext that would tell whether it is associated with a tx instead of using Set in GlobalTxEntityMap.

      - in synchronize(Transaction tx) both the List and the Set a thrown out. It is innefficient but we have to do it in current impl.

      Not to break stuff, I would create an interface for GlobalTxEntityMap and provide another implementation.

      * EntitySynchronizationInterceptor

      - in register(ctx, tx) we associate the ctx with TxEntityMap which is useless for this interceptor. It is used only for MultiInstance.

      - I think we could avoid instantiation of a new InstanceSynchronization per instance and registering it with the tx. We already do it in GlobalTxEntityMap. The synchronization logic could be put in 4 singleton classes one for each commit option A, B, C and D. At sync time we would just call synchronize(ctx) on the appropriate implementation according to commit option.

      * MultiInstance interceptors and TxEntityMap

      TxEntityMap is misused. It should to be used only with MultiInstance interceptors and is meant to be a per-tx-instance-cache. So, ideally, it should be another InstanceCache implementation.

      Any objections? Bless me.

        • 1. Re: Entity synchronization refactorings
          Alexey Loubyansky Master

          I just committed the org.jboss.ejb.plugins.PerTxEntityInstanceCache which, as the name implies, is a per tx org.jboss.ejb.EntityCache implementation.

          I think, Instance Per Transaction container should now be

           <container-configuration extends="Standard CMP 2.x EntityBean">
           <container-name>IPT container</container-name>

          and be always used with commit option C.

          MultiInstance interceptors and TxEntityMap should be removed. Any objections?

          • 2. Re: Entity synchronization refactorings
            Alexey Loubyansky Master

            Most of it is done:
            - TxEntityMap and MultiInstance interceptors are deprecated;
            - GlobalTxEntityMap is refactored: only the list is used and only one TransactionLocal variable;
            - per transaction EntityCache implementation is added.

            Current version is 3.2.4RC2.