@NotThreadSafe public class JnlpConnectionState extends Object
JnlpConnectionStateListener| Modifier and Type | Class and Description |
|---|---|
static interface |
JnlpConnectionState.ListenerState
Marker base class for all stashed state data.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
CLIENT_NAME_KEY
The property name for the client name key.
|
static String |
COOKIE_KEY
The property name for the cookie name key.
|
static String |
SECRET_KEY
The property name for the secret key.
|
| Constructor and Description |
|---|
JnlpConnectionState(Socket socket,
List<? extends JnlpConnectionStateListener> listeners)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
approve()
Signals that the current
JnlpConnectionStateListener is declaring ownership of this event, approving
the connection and all other JnlpConnectionStateListener instances will now be ignored. |
void |
fireAfterChannel(Channel channel)
Advances the connection state to indicate that the channel has been created.
|
void |
fireAfterDisconnect()
Advances the connection state to indicate that the socket has been closed.
|
void |
fireAfterProperties(Map<String,String> properties)
Advances the connection state to indicate that the property exchange has completed.
|
void |
fireBeforeChannel(ChannelBuilder builder)
Advances the connection state to indicate that the channel is about to be created.
|
void |
fireBeforeProperties()
Advances the connection state to indicate that a connection has been "secured" and the property exchange
is about to take place.
|
void |
fireChannelClosed(IOException cause)
Advances the connection state to indicate that the channel has been closed.
|
Channel |
getChannel()
Gets the connection's
Channel. |
ChannelBuilder |
getChannelBuilder()
Gets the
ChannelBuilder that will be used to create the connection's Channel. |
IOException |
getCloseCause()
Gets the reason for the channel being closed if available.
|
Map<String,String> |
getProperties()
Gets the connection properties.
|
String |
getProperty(String name)
Gets the named connection property.
|
String |
getRemoteEndpointDescription()
Description of the remote endpoint to which
getSocket() is connected, if using an actual socket and it is actually connected. |
Socket |
getSocket()
Gets the socket that the connection is on.
|
<S extends JnlpConnectionState.ListenerState> |
getStash(Class<S> clazz)
Retrieves the previously stashed state.
|
void |
ignore()
Signals that the current
JnlpConnectionStateListener is not interested in this event any more. |
void |
reject(ConnectionRefusalException reason)
Signals that the current
JnlpConnectionStateListener is declaring ownership of this event, rejecting
the connection and all other JnlpConnectionStateListener instances will now be ignored. |
void |
setRemoteEndpointDescription(String description)
Set a specific value for
getRemoteEndpointDescription(). |
<S extends JnlpConnectionState.ListenerState> |
setStash(S stash)
Stores some listener specific state for later retrieval.
|
public static final String SECRET_KEY
public static final String CLIENT_NAME_KEY
public static final String COOKIE_KEY
public JnlpConnectionState(@Nullable
Socket socket,
List<? extends JnlpConnectionStateListener> listeners)
socket - the Socket.listeners - the JnlpConnectionStateListener instances.@NonNull public Socket getSocket()
This should be considered deprecated except in situations where you know an actual socket is involved.
Use getRemoteEndpointDescription() for logging purposes.
@NonNull public String getRemoteEndpointDescription()
getSocket() is connected, if using an actual socket and it is actually connected.
Or may be some other text identifying a remote client.public void setRemoteEndpointDescription(@NonNull
String description)
getRemoteEndpointDescription().public Map<String,String> getProperties()
IllegalStateException - if invoked before
JnlpConnectionStateListener.afterProperties(JnlpConnectionState)public String getProperty(String name)
name - the property name.IllegalStateException - if invoked before
JnlpConnectionStateListener.afterProperties(JnlpConnectionState)public ChannelBuilder getChannelBuilder()
ChannelBuilder that will be used to create the connection's Channel.ChannelBuilderIllegalStateException - if invoked outside of
JnlpConnectionStateListener.beforeChannel(JnlpConnectionState)public Channel getChannel()
Channel.Channel (may be closed already), may be null in
JnlpConnectionStateListener.afterDisconnect(JnlpConnectionState) if the socket was closed by
the client.IllegalStateException - if invoked before
JnlpConnectionStateListener.afterChannel(JnlpConnectionState)@CheckForNull public IOException getCloseCause()
null if termination was normal.IllegalStateException - if invoked before
JnlpConnectionStateListener.channelClosed(JnlpConnectionState)public void ignore()
JnlpConnectionStateListener is not interested in this event any more. If all
JnlpConnectionStateListener implementations ignore the event then the connection will be
rejected.IllegalStateException - if invoked outside of
JnlpConnectionStateListener.beforeProperties(JnlpConnectionState) or
JnlpConnectionStateListener.afterProperties(JnlpConnectionState).public void approve()
JnlpConnectionStateListener is declaring ownership of this event, approving
the connection and all other JnlpConnectionStateListener instances will now be ignored.
This method must be called by at least one JnlpConnectionStateListener or the connection will be
rejected.IllegalStateException - if invoked outside of
JnlpConnectionStateListener.beforeProperties(JnlpConnectionState) or
JnlpConnectionStateListener.afterProperties(JnlpConnectionState).public void reject(ConnectionRefusalException reason)
JnlpConnectionStateListener is declaring ownership of this event, rejecting
the connection and all other JnlpConnectionStateListener instances will now be ignored.IllegalStateException - if invoked outside of
JnlpConnectionStateListener.beforeProperties(JnlpConnectionState) or
JnlpConnectionStateListener.afterProperties(JnlpConnectionState).@CheckForNull public <S extends JnlpConnectionState.ListenerState> S getStash(Class<S> clazz)
S - the expected class of the stashed state.clazz - the expected class of the stashed state.IllegalStateException - if invoked before approve()setStash(ListenerState)public <S extends JnlpConnectionState.ListenerState> void setStash(@CheckForNull S stash)
S - the expected class of the stashed state.stash - the state to stash.IllegalStateException - if invoked before approve()getStash(Class)public void fireBeforeProperties()
throws ConnectionRefusalException
ConnectionRefusalException - if the connection has been refused.public void fireAfterProperties(@NonNull
Map<String,String> properties)
throws ConnectionRefusalException
ConnectionRefusalException - if the connection has been refused.public void fireBeforeChannel(ChannelBuilder builder)
builder - the ChannelBuilder that will be used to create the channel.public void fireAfterChannel(Channel channel)
channel - the Channel (may be closed already but should not unless there is a serious race with
the remote).public void fireChannelClosed(@CheckForNull
IOException cause)
cause - the reason why the channel was closed or null if normally closedpublic void fireAfterDisconnect()
Copyright © 2004–2022. All rights reserved.