You can create an event handler in a profile.
-
Right-click a metaclass or a stereotype and select to open a selection box, listing the available event handlers.
-
Select one or more event handlers and click OK to add them to the metaclass.
-
Click on the event handler in the tree view, and enter a name and comment.
-
Click the Event Handler Script tab and enter your script:

-
Click Apply to save your changes.