Commit 8cf086b5 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

IQ packets sent to a RoutableChannelHandler (includes Components, MUC &...

IQ packets sent to a RoutableChannelHandler (includes Components, MUC & ComponentManager) that is not a ClientSession will receive and must process the IQ packet. Otherwise the previous (old) logic is applied based on the packet's namespace.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@967 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1e5c3063
...@@ -20,7 +20,6 @@ import org.jivesoftware.util.Log; ...@@ -20,7 +20,6 @@ import org.jivesoftware.util.Log;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.PacketError; import org.xmpp.packet.PacketError;
import org.xmpp.component.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -41,7 +40,6 @@ public class IQRouter extends BasicModule { ...@@ -41,7 +40,6 @@ public class IQRouter extends BasicModule {
private List<IQHandler> iqHandlers = new ArrayList<IQHandler>(); private List<IQHandler> iqHandlers = new ArrayList<IQHandler>();
private Map<String, IQHandler> namespace2Handlers = new ConcurrentHashMap<String, IQHandler>(); private Map<String, IQHandler> namespace2Handlers = new ConcurrentHashMap<String, IQHandler>();
private SessionManager sessionManager; private SessionManager sessionManager;
private InternalComponentManager componentManager;
/** /**
* Creates a packet router. * Creates a packet router.
...@@ -125,7 +123,6 @@ public class IQRouter extends BasicModule { ...@@ -125,7 +123,6 @@ public class IQRouter extends BasicModule {
routingTable = server.getRoutingTable(); routingTable = server.getRoutingTable();
iqHandlers.addAll(server.getIQHandlers()); iqHandlers.addAll(server.getIQHandlers());
sessionManager = server.getSessionManager(); sessionManager = server.getSessionManager();
componentManager = InternalComponentManager.getInstance();
} }
/** /**
...@@ -143,16 +140,21 @@ public class IQRouter extends BasicModule { ...@@ -143,16 +140,21 @@ public class IQRouter extends BasicModule {
private void handle(IQ packet) { private void handle(IQ packet) {
JID recipientJID = packet.getTo(); JID recipientJID = packet.getTo();
try { try {
// Check for registered components // Check for registered components and/or services
Component component = null;
if (recipientJID != null) { if (recipientJID != null) {
component = componentManager.getComponent(packet.getTo().toBareJID()); try {
RoutableChannelHandler serviceRoute = routingTable.getRoute(recipientJID);
if (!(serviceRoute instanceof ClientSession)) {
// A component/service was found that can handle the Packet
serviceRoute.process(packet);
return;
} }
if (component != null) {
// A component was found that can handle the Packet
component.processPacket(packet);
} }
else if (isLocalServer(recipientJID)) { catch (NoSuchRouteException e) {
// Do nothing. Continue looking for a handler
}
}
if (isLocalServer(recipientJID)) {
// Let the server handle the Packet // Let the server handle the Packet
Element childElement = packet.getChildElement(); Element childElement = packet.getChildElement();
String namespace = null; String namespace = null;
...@@ -178,19 +180,6 @@ public class IQRouter extends BasicModule { ...@@ -178,19 +180,6 @@ public class IQRouter extends BasicModule {
} }
else { else {
// JID is of the form <node@domain> // JID is of the form <node@domain>
try {
// Let a "service" handle this packet otherwise return an error
// Useful for MUC where node refers to a room and domain is the
// MUC service.
ChannelHandler route = routingTable.getRoute(recipientJID);
if (route instanceof BasicModule) {
route.process(packet);
return;
}
}
catch (NoSuchRouteException e) {
// do nothing
}
// Answer an error since the server can't handle packets sent to a node // Answer an error since the server can't handle packets sent to a node
reply.setError(PacketError.Condition.service_unavailable); reply.setError(PacketError.Condition.service_unavailable);
} }
......
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