I'm a beginner in AEM development, and I'm learning about event listening and handlers. I was stuck with some doubt and I searched on the internet but that didn't get more clarity so I am writing here.
Correct me if I'm wrong. Thank you
Solved! Go to Solution.
hello @shamyaswanth
1. javax.jcr.observation.EventListener:
This interface is part of the Java Content Repository (JCR) API. It allows you to listen to events at the JCR level, which means you can capture events related to changes in the content repository (e.g., node creation, modification, deletion). It's a low-level API specific to JCR. ResourceChangeListener is the recommended one instead. Details added below.
2. org.osgi.service.event.EventHandler:
This is part of the OSGi (Open Service Gateway initiative) framework, which is the underlying modular framework used in AEM. The EventHandler interface allows you to listen to events at a higher level within the OSGi framework. It uses the OSGi Event Admin service to receive events. You can use it to capture custom events or events from other parts of the system. It's more versatile and flexible than the JCR-level EventListener.
3. org.apache.sling.api.resource.observation.ResourceChangeListener:
This interface is specific to Apache Sling, which is a web framework built on top of the OSGi framework and is used in AEM. The ResourceChangeListener is used to listen for changes in Sling resources (content nodes in AEM). It's designed to work with Sling resources and provides a higher-level abstraction for handling resource-related events.
If you want to listen for changes to Sling resources (content nodes), you can use org.apache.sling.api.resource.observation.ResourceChangeListener. This is the preferred way for AEM-specific event handling.
Reference link: https://techrevelhub.wordpress.com/2017/03/15/resourcechangelistener/
Hello @shamyaswanth
hope this below article help your queries. It's very well written, please give it a read
https://medium.com/@toimrank/aem-handler-and-listener-12b6c8b5a3d3
Hope it helps!
Views
Replies
Total Likes
I already read this article and I didn't get that much clarity with it
Views
Replies
Total Likes
hello @shamyaswanth
1. javax.jcr.observation.EventListener:
This interface is part of the Java Content Repository (JCR) API. It allows you to listen to events at the JCR level, which means you can capture events related to changes in the content repository (e.g., node creation, modification, deletion). It's a low-level API specific to JCR. ResourceChangeListener is the recommended one instead. Details added below.
2. org.osgi.service.event.EventHandler:
This is part of the OSGi (Open Service Gateway initiative) framework, which is the underlying modular framework used in AEM. The EventHandler interface allows you to listen to events at a higher level within the OSGi framework. It uses the OSGi Event Admin service to receive events. You can use it to capture custom events or events from other parts of the system. It's more versatile and flexible than the JCR-level EventListener.
3. org.apache.sling.api.resource.observation.ResourceChangeListener:
This interface is specific to Apache Sling, which is a web framework built on top of the OSGi framework and is used in AEM. The ResourceChangeListener is used to listen for changes in Sling resources (content nodes in AEM). It's designed to work with Sling resources and provides a higher-level abstraction for handling resource-related events.
If you want to listen for changes to Sling resources (content nodes), you can use org.apache.sling.api.resource.observation.ResourceChangeListener. This is the preferred way for AEM-specific event handling.
Reference link: https://techrevelhub.wordpress.com/2017/03/15/resourcechangelistener/
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies