@Contract(threading=SAFE_CONDITIONAL) public class ListenerEndpointImpl extends java.lang.Object implements ListenerEndpoint
ListenerEndpoint
.Modifier and Type | Field and Description |
---|---|
private java.net.SocketAddress |
address |
private ListenerEndpointClosedCallback |
callback |
private boolean |
closed |
private boolean |
completed |
private java.io.IOException |
exception |
private java.nio.channels.SelectionKey |
key |
Constructor and Description |
---|
ListenerEndpointImpl(java.net.SocketAddress address,
ListenerEndpointClosedCallback callback) |
Modifier and Type | Method and Description |
---|---|
void |
cancel() |
void |
close()
Closes this endpoint.
|
void |
completed(java.net.SocketAddress address) |
void |
failed(java.io.IOException exception) |
java.net.SocketAddress |
getAddress()
Returns the socket address of this endpoint.
|
java.io.IOException |
getException()
Returns an instance of
IOException thrown during initialization
of this endpoint or null , if initialization was successful. |
boolean |
isClosed()
Determines if this endpoint has been closed and is no longer listens
for incoming connections.
|
boolean |
isCompleted() |
protected void |
setKey(java.nio.channels.SelectionKey key) |
java.lang.String |
toString() |
void |
waitFor()
Waits for completion of initialization process of this endpoint.
|
private volatile boolean completed
private volatile boolean closed
private volatile java.nio.channels.SelectionKey key
private volatile java.net.SocketAddress address
private volatile java.io.IOException exception
private final ListenerEndpointClosedCallback callback
public ListenerEndpointImpl(java.net.SocketAddress address, ListenerEndpointClosedCallback callback)
public java.net.SocketAddress getAddress()
ListenerEndpoint
getAddress
in interface ListenerEndpoint
public boolean isCompleted()
public java.io.IOException getException()
ListenerEndpoint
IOException
thrown during initialization
of this endpoint or null
, if initialization was successful.getException
in interface ListenerEndpoint
null
.public void waitFor() throws java.lang.InterruptedException
ListenerEndpoint
waitFor
in interface ListenerEndpoint
java.lang.InterruptedException
- in case the initialization process was
interrupted.public void completed(java.net.SocketAddress address)
public void failed(java.io.IOException exception)
public void cancel()
protected void setKey(java.nio.channels.SelectionKey key)
public boolean isClosed()
ListenerEndpoint
isClosed
in interface ListenerEndpoint
true
if the endpoint has been closed,
false
otherwise.public void close()
ListenerEndpoint
close
in interface ListenerEndpoint
public java.lang.String toString()
toString
in class java.lang.Object