You need to sign in or sign up before continuing.
Commit e4191659 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Packets with node or resource not null may now be delivered to components. JM-381

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@2715 b35dd754-fafc-0310-a699-88a17e54d16e
parent 7cbdfe05
......@@ -179,6 +179,19 @@ public class XMPPServer {
return false;
}
/**
* Returns true if the given address matches a component service JID.
*
* @param jid the JID to check.
* @return true if the given address matches a component service JID.
*/
public boolean matchesComponent(JID jid) {
if (jid != null) {
return componentManager.getComponent(jid.getDomain()) != null;
}
return false;
}
/**
* Creates an XMPPAddress local to this server.
*
......
/**
* $RCSfile$
* $RCSfile: SocketPacketWriteHandler.java,v $
* $Revision$
* $Date$
*
......@@ -44,10 +44,11 @@ public class SocketPacketWriteHandler implements ChannelHandler {
public void process(Packet packet) throws UnauthorizedException, PacketException {
try {
JID recipient = packet.getTo();
// Check if the target domain belongs to a remote server
if (server.isRemote(recipient)) {
// Check if the target domain belongs to a remote server or a component
if (server.matchesComponent(recipient) || server.isRemote(recipient)) {
try {
// Locate the route to the remote server and ask it to process the packet
// Locate the route to the remote server or component and ask it
// to process the packet
routingTable.getRoute(recipient).process(packet);
}
catch (NoSuchRouteException e) {
......
/**
* $RCSfile$
* $RCSfile: PacketDelivererImpl.java,v $
* $Revision$
* $Date$
*
......@@ -12,12 +12,9 @@
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;
import org.xmpp.component.Component;
import org.xmpp.packet.JID;
import org.xmpp.packet.Packet;
/**
......@@ -35,11 +32,8 @@ public class PacketDelivererImpl extends BasicModule implements PacketDeliverer
private OfflineMessageStrategy messageStrategy;
private SessionManager sessionManager;
private InternalComponentManager componentManager;
public PacketDelivererImpl() {
super("Packet Delivery");
componentManager = InternalComponentManager.getInstance();
}
public void deliver(Packet packet) throws UnauthorizedException, PacketException {
......@@ -49,17 +43,6 @@ public class PacketDelivererImpl extends BasicModule implements PacketDeliverer
if (deliverHandler == null) {
throw new PacketException("Could not send packet - no route" + packet.toString());
}
// Check if the target of the packet is the a component itself. If it does then just pass
// the packet to the component for processing it
JID recipient = packet.getTo();
if (recipient != null && recipient.getNode() == null && recipient.getResource() == null) {
// Check for registered components
Component component = componentManager.getComponent(recipient);
if (component != null) {
component.processPacket(packet);
return;
}
}
// Let the SocketPacketWriteHandler process the packet. SocketPacketWriteHandler may send
// it over the socket or store it when user is offline or drop it.
deliverHandler.process(packet);
......
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