}
@Override
protected Object invoke0(String name, Object[] params, String[] signature) throws Exception {
if (name.equals("findSessions")) {
IoSessionFinder finder = new IoSessionFinder((String) params[0]);
return finder.find(getSource().getManagedSessions().values());
}
if (name.equals("findAndRegisterSessions")) {
IoSessionFinder finder = new IoSessionFinder((String) params[0]);
Set<IoSession> registeredSessions = new LinkedHashSet<IoSession>();
for (IoSession s : finder.find(getSource().getManagedSessions().values())) {
try {
getServer().registerMBean(
new IoSessionMBean(s),
new ObjectName(getName().getDomain() + ":type=session,name="
+ getSessionIdAsString(s.getId())));
registeredSessions.add(s);
} catch (Exception e) {
LOGGER.warn("Failed to register a session as a MBean: " + s, e);
}
}
return registeredSessions;
}
if (name.equals("findAndProcessSessions")) {
IoSessionFinder finder = new IoSessionFinder((String) params[0]);
String command = (String) params[1];
Object expr = Ognl.parseExpression(command);
Set<IoSession> matches = finder.find(getSource().getManagedSessions().values());
for (IoSession s : matches) {
try {
Ognl.getValue(expr, s);
} catch (Exception e) {