Commit e6f4b8a4 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Refactoring work. JM-5 JM-6


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1537 b35dd754-fafc-0310-a699-88a17e54d16e
parent be1c1b00
......@@ -20,6 +20,8 @@ import org.jivesoftware.messenger.server.OutgoingServerSession;
import org.jivesoftware.messenger.spi.BasicStreamIDFactory;
import org.jivesoftware.messenger.user.UserManager;
import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.messenger.component.ComponentSession;
import org.jivesoftware.messenger.component.InternalComponentManager;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
......@@ -1063,6 +1065,21 @@ public class SessionManager extends BasicModule {
return Collections.unmodifiableCollection(componentsSessions);
}
/**
* Returns the session of the component whose domain matches the specified domain.
*
* @param domain the domain of the component session to look for.
* @return the session of the component whose domain matches the specified domain.
*/
public ComponentSession getComponentSession(String domain) {
for (ComponentSession session : componentsSessions) {
if (domain.equals(session.getAddress().getDomain())) {
return session;
}
}
return null;
}
/**
* Returns a collection with the hostnames of the remote servers that currently have an
* incoming server connection to this server.
......@@ -1408,7 +1425,7 @@ public class SessionManager extends BasicModule {
serverCleanupTask = new ServerCleanupTask();
timer.schedule(serverCleanupTask, getServerSessionTimeout(), getServerSessionTimeout());
// Set the new property value
JiveGlobals.setProperty("xmpp.session.server.timeout", Integer.toString(timeout));
JiveGlobals.setProperty("xmpp.server.session.timeout", Integer.toString(timeout));
}
/**
......@@ -1417,7 +1434,7 @@ public class SessionManager extends BasicModule {
* @return the number of milliseconds to elapse between clearing of idle server sessions.
*/
public int getServerSessionTimeout() {
return JiveGlobals.getIntProperty("xmpp.session.server.timeout", 5 * 60 * 1000);
return JiveGlobals.getIntProperty("xmpp.server.session.timeout", 5 * 60 * 1000);
}
public void setServerSessionIdleTime(int idleTime) {
......@@ -1425,11 +1442,11 @@ public class SessionManager extends BasicModule {
return;
}
// Set the new property value
JiveGlobals.setProperty("xmpp.session.server.idle", Integer.toString(idleTime));
JiveGlobals.setProperty("xmpp.server.session.idle", Integer.toString(idleTime));
}
public int getServerSessionIdleTime() {
return JiveGlobals.getIntProperty("xmpp.session.server.idle", 30 * 60 * 1000);
return JiveGlobals.getIntProperty("xmpp.server.session.idle", 30 * 60 * 1000);
}
/**
......
......@@ -28,6 +28,7 @@ import org.jivesoftware.messenger.spi.*;
import org.jivesoftware.messenger.container.Module;
import org.jivesoftware.messenger.container.PluginManager;
import org.jivesoftware.messenger.net.MulticastDNSService;
import org.jivesoftware.messenger.component.InternalComponentManager;
import org.jivesoftware.util.Version;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
......
......@@ -12,7 +12,7 @@
package org.jivesoftware.messenger.net;
import org.dom4j.Element;
import org.jivesoftware.messenger.ComponentSession;
import org.jivesoftware.messenger.component.ComponentSession;
import org.jivesoftware.messenger.PacketRouter;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.xmlpull.v1.XmlPullParserException;
......
......@@ -13,8 +13,6 @@ package org.jivesoftware.messenger.server;
import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.net.SocketAcceptThread;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.xmpp.packet.JID;
......@@ -80,9 +78,10 @@ public class OutgoingServerSession extends Session {
return false;
}
try {
// TODO Check if the remote hostname is in the blacklist
// TODO Keep a list of ports to connect to for each hostname or use the default
// if none was defined
// Check if the remote hostname is in the blacklist
if (!RemoteServerManager.canAccess(hostname)) {
return false;
}
// Check if a session already exists to the desired hostname (i.e. remote server). If
// no one exists then create a new session. The same session will be used for the same
......@@ -106,8 +105,7 @@ public class OutgoingServerSession extends Session {
}
}
if (session == null) {
int port = JiveGlobals.getIntProperty("xmpp.server.socket.remotePort",
SocketAcceptThread.DEFAULT_SERVER_PORT);
int port = RemoteServerManager.getPortForServer(hostname);
// No session was found to the remote server so make sure that only one is created
synchronized (hostname.intern()) {
session = sessionManager.getOutgoingServerSession(hostname);
......
......@@ -12,6 +12,7 @@
package org.jivesoftware.messenger.spi;
import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.component.InternalComponentManager;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.messenger.net.SocketPacketWriteHandler;
......
......@@ -14,6 +14,7 @@ package org.jivesoftware.messenger.spi;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.component.InternalComponentManager;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.messenger.roster.Roster;
......
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