ServerConnectionHandler.java 1.25 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
package org.jivesoftware.openfire.nio;

import org.apache.mina.core.session.IoSession;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.net.ServerStanzaHandler;
import org.jivesoftware.openfire.net.StanzaHandler;
import org.jivesoftware.openfire.spi.ConnectionConfiguration;
import org.jivesoftware.util.JiveGlobals;

/**
 * ConnectionHandler that knows which subclass of {@link StanzaHandler} should be created and how to build and configure
 * a {@link NIOConnection}.
 *
 * @author Guus der Kinderen, guus.der.kinderen@gmail.com
 */
public class ServerConnectionHandler extends ConnectionHandler
{
    public ServerConnectionHandler( ConnectionConfiguration configuration )
    {
        super( configuration );
    }

    @Override
    NIOConnection createNIOConnection( IoSession session )
    {
        return new NIOConnection( session, XMPPServer.getInstance().getPacketDeliverer(), configuration );
    }

    @Override
    StanzaHandler createStanzaHandler( NIOConnection connection )
    {
        return new ServerStanzaHandler( XMPPServer.getInstance().getPacketRouter(), connection );
    }

    @Override
    int getMaxIdleTime()
    {
        return JiveGlobals.getIntProperty( "xmpp.server.idle", 6 * 60 * 1000 ) / 1000;
    }
}