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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Adding multiple paths in event listener

Avatar

Level 5

I have an event listener in which I am listening to a path as in the below screenshot using Observation Manger . How can I add multiple paths here , so that I can listen to multiple paths. I cannot add the root path, since I don't want to listen to the root path due to other project requirement constraints.

 

P_V_Nair_0-1643925056613.png

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @P_V_Nair ,

 

Try using ResourceChangeListener to handle multiple paths.

 

https://techrevel.blog/2017/03/15/resourcechangelistener/ 

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @P_V_Nair ,

 

Try using ResourceChangeListener to handle multiple paths.

 

https://techrevel.blog/2017/03/15/resourcechangelistener/ 

Avatar

Employee Advisor

As @Kishore_Kumar_ already pointed out, use the ResourceChangeListener.

 

if that's not possible: 

JackrabbitObservationManager mgr = (JackrabbitObservationManager) session.getWorkspace().getObservationManager;

JackrabbitEventFilter filter = new JackrabbitEventFilter()
  .setAbsPath(PATH1)
  .setAdditionalPaths(PATH2,PATH3, ...)
...

mgr.addEventListener(listener, filter);

This allows to you specify more constraints than the JCR compliant JCR ObservationManager. In Oak the ObservationManager implements the JackrabbitObservationManager.

 

See

https://jackrabbit.apache.org/api/2.12/org/apache/jackrabbit/api/observation/JackrabbitEventFilter.h... https://jackrabbit.apache.org/api/2.12/org/apache/jackrabbit/api/observation/JackrabbitObservationMa...