001 /**
002 * Copyright (C) 2010-2011, FuseSource Corp. All rights reserved.
003 *
004 * http://fusesource.com
005 *
006 * The software in this package is published under the terms of the
007 * CDDL license a copy of which has been included with this distribution
008 * in the license.txt file.
009 */
010 package org.fusesource.hawtdispatch.transport;
011
012 import java.net.SocketAddress;
013
014 import org.fusesource.hawtdispatch.DispatchQueue;
015
016 /**
017 * A TransportServer asynchronously accepts {@see Transport} objects and then
018 * delivers those objects to a {@see TransportAcceptListener}.
019 *
020 * @version $Revision: 1.4 $
021 */
022 public interface TransportServer {
023 /**
024 * Starts the service. Executes the onComplete runnable once the service has fully started up.
025 *
026 * @param onComplete my be set to null if not interested in a callback.
027 */
028 void start(Runnable onComplete) throws Exception;
029
030 /**
031 * Stops the service. Executes the onComplete runnable once the service has fully stopped.
032 *
033 * @param onComplete my be set to null if not interested in a callback.
034 */
035 void stop(Runnable onComplete) throws Exception;
036
037 /**
038 * Registers an {@see TransportAcceptListener} which is notified of accepted
039 * channels.
040 *
041 * @param acceptListener
042 */
043 void setTransportServerListener(TransportServerListener acceptListener);
044
045 String getBoundAddress();
046
047 String getConnectAddress();
048
049 /**
050 * @return The socket address that this transport is accepting connections
051 * on or null if this does not or is not currently accepting
052 * connections on a socket.
053 */
054 SocketAddress getSocketAddress();
055
056 /**
057 * Returns the dispatch queue used by the transport
058 *
059 * @return
060 */
061 DispatchQueue getDispatchQueue();
062
063 /**
064 * Sets the dispatch queue used by the transport
065 *
066 * @param queue
067 */
068 void setDispatchQueue(DispatchQueue queue);
069
070 /**
071 * suspend accepting new transports
072 */
073 void suspend();
074
075 /**
076 * resume accepting new transports
077 */
078 void resume();
079
080 }