The portal supports an event listening system for code to hook into the system. Event listening is configured in /portal-ejb/classes/portal.properties (and re-configured in portal-ext.properties) by configuring event handlers/listeners.
System level event handling #
Various events (e.g. application start-up, session creation and destruction, etc.) can have one or more handler classes listed. If a class is listed, it is called by the event management system. Key players in this mechanism are:
- com.liferay.portal.events.EventsProcessor (the dispatcher)
- com.liferay.portal.servlet.MainServlet (calls EventsProcessor for most events)
- com.liferay.portal.servlet.PortalSessionListener (calls EventsProcessor for session creation and destruction events)
- com.liferay.portal.action.LogoutAction (calls EventsProcessor when user logs out)
- com.liferay.portal.util.InitUtil (calls EventsProcessor during initialization)
Entity CRUD listening #
Code can be notified when most database "entities" are created, updated, deleted, etc. You can define "listeners" for the CRUD operations on users, layouts, organizations, locations, websites, etc. by defining a class that implements the interface com.liferay.portal.model.ModelListener, then making an entries in the portal-ext.properties file to "register" it. See portal.properties for more info and examples, but one an example is:
which defines a class that listens and responds to any additions, updates, and deletions from the registered user list.