Package org.jenkinsci.remoting.engine
Class JnlpProtocolHandler<STATE extends JnlpConnectionState>
- java.lang.Object
-
- org.jenkinsci.remoting.engine.JnlpProtocolHandler<STATE>
-
- Type Parameters:
STATE
- State class for connection events
- Direct Known Subclasses:
JnlpProtocol4Handler
,JnlpProtocol4ProxyHandler
public abstract class JnlpProtocolHandler<STATE extends JnlpConnectionState> extends Object
Consolidates the protocol handling for both the server and the client ends of the connection.- Since:
- 3.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Future<Channel>
connect(Socket socket, Map<String,String> headers, List<? extends JnlpConnectionStateListener> listeners)
Handles an outgoing connection to the server on the supplied socket.Future<Channel>
connect(Socket socket, Map<String,String> headers, JnlpConnectionStateListener... listeners)
Handles an outgoing connection to the server on the supplied socket.protected abstract STATE
createConnectionState(Socket socket, List<? extends JnlpConnectionStateListener> listeners)
Creates theJnlpConnectionState
instance for thisJnlpProtocolHandler
.JnlpClientDatabase
getClientDatabase()
Gets theJnlpClientDatabase
.abstract String
getName()
Get the name of the protocol.abstract Future<Channel>
handle(Socket socket, Map<String,String> headers, List<? extends JnlpConnectionStateListener> listeners)
Handles an incoming client connection on the supplied socket.Future<Channel>
handle(Socket socket, Map<String,String> headers, JnlpConnectionStateListener... listeners)
Handles an incoming client connection on the supplied socket.boolean
isEnabled()
Whether this protocol is enabled for connecting.boolean
isPreferNio()
Gets the preference for Non-Blocking I/O
-
-
-
Method Detail
-
getClientDatabase
@CheckForNull public JnlpClientDatabase getClientDatabase()
Gets theJnlpClientDatabase
.- Returns:
- the
JnlpClientDatabase
ornull
.
-
isPreferNio
public boolean isPreferNio()
Gets the preference for Non-Blocking I/O- Returns:
true
means that the protocol should attempt to use NIO if possible.
-
getName
public abstract String getName()
Get the name of the protocol.
-
isEnabled
public boolean isEnabled()
Whether this protocol is enabled for connecting.- Returns:
true
if this protocol is enabled.
-
createConnectionState
@NonNull protected abstract STATE createConnectionState(@NonNull Socket socket, @NonNull List<? extends JnlpConnectionStateListener> listeners) throws IOException
Creates theJnlpConnectionState
instance for thisJnlpProtocolHandler
.- Parameters:
socket
- theSocket
listeners
- the initialJnlpConnectionStateListener
instances.- Returns:
- the
JnlpConnectionState
for this connection. - Throws:
IOException
- if something goes wrong.
-
handle
@NonNull public final Future<Channel> handle(@NonNull Socket socket, @NonNull Map<String,String> headers, @NonNull JnlpConnectionStateListener... listeners) throws IOException
Handles an incoming client connection on the supplied socket.- Parameters:
socket
- the socket.headers
- the headers to send.listeners
- the listeners to approve and receive the connection.- Returns:
- a
Future
for theChannel
to the server. - Throws:
IOException
- if the protocol cannot be initiated.
-
handle
@NonNull public abstract Future<Channel> handle(@NonNull Socket socket, @NonNull Map<String,String> headers, @NonNull List<? extends JnlpConnectionStateListener> listeners) throws IOException
Handles an incoming client connection on the supplied socket.- Parameters:
socket
- the socket.headers
- the headers to send.listeners
- the listeners to approve and receive the connection.- Returns:
- a
Future
for theChannel
to the server. - Throws:
IOException
- if the protocol cannot be initiated.
-
connect
@NonNull public final Future<Channel> connect(@NonNull Socket socket, @NonNull Map<String,String> headers, @NonNull JnlpConnectionStateListener... listeners) throws IOException
Handles an outgoing connection to the server on the supplied socket.- Parameters:
socket
- the socket.headers
- the headers to send.listeners
- the listeners to approve and receive the connection.- Returns:
- a
Future
for theChannel
to the server. - Throws:
IOException
- if the protocol cannot be initiated.
-
connect
@NonNull public abstract Future<Channel> connect(@NonNull Socket socket, @NonNull Map<String,String> headers, @NonNull List<? extends JnlpConnectionStateListener> listeners) throws IOException
Handles an outgoing connection to the server on the supplied socket.- Parameters:
socket
- the socket.headers
- the headers to send.listeners
- the listeners to approve and receive the connection.- Returns:
- a
Future
for theChannel
to the server. - Throws:
IOException
- if the protocol cannot be initiated.
-
-