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
Consolidates the protocol handling for both the server and the client ends of the connection.
- Since:
- 3.0
-
Method Summary
Modifier and TypeMethodDescriptionconnect
(Socket socket, Map<String, String> headers, List<? extends JnlpConnectionStateListener> listeners) Handles an outgoing connection to the server on the supplied socket.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
.Gets theJnlpClientDatabase
.abstract String
getName()
Get the name of the protocol.handle
(Socket socket, Map<String, String> headers, List<? extends JnlpConnectionStateListener> listeners) Handles an incoming client connection on the supplied socket.Handles an incoming client connection on the supplied socket.boolean
Whether this protocol is enabled for connecting.boolean
Gets the preference for Non-Blocking I/O
-
Method Details
-
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
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 IOExceptionHandles 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 IOExceptionHandles 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 IOExceptionHandles 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 IOExceptionHandles 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.
-