Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to use Interface ResourceChangeListener

Avatar

Avatar
Validate 1
Level 2
Reini-
Level 2

Likes

4 likes

Total Posts

21 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
Reini-
Level 2

Likes

4 likes

Total Posts

21 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 1
View profile
Reini-
Level 2

31-07-2016

Hi,

in the past I used some static fields (e.g. SlingConstants.TOPIC_RESOURCE_ADDED, SlingConstants.TOPIC_RESOURCE_CHANGED, ...) to implement EventHandlers. Since AEM 6.2 this static fields are deprecated. In JavaDoc I found the hint to use ResourceChangeListener instead. But I didn't find any example how to use ResourceChangeListener. Has anybody an example how to use them?

regards
Reini

Replies

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

01-08-2016

Avatar

Avatar
Validate 10
Level 3
stevec2515680
Level 3

Likes

6 likes

Total Posts

92 posts

Correct Reply

8 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 10
Level 3
stevec2515680
Level 3

Likes

6 likes

Total Posts

92 posts

Correct Reply

8 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile
stevec2515680
Level 3

01-08-2016

Avatar

Avatar
Validate 10
Level 4
Gdubz-57m2mu
Level 4

Likes

41 likes

Total Posts

123 posts

Correct Reply

9 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 10
Level 4
Gdubz-57m2mu
Level 4

Likes

41 likes

Total Posts

123 posts

Correct Reply

9 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 25
View profile
Gdubz-57m2mu
Level 4

01-02-2017

Not sure why it's not showing the @Deprecated annotation on any of the Sling API JavaDocs online[1], but if you open the org.apache.sling.api.SlingConstants class that's included in the AEM 6.2.0 UberJar, you'll see the following:

/** * The topic for the OSGi event which is sent when a resource has been added * to the resource tree. * The event contains at least the {@link #PROPERTY_PATH}, {@link #PROPERTY_RESOURCE_SUPER_TYPE} * and {@link #PROPERTY_RESOURCE_TYPE} properties. * @since 2.0.6 (Sling API Bundle 2.0.6) * * @deprecated Register a {@link ResourceChangeListener} instead */ @Deprecated public static final String TOPIC_RESOURCE_ADDED = "org/apache/sling/api/resource/Resource/ADDED"; /** * The topic for the OSGi event which is sent when a resource has been removed * from the resource tree. * The event contains at least the {@link #PROPERTY_PATH}. As the resource has already been removed * no further information like resource type etc. might be available. * @since 2.0.6 (Sling API Bundle 2.0.6) * * @deprecated Register a {@link ResourceChangeListener} instead */ @Deprecated public static final String TOPIC_RESOURCE_REMOVED = "org/apache/sling/api/resource/Resource/REMOVED"; /** * The topic for the OSGi event which is sent when a resource has been changed * in the resource tree. * The event contains at least the {@link #PROPERTY_PATH}, {@link #PROPERTY_RESOURCE_SUPER_TYPE} * and {@link #PROPERTY_RESOURCE_TYPE} properties. * Since 2.2.0 the event might contain these properties {@link #PROPERTY_ADDED_ATTRIBUTES}, * {@link #PROPERTY_REMOVED_ATTRIBUTES}, {@link #PROPERTY_CHANGED_ATTRIBUTES}. All of them are * optional. * @since 2.0.6 (Sling API Bundle 2.0.6) * * @deprecated Register a {@link ResourceChangeListener} instead */ @Deprecated public static final String TOPIC_RESOURCE_CHANGED = "org/apache/sling/api/resource/Resource/CHANGED";

[1] http://sling.apache.org/apidocs/sling8/org/apache/sling/api/SlingConstants.html#TOPIC_RESOURCE_CHANG...

Avatar

Avatar
Validate 10
Level 4
Gdubz-57m2mu
Level 4

Likes

41 likes

Total Posts

123 posts

Correct Reply

9 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 10
Level 4
Gdubz-57m2mu
Level 4

Likes

41 likes

Total Posts

123 posts

Correct Reply

9 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 25
View profile
Gdubz-57m2mu
Level 4

01-02-2017

Also worth noting, in my own search for replacement of these deprecations in our own listener classes, I stumbled onto this code sample from Adobe Consulting Services' ACS AEM Samples github[1]: SampleResourceChangeListener.java[2].

Looks like exactly what you need, Reini-.

[1] https://github.com/Adobe-Consulting-Services/acs-aem-samples
[2] https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/bundle/src/main/java/com/ad...