
org.simpleframework.transport.Controller Maven / Gradle / Ivy
/*
* Controller.java February 2008
*
* Copyright (C) 2008, Niall Gallagher
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*/
package org.simpleframework.transport;
import java.io.IOException;
/**
* The Controller
interface is used to represent the means
* to write packets to an underlying transport. This controls all of
* the selection required to determine if the socket is write ready.
* If the packet to be written is to block then this will wait until
* all queued packets are fully written.
*
* @author Niall Gallagher
*/
interface Controller {
/**
* This method is used to deliver the provided packet of bytes to
* the underlying transport. This will not modify the data that
* is to be written, this will simply queue the packets in the
* order that they are provided.
*
* @param array this is the array of bytes to send to the client
*/
public void write(Packet packet) throws IOException;
/**
* This method is used to deliver the provided packet of bytes to
* the underlying transport. This will not modify the data that
* is to be written, this will simply queue the packets in the
* order that they are provided.
*
* @param packet this is the packet of bytes to send to the client
* @param block determines if the calling thread should block
*/
public void write(Packet packet, boolean block) throws IOException;
/**
* This method is used to flush all of the queued packets to
* the client. This method will block not block but will simply
* flush any data to the underlying transport. Internally the
* data will be queued for delivery to the connected entity.
*/
public void flush() throws IOException;
/**
* This method is used to flush all of the queued packets to
* the client. This method can block until such time as all of
* the data has been sent to the client. If at any point there
* is an error sending the content an exception is thrown.
*
* @param block whether to block until all data is gone
*/
public void flush(boolean block) throws IOException;
/**
* This is used to close the writer and the underlying socket.
* If a close is performed on the writer then no more bytes
* can be read from or written to the writer and the client
* will receive a connection close on their side.
*/
public void close() throws IOException;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy