Package gov.usgs.util
Class SocketAcceptor
- java.lang.Object
-
- gov.usgs.util.SocketAcceptor
-
- All Implemented Interfaces:
java.lang.Runnable
public class SocketAcceptor extends java.lang.Object implements java.lang.RunnableAccept socket connections from a ServerSocket, and notify a listener using a separate thread.
-
-
Constructor Summary
Constructors Constructor Description SocketAcceptor(java.net.ServerSocket listener, SocketListenerInterface callback)Create a new SocketAcceptor object that uses a single thread executor.SocketAcceptor(java.net.ServerSocket listener, SocketListenerInterface callback, java.util.concurrent.ExecutorService executor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidrun()Accept connections until the shutdown method is called.voidstart()Start accepting connections in a background thread.voidstop()Stop accepting connections.
-
-
-
Constructor Detail
-
SocketAcceptor
public SocketAcceptor(java.net.ServerSocket listener, SocketListenerInterface callback)Create a new SocketAcceptor object that uses a single thread executor.- Parameters:
listener- the server socket to accept connections from.callback- the object that processes accepted connections.
-
SocketAcceptor
public SocketAcceptor(java.net.ServerSocket listener, SocketListenerInterface callback, java.util.concurrent.ExecutorService executor)- Parameters:
listener- the server socket to accept connections from.callback- the object that processes accepted connections.executor- the executor used to invoke callback.
-
-