-
-
Save saulovenancio/e502581dcfcdf277ed73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.felix.scr.annotations.Component; | |
import org.apache.felix.scr.annotations.Properties; | |
import org.apache.felix.scr.annotations.Property; | |
import org.apache.felix.scr.annotations.Service; | |
import org.apache.sling.api.SlingConstants; | |
import org.apache.sling.event.EventUtil; | |
import org.apache.sling.event.jobs.JobProcessor; | |
import org.apache.sling.event.jobs.JobUtil; | |
import org.osgi.service.event.Event; | |
import org.osgi.service.event.EventConstants; | |
import org.osgi.service.event.EventHandler; | |
//@formatter:off | |
@Service(value = EventHandler.class) | |
@Component(immediate = true, metatype = false) | |
@Properties({ | |
@Property(name = EventConstants.EVENT_TOPIC, value = SlingConstants.TOPIC_RESOURCE_ADDED) | |
}) | |
//@formatter:on | |
public class SampleEventHandler implements EventHandler, JobProcessor { | |
public boolean process(Event event) { | |
String path = (String) event.getProperty("path"); | |
String resourceType = (String) event.getProperty("resourceType"); | |
if (path.startsWith("/content/mysite/myfolder")) { | |
// process event here | |
} | |
return true; | |
} | |
public void handleEvent(Event event) { | |
if (EventUtil.isLocal(event)) { | |
JobUtil.processJob(event, this); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment