public void deliver(Packet packet) throws UnauthorizedException, PacketException {
        if (packet == null) {
            throw new NullPointerException();
        }

        if (xmppServer != null && xmppServer.isLocal(packet.getTo())) {
            deliverer.deliver(packet);
        }
        else if (transportHandler != null) {
            transportHandler.process(packet);
        }
        else {
            Log.warn("Could not deliver message: no deliverer available "
                    + packet.toString());
        }
    }
Delivers the given packet based on packet recipient and sender. The
deliverer defers actual routing decisions to other classes.
<h2>Warning</h2>
Be careful to enforce concurrency DbC of concurrent by synchronizing
any accesses to class resources.

@param packet The packet to route
@throws NullPointerException If the packet is null or the
                             packet could not be routed
@throws UnauthorizedException if the user is not authorised
xmppserver/src/main/java/org/jivesoftware/openfire/spi/PacketTransporterImpl.java