@Override
     public void process(Packet packet) throws UnauthorizedException, PacketException {
        try {
            JID recipient = packet.getTo();
            // Check if the target domain belongs to a remote server or a component
            if (server.matchesComponent(recipient) || server.isRemote(recipient)) {
                routingTable.routePacket(recipient, packet);
            }
            // The target domain belongs to the local server
            else if (recipient == null || (recipient.getNode() == null && recipient.getResource() == null)) {
                // no TO was found so send back the packet to the sender
                routingTable.routePacket(packet.getFrom(), packet);
            }
            else if (recipient.getResource() != null || !(packet instanceof Presence)) {
                // JID is of the form <user@domain/resource>
                routingTable.routePacket(recipient, packet);
            }
            else {
                // JID is of the form <user@domain>
                for (JID route : routingTable.getRoutes(recipient, null)) {
                    routingTable.routePacket(route, packet);
                }
            }
        }
        catch (Exception e) {
            Log.error(LocaleUtils.getLocalizedString("admin.error.deliver") + "\n" + packet.toString(), e);
        }
    }
This ChannelHandler writes packet data to connections.

@author Iain Shigeoka
@see PacketRouter
xmppserver/src/main/java/org/jivesoftware/openfire/net/SocketPacketWriteHandler.java