@Override
 public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
   resourceRegistration.registerReadOnlyAttribute(CONTEXT_ROOT, null);
   resourceRegistration.registerReadOnlyAttribute(VIRTUAL_HOST, null);
   for (SessionStat stat : SessionStat.values()) {
     resourceRegistration.registerMetric(
         stat.definition, SessionManagerStatsHandler.getInstance());
   }
 }
    @Override
    protected void executeRuntimeStep(OperationContext context, ModelNode operation)
        throws OperationFailedException {

      final PathAddress address =
          PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR));

      final Resource web =
          context.readResourceFromRoot(address.subAddress(0, address.size()), false);
      final ModelNode subModel = web.getModel();

      final String host = VIRTUAL_HOST.resolveModelAttribute(context, subModel).asString();
      final String path = CONTEXT_ROOT.resolveModelAttribute(context, subModel).asString();
      final String server = SERVER.resolveModelAttribute(context, subModel).asString();

      final ServiceController<?> controller =
          context
              .getServiceRegistry(false)
              .getService(UndertowService.deploymentServiceName(server, host, path));

      SessionStat stat =
          SessionStat.getStat(operation.require(ModelDescriptionConstants.NAME).asString());

      if (stat == null) {
        context
            .getFailureDescription()
            .set(
                UndertowMessages.MESSAGES.unknownMetric(
                    operation.require(ModelDescriptionConstants.NAME).asString()));
      } else {
        context.getResult().set("<not implemented>");
        /*final Context webContext = Context.class.cast(controller.getValue());
        ManagerBase sm = (ManagerBase) webContext.getManager();
        ModelNode result = new ModelNode();
        switch (stat) {
            case ACTIVE_SESSIONS:
                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);*/
      }

      context.stepCompleted();
    }
 static {
   for (SessionStat stat : EnumSet.allOf(SessionStat.class)) {
     MAP.put(stat.toString(), stat);
   }
 }