0 Replies Latest reply on Jan 23, 2009 12:58 AM by Vladimir Ralev

    Order for @Oserver-annotated methods?

    Vladimir Ralev Newbie

      Hi,


      How about adding a order/priority number to the Observer annotation or having a more broad @Order(x) annotation for other callback method annotations? My use-case is this:


      I am making a framework component that logs events generated from the user-applications for statistics purposes like this:


      @Observer({"A","B","C"})
      public void frameworkLogger(Event event) {}
      




      then the user-application can have


      @Observer("A")
      public void queryAllStatistics(Event event)
      {
      //here the user will try to get the currently available statistics (the most recent stats are most interesting)
      }





      So in this case frameworkLogger will log events that will be queried in the queryAllStatistics when event A occurs. But unless there is a guarantee that frameworkLogger will always be called before queryAllStatistics the user-app may or may not see the most recent logged event recorded in the stats. There are also many other valid cases when events are communicated between a framework and user-app.


      Another use-case is in telco apps where an event comes (a phone call) and you have to start a number of decoupled and optionally-active services - you want to answer the call (call service), then you want to check if the caller has enough funds to make the call and start charging him (charging/billing service), then you want to log the the call and the status stored in the session by the previous two services (logging service) and then you want to do other optional things like start recording the call or logging it again for some third party, etc.


      The idea is to specify


      @Observer("A",order=1)
      void doSomething(){}
      
      @Observer({"A","B"},order=1) 
      void doSomething(){}
      
      @Observer("A")
      @Order(1)
      void doSomething(){}
      
      and for less useful things:
      @Create
      @Order(1)
      void doSomething(){}
      



      and still preserve the current syntax defaulting to some mid-order, say 10000, so you can plug observer before or after it.