Commit 7ba4332b authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Optimization. JM-476

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@3143 b35dd754-fafc-0310-a699-88a17e54d16e
parent 19d41e6f
...@@ -163,7 +163,7 @@ public class SessionManager extends BasicModule { ...@@ -163,7 +163,7 @@ public class SessionManager extends BasicModule {
*/ */
private class SessionMap { private class SessionMap {
private Map<String,ClientSession> resources = new ConcurrentHashMap<String,ClientSession>(); private Map<String,ClientSession> resources = new ConcurrentHashMap<String,ClientSession>();
private LinkedList priorityList = new LinkedList(); private LinkedList<String> priorityList = new LinkedList<String>();
/** /**
* Add a session to the manager. * Add a session to the manager.
...@@ -187,7 +187,7 @@ public class SessionManager extends BasicModule { ...@@ -187,7 +187,7 @@ public class SessionManager extends BasicModule {
private void sortSession(String resource, int priority) { private void sortSession(String resource, int priority) {
synchronized (priorityList) { synchronized (priorityList) {
if (priorityList.size() > 0) { if (priorityList.size() > 0) {
Iterator iter = priorityList.iterator(); Iterator<String> iter = priorityList.iterator();
for (int i = 0; iter.hasNext(); i++) { for (int i = 0; iter.hasNext(); i++) {
ClientSession sess = resources.get(iter.next()); ClientSession sess = resources.get(iter.next());
if (sess != null && sess.getPresence().getPriority() <= priority) { if (sess != null && sess.getPresence().getPriority() <= priority) {
...@@ -309,12 +309,8 @@ public class SessionManager extends BasicModule { ...@@ -309,12 +309,8 @@ public class SessionManager extends BasicModule {
* *
* @return An iterator of all sessions * @return An iterator of all sessions
*/ */
public Iterator getSessions() { public Collection<ClientSession> getSessions() {
LinkedList<Session> list = new LinkedList<Session>(); return resources.values();
for (Session session : resources.values()) {
list.add(session);
}
return list.iterator();
} }
/** /**
...@@ -1030,30 +1026,28 @@ public class SessionManager extends BasicModule { ...@@ -1030,30 +1026,28 @@ public class SessionManager extends BasicModule {
return between; return between;
} }
private void copyAnonSessions(List sessions) { private void copyAnonSessions(List<ClientSession> sessions) {
// Add anonymous sessions // Add anonymous sessions
for (Session session : anonymousSessions.values()) { for (ClientSession session : anonymousSessions.values()) {
sessions.add(session); sessions.add(session);
} }
} }
private void copyUserSessions(List sessions) { private void copyUserSessions(List<ClientSession> sessions) {
// Get a copy of the sessions from all users // Get a copy of the sessions from all users
for (String username : getSessionUsers()) { for (String username : getSessionUsers()) {
Collection<ClientSession> usrSessions = getSessions(username); for (ClientSession session : getSessions(username)) {
for (Session session : usrSessions) {
sessions.add(session); sessions.add(session);
} }
} }
} }
private void copyUserSessions(String username, List sessionList) { private void copyUserSessions(String username, List<ClientSession> sessionList) {
// Get a copy of the sessions from all users // Get a copy of the sessions from all users
SessionMap sessionMap = sessions.get(username); SessionMap sessionMap = sessions.get(username);
if (sessionMap != null) { if (sessionMap != null) {
Iterator sessionItr = sessionMap.getSessions(); for (ClientSession session : sessionMap.getSessions()) {
while (sessionItr.hasNext()) { sessionList.add(session);
sessionList.add(sessionItr.next());
} }
} }
} }
......
...@@ -140,7 +140,9 @@ public abstract class SocketReader implements Runnable { ...@@ -140,7 +140,9 @@ public abstract class SocketReader implements Runnable {
} }
finally { finally {
if (session != null) { if (session != null) {
Log.debug("Logging off " + session.getAddress() + " on " + connection); if (Log.isDebugEnabled()) {
Log.debug("Logging off " + session.getAddress() + " on " + connection);
}
try { try {
session.getConnection().close(); session.getConnection().close();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment