top of page
  • Writer's pictureHeena

What are Event Listeners in AEM?

Updated: Dec 12, 2023

Event listener is responsible for JCR level events which means it can capture events related to changes in the content repository.


Following are the events to which an event listener listens:

  1. Event.NODE_ADDED

  2. Event.NODE_MOVED

  3. Event.NODE_REMOVED

  4. Event.PERSIST

  5. Event.PROPERTY_ADDED

  6. Event.PROPERTY_CHANGED

  7. Event.PROPERTY_REMOVED


How to listen to an JCR event?

An event is listened by implementing EventListener interface which belongs to javax.jcr.observation package.


Listener Implementation will consist of following three methods:

  1. activate(): This method helps registering the listener by adding event listener to the observation manager. Following is the method to register an event listener. Objects.requireNonNull(session).getWorkspace().getObservationManager(). addEventListener(EventListener listener, int eventTypes, String absPath, boolean isDeep, String[] uuid, String[] nodeTypeName, boolean noLocal)

  2. deactivate(): This method will unbind the event listener we bound in activate method.

  3. onEvent(): This method is executed when an event is listened. The business logic is written inside this method.


That's all for today! If you've found this blog post informative or helpful, I’d greatly appreciate it if you could give it a like. It keeps me motivated 💛

42 views

Related Posts

See All
bottom of page