final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String name = address.getLastElement().getValue();
ListenerService<?> service = (ListenerService<?>) context.getServiceRegistry(false).getService(UndertowService.listenerName(name)).getValue();
String op = operation.get(NAME).asString();
ConnectorStatistics stats = service.getOpenListener().getConnectorStatistics();
if(stats != null) {
ConnectorStat element = ConnectorStat.getStat(op);
switch (element) {
case BYTES_RECEIVED:
context.getResult().set(stats.getBytesReceived());
break;
case BYTES_SENT:
context.getResult().set(stats.getBytesSent());
break;
case ERROR_COUNT:
context.getResult().set(stats.getErrorCount());
break;
case MAX_PROCESSING_TIME:
context.getResult().set(stats.getMaxProcessingTime());
break;
case PROCESSING_TIME:
context.getResult().set(stats.getProcessingTime());
break;
case REQUEST_COUNT:
context.getResult().set(stats.getRequestCount());
break;
}
} else {
context.getResult().set(0L);
}