
org.simpleframework.http.connect.Connection Maven / Gradle / Ivy
/*
* Connection.java October 2002
*
* Copyright (C) 2002, 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.http.connect;
import java.net.SocketAddress;
import javax.net.ssl.SSLContext;
/**
* The Connection
object is used to manage connections
* from a server socket. In order to achieve this it spawns a task
* to listen for incoming connect requests. When a TCP connection
* request arrives it hands off the SocketChannel
to
* the Server
which processes the request.
*
* This handles connections from a ServerSocketChannel
* object so that features such as SSL can be used by a server that
* uses this package. The background acceptor process will terminate
* if the connection is closed.
*
* @author Niall Gallagher
*
* @see org.simpleframework.http.Server
*/
public interface Connection {
/**
* This creates a new background task that will listen to the
* specified ServerAddress
for incoming TCP connect
* requests. When an connection is accepted it is handed to the
* internal Server
implementation as a pipeline. The
* background task is a non daemon task to ensure the server is
* kept active, to terminate the connection this can be closed.
*
* @param address this is the address used to accept connections
*/
public void connect(SocketAddress address) throws Exception;
/**
* This creates a new background task that will listen to the
* specified ServerAddress
for incoming TCP connect
* requests. When an connection is accepted it is handed to the
* internal Server
implementation as a pipeline. The
* background task is a non daemon task to ensure the server is
* kept active, to terminate the connection this can be closed.
*
* @param address this is the address used to accept connections
* @param context this is used for secure SSL connections
*/
public void connect(SocketAddress address, SSLContext context) throws Exception;
/**
* This is used to close the connection and the server socket
* used to accept connections. This will perform a close of all
* connected server sockets that have been created from using
* the connect
method. The connection can be
* reused after the existing server sockets have been closed.
*
* @throws Exception thrown if there is a problem closing
*/
public void close() throws Exception;
}