if (pos < handlerList.size()) {
boolean writeLockedHere = false;
boolean unWriteLockedHere = false;
boolean readLockedHere = false;
boolean unReadLockedHere = false;
Handler current = (Handler) handlerList.get(pos++);
if (current.requiresWriteLock()) {
if (!writeLocked) {
if (readLocked) {
model.leaveCriticalSection();
readLocked = false;
unReadLockedHere = true;
}
model.enterCriticalSection(ModelLock.WRITE);
writeLockedHere = true;
writeLocked = true;
}
} else {
if (writeLocked) {
model.leaveCriticalSection();
writeLocked = false;
unWriteLockedHere = true;
}
if (current.requiresReadLock()) {
if (!readLocked) {
model.enterCriticalSection(ModelLock.READ);
readLocked = true;
readLockedHere = true;
}
} else {
if (readLocked) {
model.leaveCriticalSection();
readLocked = false;
unReadLockedHere = true;
}
}
}
try {
if (log.isDebugEnabled()) {
log.debug("performing " + current);
}
current.handle(request, response, this);
} finally {
if (writeLockedHere) {
model.leaveCriticalSection();
writeLocked = false;
}