uOttawaUniversity of Ottawa - Canadas University
list of dots

Umple User Manual    [Previous]   [Next]   

Loading

Code Injection in Event Methods

State machine event methods are generated automatically from a state machine. Sometimes a programmer wants to execute some code whenever a given event is processed by a state machine, no matter what state the state machine is in.

Code can be injected before or after any event, as shown in the example below. Note that in the case of queued or pooled state machines, the injected code will only be triggered when the event is actually processed by the state machine (i.e. when it is removed from the queue).

Example


class Car {
  queued radio {
    on {
      radioToggle -> off;
    }
    off {
      radioToggle -> on;
    }
  }
  after radioToggle {soundBeep();}
}


      

Load the above code into UmpleOnline