1 Reply Latest reply on Dec 2, 2009 7:44 PM by nickarls

    Transactional observers

    asookazian

      http://docs.jboss.org/weld/reference/1.0.0/en-US/html_single/#d0e3997


      This portion of the spec looks particularly interesting.  Seam has the concept of raising events and observing them via the @RaiseEvent and @Observer annotations.


      It is possible in Seam to use the Events API as follows to raise an event:


      Events.instance().raiseEvent("foo.bar");



      Obviously this is not a typesafe solution so the CDI version has made this typesafe.


      Is the other intention to allow more fine-grained control in terms of when the event is raised?


      There are five kinds of transactional observers:

          *

            IN_PROGESS observers are called immediately (default)

            AFTER_SUCCESS observers are called during the after completion phase of the transaction, but only if the transaction completes successfully
          *

            AFTER_FAILURE observers are called during the after completion phase of the transaction, but only if the transaction fails to complete successfully
          *

            AFTER_COMPLETION observers are called during the after completion phase of the transaction
          *

            BEFORE_COMPLETION observers are called during the before completion phase of the transaction


      Using this technique, we could do audit logging or error logging for tx's...  pretty cool...


        • 1. Re: Transactional observers
          nickarls

          Arbi Sookazian wrote on Dec 02, 2009 19:37:

          Is the other intention to allow more fine-grained control in terms of when the event is raised?


          Well, you raise what you raise but with qualifiers (included membered ones) you have fine-grain-control over who is observing them without having to pick the event apart and see if you are really interested in it.