if (stat == null) {
context.getFailureDescription().set(WebMessages.MESSAGES.unknownMetric(operation.require(ModelDescriptionConstants.NAME).asString()));
} else {
final Context webContext = Context.class.cast(controller.getValue());
ManagerBase sm = (ManagerBase) webContext.getManager();
ModelNode result = new ModelNode();
switch (stat) {
case ACTIVE_SESSIONS:
// todo: what about other manager implementations?
// if (sm.getDistributable() && (sm instanceof DistributableSessionManager)) {
// result.set(((DistributableSessionManager)sm).getActiveSessionCount());
// }
result.set(sm.getActiveSessions());
break;
case EXPIRED_SESSIONS:
result.set(sm.getExpiredSessions());
break;
case MAX_ACTIVE_SESSIONS:
result.set(sm.getMaxActive());
break;
case SESSIONS_CREATED:
result.set(sm.getSessionCounter());
break;
case DUPLICATED_SESSION_IDS:
result.set(sm.getDuplicates());
break;
case SESSION_AVG_ALIVE_TIME:
result.set(sm.getSessionAverageAliveTime());
break;
case SESSION_MAX_ALIVE_TIME:
result.set(sm.getSessionMaxAliveTime());
break;
case REJECTED_SESSIONS:
result.set(sm.getRejectedSessions());
break;
default:
throw new IllegalStateException(WebMessages.MESSAGES.unknownMetric(stat));
}
context.getResult().set(result);