You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2012/06/05 08:17:40 UTC
svn commit: r1346252 -
/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/SshServer.java
Author: gnodet
Date: Tue Jun 5 06:17:40 2012
New Revision: 1346252
URL: http://svn.apache.org/viewvc?rev=1346252&view=rev
Log:
[SSHD-172] Provide a way to access the list of active sessions from the server
Modified:
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/SshServer.java
Modified: mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/SshServer.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/SshServer.java?rev=1346252&r1=1346251&r2=1346252&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/SshServer.java (original)
+++ mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/SshServer.java Tue Jun 5 06:17:40 2012
@@ -389,12 +389,7 @@ public class SshServer extends AbstractF
if (acceptor != null) {
acceptor.setCloseOnDeactivation(false);
acceptor.unbind();
- for (IoSession ioSession : acceptor.getManagedSessions().values()) {
- AbstractSession session = AbstractSession.getSession(ioSession, true);
- if (session != null) {
- sessions.add(session);
- }
- }
+ sessions = getActiveSessions();
}
final CountDownLatch latch = new CountDownLatch(sessions.size());
SshFutureListener<CloseFuture> listener = new SshFutureListener<CloseFuture>() {
@@ -418,6 +413,20 @@ public class SshServer extends AbstractF
}
}
+ /**
+ * Obtain the list of active sessions.
+ */
+ public List<AbstractSession> getActiveSessions() {
+ List<AbstractSession> sessions = new ArrayList<AbstractSession>();
+ for (IoSession ioSession : acceptor.getManagedSessions().values()) {
+ AbstractSession session = AbstractSession.getSession(ioSession, true);
+ if (session != null) {
+ sessions.add(session);
+ }
+ }
+ return sessions;
+ }
+
protected IoAcceptor createAcceptor() {
return new NioSocketAcceptor(getNioWorkers());
}