1 11 12 package org.jivesoftware.messenger.spi; 13 14 import org.jivesoftware.messenger.container.BasicModule; 15 import org.jivesoftware.util.Log; 16 import org.jivesoftware.messenger.*; 17 import org.jivesoftware.messenger.auth.UnauthorizedException; 18 import org.jivesoftware.messenger.transport.TransportHandler; 19 import org.xmpp.packet.Packet; 20 21 26 public class PacketTransporterImpl extends BasicModule { 27 28 31 private TransportHandler transportHandler; 32 33 36 private PacketDeliverer deliverer; 37 38 41 private XMPPServer xmppServer; 42 43 48 public PacketTransporterImpl() { 49 super("XMPP Packet Transporter"); 50 } 51 52 58 public TransportHandler getTransportHandler() { 59 return transportHandler; 60 } 61 62 73 public void deliver(Packet packet) throws UnauthorizedException, PacketException { 74 if (packet == null) { 75 throw new NullPointerException (); 76 } 77 78 if (xmppServer != null && xmppServer.isLocal(packet.getTo())) { 79 deliverer.deliver(packet); 80 } 81 else if (transportHandler != null) { 82 transportHandler.process(packet); 83 } 84 else { 85 Log.warn("Could not deliver message: no deliverer available " 86 + packet.toString()); 87 } 88 } 89 90 public void initialize(XMPPServer server) { 91 super.initialize(server); 92 xmppServer = server; 93 deliverer = server.getPacketDeliverer(); 94 transportHandler = server.getTransportHandler(); 95 } 96 } 97 | Popular Tags |