/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/ package org.apache.catalina.ha.session;
/** * This class is used to track the series of actions that happens when a request is executed. These actions will then * translate into invocations of methods on the actual session. * <p> * This class is NOT thread safe. One DeltaRequest per session.
*/ publicclass DeltaRequest implements Externalizable {
protectedvoid addAction(int type, int action, String name, Object value) {
AttributeInfo info = null; if (this.actionPool.size() > 0) { try {
info = actionPool.removeFirst();
} catch (Exception x) {
log.error(sm.getString("deltaRequest.removeUnable"), x);
info = new AttributeInfo(type, action, name, value);
}
info.init(type, action, name, value);
} else {
info = new AttributeInfo(type, action, name, value);
} // if we have already done something to this attribute, make sure // we don't send multiple actions across the wire if (!recordAllActions) { try {
actions.remove(info);
} catch (java.util.NoSuchElementException x) { // do nothing, we wanted to remove it anyway
}
} // add the action
actions.addLast(info);
}
publicvoid execute(DeltaSession session, boolean notifyListeners) { if (!this.sessionId.equals(session.getId())) { thrownew IllegalArgumentException(sm.getString("deltaRequest.ssid.mismatch"));
}
session.access(); for (AttributeInfo info : actions) { switch (info.getType()) { case TYPE_ATTRIBUTE: if (info.getAction() == ACTION_SET) { if (log.isTraceEnabled()) {
log.trace("Session.setAttribute('" + info.getName() + "', '" + info.getValue() + "')");
}
session.setAttribute(info.getName(), info.getValue(), notifyListeners, false);
} else { if (log.isTraceEnabled()) {
log.trace("Session.removeAttribute('" + info.getName() + "')");
}
session.removeAttribute(info.getName(), notifyListeners, false);
}
break; case TYPE_ISNEW: if (log.isTraceEnabled()) {
log.trace("Session.setNew('" + info.getValue() + "')");
}
session.setNew(((Boolean) info.getValue()).booleanValue(), false); break; case TYPE_MAXINTERVAL: if (log.isTraceEnabled()) {
log.trace("Session.setMaxInactiveInterval('" + info.getValue() + "')");
}
session.setMaxInactiveInterval(((Integer) info.getValue()).intValue(), false); break; case TYPE_PRINCIPAL:
Principal p = null; if (info.getAction() == ACTION_SET) {
p = (Principal) info.getValue();
}
session.setPrincipal(p, false); break; case TYPE_AUTHTYPE:
String authType = null; if (info.getAction() == ACTION_SET) {
authType = (String) info.getValue();
}
session.setAuthType(authType, false); break; case TYPE_LISTENER:
SessionListener listener = (SessionListener) info.getValue(); if (info.getAction() == ACTION_SET) {
session.addSessionListener(listener, false);
} else {
session.removeSessionListener(listener, false);
} break; case TYPE_NOTE: if (info.getAction() == ACTION_SET) { if (log.isTraceEnabled()) {
log.trace("Session.setNote('" + info.getName() + "', '" + info.getValue() + "')");
}
session.setNote(info.getName(), info.getValue(), false);
} else { if (log.isTraceEnabled()) {
log.trace("Session.removeNote('" + info.getName() + "')");
}
session.removeNote(info.getName(), false);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.