Commit 96fb02c6 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Changed to continue working as a module and not as a component.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@958 b35dd754-fafc-0310-a699-88a17e54d16e
parent 156752da
...@@ -64,7 +64,7 @@ import org.xmpp.component.ComponentManager; ...@@ -64,7 +64,7 @@ import org.xmpp.component.ComponentManager;
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
public class MultiUserChatServerImpl extends BasicModule implements MultiUserChatServer, public class MultiUserChatServerImpl extends BasicModule implements MultiUserChatServer,
ServerItemsProvider, DiscoInfoProvider, DiscoItemsProvider { ServerItemsProvider, DiscoInfoProvider, DiscoItemsProvider, RoutableChannelHandler {
private static final DateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); private static final DateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
static { static {
...@@ -110,6 +110,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -110,6 +110,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
private Map<JID, MUCUser> users = new ConcurrentHashMap<JID, MUCUser>(); private Map<JID, MUCUser> users = new ConcurrentHashMap<JID, MUCUser>();
private HistoryStrategy historyStrategy; private HistoryStrategy historyStrategy;
private RoutingTable routingTable = null;
/** /**
* The packet router for the server. * The packet router for the server.
*/ */
...@@ -189,6 +190,11 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -189,6 +190,11 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
return null; return null;
} }
public void process(Packet packet) throws UnauthorizedException, PacketException {
// TODO Remove this method when moving MUC as a component and removing module code
processPacket(packet);
}
public void processPacket(Packet packet) { public void processPacket(Packet packet) {
try { try {
MUCUser user = getChatUser(packet.getFrom()); MUCUser user = getChatUser(packet.getFrom());
...@@ -207,12 +213,14 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -207,12 +213,14 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
} }
public String getServiceDomain() { public String getServiceDomain() {
return chatServiceName + "." + XMPPServer.getInstance().getServerInfo().getName(); return chatServiceName + "." + XMPPServer.getInstance().getServerInfo().getName();
} }
public JID getAddress() {
return new JID(null, getServiceDomain(), null);
}
/** /**
* Probes the presence of any user who's last packet was sent more than 5 minute ago. * Probes the presence of any user who's last packet was sent more than 5 minute ago.
*/ */
...@@ -680,12 +688,21 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -680,12 +688,21 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
cleanupTask = new CleanupTask(); cleanupTask = new CleanupTask();
timer.schedule(cleanupTask, cleanup_frequency, cleanup_frequency); timer.schedule(cleanupTask, cleanup_frequency, cleanup_frequency);
routingTable = server.getRoutingTable();
router = server.getPacketRouter(); router = server.getPacketRouter();
// TODO Remove the tracking for IQRegisterHandler when the component JEP gets implemented.
registerHandler = server.getIQRegisterHandler();
registerHandler.addDelegate(getServiceDomain(), new IQMUCRegisterHandler(this));
} }
public void start() { public void start() {
super.start(); super.start();
InternalComponentManager.getInstance().addComponent(chatServiceName, this); // Add the route to this service
routingTable.addRoute(getAddress(), this);
ArrayList params = new ArrayList();
params.clear();
params.add(getServiceDomain());
Log.info(LocaleUtils.getLocalizedString("startup.starting.muc", params));
// Load all the persistent rooms to memory // Load all the persistent rooms to memory
for (MUCRoom room : MUCPersistenceManager.loadRoomsFromDB(this, this.getCleanupDate(), for (MUCRoom room : MUCPersistenceManager.loadRoomsFromDB(this, this.getCleanupDate(),
router)) { router)) {
...@@ -696,7 +713,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -696,7 +713,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
public void stop() { public void stop() {
super.stop(); super.stop();
// Remove the route to this service // Remove the route to this service
InternalComponentManager.getInstance().removeComponent(chatServiceName); routingTable.removeRoute(getAddress());
timer.cancel(); timer.cancel();
logAllConversation(); logAllConversation();
if (registerHandler != null) { if (registerHandler != null) {
......
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