What is the difference between ResourceChangeListener and EventListener in AEM ?
Solved! Go to Solution.
Views
Replies
Total Likes
There are three type of Listener is in AEM
1. JCR Event Listeners
2. Sling Event Listener
3. Osgi Event listener
It is encouraging to use Sling Resource Listener if you are listening just the resource changes.
Check for more about sling event listener https://cqdump.joerghoh.de/2022/02/03/the-deprecation-of-sling-resource-events/
@Prashanth_02a Former is called when a resource is added/deleted/modified in Target path. These resources are not changed through the installer but through any other means like a bundle being installed directly through the framework or a configuration directly changed through the configuration admin.
ex:
@Property( label = "Change Types", description = "[ Optional ] The change event types this listener will listener for. ", name = ResourceChangeListener.CHANGES, value = {"ADDED", "CHANGED", "REMOVED", "PROVIDER_ADDED", "PROVIDER_REMOVED"} )
https://sling.apache.org/apidocs/sling7/org/apache/sling/installer/api/ResourceChangeListener.html
while EventListener can be used for event handling at the JCR level by implementing the EventListener interface. Ex: you can create an event listener that listens to the event when a new node is added.
@Mayank_Gandhi
There are two ResourceChangeListeners one is
1. org.apache.sling.installer.api.ResourceChangeListener
and other one is
2. org.apache.sling.api.resource.observation.ResourceChangeListener;
I think you mentioned about first one(org.apache.sling.installer.api.ResourceChangeListener), but i want to know about second one(org.apache.sling.api.resource.observation.ResourceChangeListener;)
org.apache.sling.installer.api.ResourceChangeListener
public interface ResourceChangeListener
OSGi Service listening for changes of resources. These resources are not changed through the installer but through any other means like a bundle being installed directly through the framework or a configuration directly changed through the configuration admin.
org.apache.sling.api.resource.observation.ResourceChangeListener;
public interface ResourceChangeListener
Listener for resource change events.
ResourceChangeListener objects are registered with the Framework service registry and are notified with ResourceChange objects when a change occurs.
ResourceChangeListener objects can inspect the received ResourceChange objects to determine the type of change, location and other properties
There are three type of Listener is in AEM
1. JCR Event Listeners
2. Sling Event Listener
3. Osgi Event listener
It is encouraging to use Sling Resource Listener if you are listening just the resource changes.
Check for more about sling event listener https://cqdump.joerghoh.de/2022/02/03/the-deprecation-of-sling-resource-events/
Thanks @arunpatidar
Views
Likes
Replies
Views
Likes
Replies