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; ...@@ -20,6 +20,8 @@ import org.jivesoftware.messenger.server.OutgoingServerSession;
import org.jivesoftware.messenger.spi.BasicStreamIDFactory; import org.jivesoftware.messenger.spi.BasicStreamIDFactory;
import org.jivesoftware.messenger.user.UserManager; import org.jivesoftware.messenger.user.UserManager;
import org.jivesoftware.messenger.user.UserNotFoundException; 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.JiveGlobals;
import org.jivesoftware.util.LocaleUtils; import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
...@@ -1063,6 +1065,21 @@ public class SessionManager extends BasicModule { ...@@ -1063,6 +1065,21 @@ public class SessionManager extends BasicModule {
return Collections.unmodifiableCollection(componentsSessions); 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 * Returns a collection with the hostnames of the remote servers that currently have an
* incoming server connection to this server. * incoming server connection to this server.
...@@ -1408,7 +1425,7 @@ public class SessionManager extends BasicModule { ...@@ -1408,7 +1425,7 @@ public class SessionManager extends BasicModule {
serverCleanupTask = new ServerCleanupTask(); serverCleanupTask = new ServerCleanupTask();
timer.schedule(serverCleanupTask, getServerSessionTimeout(), getServerSessionTimeout()); timer.schedule(serverCleanupTask, getServerSessionTimeout(), getServerSessionTimeout());
// Set the new property value // 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 { ...@@ -1417,7 +1434,7 @@ public class SessionManager extends BasicModule {
* @return the number of milliseconds to elapse between clearing of idle server sessions. * @return the number of milliseconds to elapse between clearing of idle server sessions.
*/ */
public int getServerSessionTimeout() { 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) { public void setServerSessionIdleTime(int idleTime) {
...@@ -1425,11 +1442,11 @@ public class SessionManager extends BasicModule { ...@@ -1425,11 +1442,11 @@ public class SessionManager extends BasicModule {
return; return;
} }
// Set the new property value // 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() { 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.*; ...@@ -28,6 +28,7 @@ import org.jivesoftware.messenger.spi.*;
import org.jivesoftware.messenger.container.Module; import org.jivesoftware.messenger.container.Module;
import org.jivesoftware.messenger.container.PluginManager; import org.jivesoftware.messenger.container.PluginManager;
import org.jivesoftware.messenger.net.MulticastDNSService; import org.jivesoftware.messenger.net.MulticastDNSService;
import org.jivesoftware.messenger.component.InternalComponentManager;
import org.jivesoftware.util.Version; import org.jivesoftware.util.Version;
import org.jivesoftware.util.LocaleUtils; import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
package org.jivesoftware.messenger.net; package org.jivesoftware.messenger.net;
import org.dom4j.Element; import org.dom4j.Element;
import org.jivesoftware.messenger.ComponentSession; import org.jivesoftware.messenger.component.ComponentSession;
import org.jivesoftware.messenger.PacketRouter; import org.jivesoftware.messenger.PacketRouter;
import org.jivesoftware.messenger.auth.UnauthorizedException; import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
......
...@@ -13,8 +13,6 @@ package org.jivesoftware.messenger.server; ...@@ -13,8 +13,6 @@ package org.jivesoftware.messenger.server;
import org.jivesoftware.messenger.*; import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.auth.UnauthorizedException; 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.LocaleUtils;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
...@@ -80,9 +78,10 @@ public class OutgoingServerSession extends Session { ...@@ -80,9 +78,10 @@ public class OutgoingServerSession extends Session {
return false; return false;
} }
try { try {
// TODO Check if the remote hostname is in the blacklist // 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 (!RemoteServerManager.canAccess(hostname)) {
// if none was defined return false;
}
// Check if a session already exists to the desired hostname (i.e. remote server). If // 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 // 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 { ...@@ -106,8 +105,7 @@ public class OutgoingServerSession extends Session {
} }
} }
if (session == null) { if (session == null) {
int port = JiveGlobals.getIntProperty("xmpp.server.socket.remotePort", int port = RemoteServerManager.getPortForServer(hostname);
SocketAcceptThread.DEFAULT_SERVER_PORT);
// No session was found to the remote server so make sure that only one is created // No session was found to the remote server so make sure that only one is created
synchronized (hostname.intern()) { synchronized (hostname.intern()) {
session = sessionManager.getOutgoingServerSession(hostname); session = sessionManager.getOutgoingServerSession(hostname);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
package org.jivesoftware.messenger.spi; package org.jivesoftware.messenger.spi;
import org.jivesoftware.messenger.*; import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.component.InternalComponentManager;
import org.jivesoftware.messenger.auth.UnauthorizedException; import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.container.BasicModule; import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.messenger.net.SocketPacketWriteHandler; import org.jivesoftware.messenger.net.SocketPacketWriteHandler;
......
...@@ -14,6 +14,7 @@ package org.jivesoftware.messenger.spi; ...@@ -14,6 +14,7 @@ package org.jivesoftware.messenger.spi;
import org.dom4j.Document; import org.dom4j.Document;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.jivesoftware.messenger.*; import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.component.InternalComponentManager;
import org.jivesoftware.messenger.auth.UnauthorizedException; import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.container.BasicModule; import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.messenger.roster.Roster; 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