public abstract class SocketConnectionBase<Request extends AbstractRequest,Response extends AbstractResponse> extends java.lang.Object implements SocketConnection<Request,Response>
Disposable.Parent
Constructor and Description |
---|
SocketConnectionBase(RequestResponseExternalizerFactory<Request,Response> factory) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(SocketConnectionListener listener,
Disposable parentDisposable) |
protected void |
addThreadToInterrupt() |
protected void |
attachToSocket(java.net.Socket socket) |
void |
close() |
void |
dispose()
Usually not invoked directly, see class javadoc.
|
int |
getPort() |
ConnectionState |
getState() |
boolean |
isStopping() |
protected void |
onClosing() |
protected void |
processRequests(RequestWriter<Request> writer) |
<R extends Response> |
registerHandler(java.lang.Class<R> responseClass,
AbstractResponseHandler<R> handler) |
protected void |
removeThreadToInterrupt() |
void |
sendRequest(Request request) |
void |
sendRequest(Request request,
AbstractResponseToRequestHandler<? extends Response> handler) |
void |
sendRequest(Request request,
AbstractResponseToRequestHandler<? extends Response> handler,
int timeout,
java.lang.Runnable onTimeout) |
protected void |
setPort(int port) |
protected void |
setStatus(ConnectionStatus status,
java.lang.String message) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
open
public SocketConnectionBase(RequestResponseExternalizerFactory<Request,Response> factory)
public void sendRequest(Request request)
sendRequest
in interface SocketConnection<Request extends AbstractRequest,Response extends AbstractResponse>
public void sendRequest(Request request, AbstractResponseToRequestHandler<? extends Response> handler)
sendRequest
in interface SocketConnection<Request extends AbstractRequest,Response extends AbstractResponse>
public void sendRequest(Request request, AbstractResponseToRequestHandler<? extends Response> handler, int timeout, java.lang.Runnable onTimeout)
sendRequest
in interface SocketConnection<Request extends AbstractRequest,Response extends AbstractResponse>
public <R extends Response> void registerHandler(java.lang.Class<R> responseClass, AbstractResponseHandler<R> handler)
registerHandler
in interface SocketConnection<Request extends AbstractRequest,Response extends AbstractResponse>
public boolean isStopping()
isStopping
in interface SocketConnection<Request extends AbstractRequest,Response extends AbstractResponse>
protected void processRequests(RequestWriter<Request> writer) throws java.io.IOException
java.io.IOException
protected void addThreadToInterrupt()
protected void removeThreadToInterrupt()
public void dispose()
Disposable
dispose
in interface Disposable
public int getPort()
getPort
in interface SocketConnection<Request extends AbstractRequest,Response extends AbstractResponse>
protected void setStatus(ConnectionStatus status, java.lang.String message)
public ConnectionState getState()
getState
in interface SocketConnection<Request extends AbstractRequest,Response extends AbstractResponse>
public void addListener(SocketConnectionListener listener, Disposable parentDisposable)
addListener
in interface SocketConnection<Request extends AbstractRequest,Response extends AbstractResponse>
public void close()
close
in interface SocketConnection<Request extends AbstractRequest,Response extends AbstractResponse>
protected void onClosing()
protected void attachToSocket(java.net.Socket socket) throws java.io.IOException
java.io.IOException
protected void setPort(int port)