use of org.apache.sling.api.resource.observation.ResourceChange in project sling by apache.
the class JobSchedulerImpl method onChange.
/**
* @see org.apache.sling.api.resource.observation.ResourceChangeListener#onChange(java.util.List)
*/
@Override
public void onChange(List<ResourceChange> changes) {
for (final ResourceChange change : changes) {
if (change.getPath() != null && change.getPath().startsWith(this.configuration.getScheduledJobsPath(true))) {
if (change.getType() == ResourceChange.ChangeType.REMOVED) {
// removal
logger.debug("Remove scheduled job {}", change.getPath());
this.scheduledJobHandler.handleRemove(change.getPath());
} else {
// add or update
logger.debug("Add or update scheduled job {}, event {}", change.getPath(), change.getType());
this.scheduledJobHandler.handleAddUpdate(change.getPath());
}
}
}
}
use of org.apache.sling.api.resource.observation.ResourceChange in project sling by apache.
the class ScriptCacheImpl method onChange.
@Override
public void onChange(@Nonnull List<ResourceChange> list) {
for (final ResourceChange change : list) {
Runnable eventTask = new Runnable() {
@Override
public void run() {
String path = change.getPath();
writeLock.lock();
try {
final boolean removed = internalMap.remove(path) != null;
LOGGER.debug("Detected script change for {} - removed entry from the cache.", path);
if (!removed && change.getType() == ChangeType.REMOVED) {
final String prefix = path + "/";
final Set<String> removal = new HashSet<>();
for (final Map.Entry<String, SoftReference<CachedScript>> entry : internalMap.entrySet()) {
if (entry.getKey().startsWith(prefix)) {
removal.add(entry.getKey());
}
}
for (final String key : removal) {
internalMap.remove(key);
LOGGER.debug("Detected removal for {} - removed entry {} from the cache.", path, key);
}
}
} finally {
writeLock.unlock();
}
}
};
threadPool.execute(eventTask);
}
}
use of org.apache.sling.api.resource.observation.ResourceChange in project sling by apache.
the class XSSFilterImpl method onChange.
@Override
public void onChange(@Nonnull List<ResourceChange> resourceChanges) {
for (ResourceChange change : resourceChanges) {
if (change.getPath().endsWith(DEFAULT_POLICY_PATH)) {
logger.info("Detected policy file change ({}) at {}. Updating default handler.", change.getType().name(), change.getPath());
updateDefaultHandler();
}
}
}
Aggregations