in src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java [133:188]
public void onChange(final List<ResourceChange> changes) {
for(final ResourceChange change : changes){
// check if the event handles something in the search paths
String path = change.getPath();
int foundPos = -1;
for(final String sPath : this.searchPath) {
if ( path.startsWith(sPath) ) {
foundPos = sPath.length();
break;
}
}
boolean handled = false;
if ( foundPos != -1 ) {
// now check if this is a rewriter config
// relative path after the search path
final int firstSlash = path.indexOf('/', foundPos);
final int pattern = path.indexOf(CONFIG_PATH, foundPos);
// only if firstSlash and pattern are at the same position, this might be a rewriter config
if ( firstSlash == pattern && firstSlash != -1 ) {
// the node should be a child of CONFIG_PATH
if ( path.length() > pattern + CONFIG_PATH.length() && path.charAt(pattern + CONFIG_PATH.length()) == '/') {
// if a child resource is changed, make sure we have the correct path
final int slashPos = path.indexOf('/', pattern + CONFIG_PATH.length() + 1);
if ( slashPos != -1 ) {
path = path.substring(0, slashPos);
}
// we should do the update async as we don't want to block the event delivery
final String configPath = path;
final Thread t = new Thread() {
@Override
public void run() {
if (change.getType() == ChangeType.REMOVED) {
removeProcessor(configPath);
} else {
updateProcessor(configPath);
}
}
};
t.start();
handled = true;
}
}
}
if ( !handled && change.getType() == ChangeType.REMOVED ) {
final Thread t = new Thread() {
@Override
public void run() {
checkRemoval(change.getPath());
}
};
t.start();
}
}
}