Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.1 kB
1
Indexable
Never
package com.awcm.projects.ous.core.listener;

import org.apache.sling.api.resource.observation.ResourceChange;
import org.apache.sling.api.resource.observation.ResourceChangeListener;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

@Component(
        immediate = true,
        service = ResourceChangeListener.class,
        property = {
                ResourceChangeListener.PATHS+"=/content/abbvie-lets-talk-eczema-ous/gb/en/useful-tools",
                ResourceChangeListener.CHANGES+"=ADDED",
                ResourceChangeListener.CHANGES+"=REMOVED",
                ResourceChangeListener.CHANGES+"=CHANGED"
        }
)
public class ResourceEventHandler implements ResourceChangeListener {
        private static final Logger LOG = LoggerFactory.getLogger(ResourceEventHandler.class);

        @Override
        public void onChange(List<ResourceChange> list){
                for(ResourceChange rc : list){
                        LOG.info("\n Event : {}, Resource : {}", rc.getType(), rc.getPath());
                }
        }
}