Reading Time: 3 minutes

Galaxy includes many standard events you can use right out of the box, such as ENTRY_CREATED and LIFECYCLE_TRANSITION. (For the full list, click here). Using the Event API, you can also create your own events and create scripts that listen for them…

Let’s say we want to create an event called ENTRY_COMMENT_CREATED that’s triggered whenever a user adds a comment to an artifact (entry). We would take the following steps:

latest report
Learn why we are the Leaders in API management and iPaaS

1. Create an event class EntryCommentCreatedEvent that will be fired by the Event Manager when a comment is created.

2.  Create a constant for the event in the DefaultEvents class.

3. Create an event listener class EntryCommentCreatedEventListener, which listens for and reacts to the event, such as updating the activity log when a comment is added to an artifact.

4.  Register the event listener class in the appropriate configuration file based on the event taxonomy.

5. Fire the event through the Event Manager using eventManager.fireEvent(event);

These steps create a system event, which is automatically registered during bootstrap via the applicationContext-core.xml configuration file. If you want to create a user event, which behaves exactly the same way as a system event, it must be registered either using the galaxy-applicationContext.xml configuration file or using the addListener method to register it in code or via a script.

For complete instructions and a walkthrough of these steps, plus additional tips on naming conventions and other options you can set, see Creating Events in the Galaxy documentation. You’ll need to log in to view this page, so if you haven’t registered yet, please take a moment to do so…it’s free!