Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-162

Prevent duplicate proxies and AOP in context services

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Should
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: OpenMRS 1.7.0
    • Component/s: None
    • Labels:
    • Complexity:
      Undetermined

      Description

      Currently, it doesn't appear possible to re-order module-provided advice so that it can participate in a transaction initiated by the same method call. The problem appears to be that the ServiceContext wraps already proxied spring beans with another proxy to add the advice.

      To reproduce the issue:

      1.) Add a bare-bones AfterReturningAdvice from a module to an
      ObsService method like saveObs(...).

      2.) In the advice, try calling
      TransactionSynchronizationManager.isSynchronizationActive() and log
      the result. If you call the service method when an enclosing
      transaction is active, the call returns true. This works as expected.

      3.) If you call saveObs(...) outside of an existing transaction (so
      that the ObsService tx interceptor initiates a new transaction) the
      call returns false. If the ordering is correct, we'd expect this to be
      true as well.

      4.) Try reordering the advice order so that the tx interceptor starts
      the transaction before the module's advice (I tried using the Ordered
      interface).

        Attachments

        1. advice-ordering.patch
          7 kB
        2. advice-ordering-refactored.patch
          9 kB
        3. advice-ordering-replacing-aop.patch
          10 kB
        4. advice-ordering-tests-pass.patch
          8 kB

          Activity

            People

            Assignee:
            batkinson Brent Atkinson [X] (Inactive)
            Reporter:
            batkinson Brent Atkinson [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: