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 STATEcreateConnectionState(Socket socket, List<? extends JnlpConnectionStateListener> listeners) Creates theJnlpConnectionStateinstance for thisJnlpProtocolHandler.Gets theJnlpClientDatabase.abstract StringgetName()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.booleanWhether this protocol is enabled for connecting.booleanGets the preference for Non-Blocking I/O
-
Method Details
-
getClientDatabase
Gets theJnlpClientDatabase.- Returns:
- the
JnlpClientDatabaseornull.
-
isPreferNio
public boolean isPreferNio()Gets the preference for Non-Blocking I/O- Returns:
truemeans 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:
trueif this protocol is enabled.
-
createConnectionState
@NonNull protected abstract STATE createConnectionState(@NonNull Socket socket, @NonNull List<? extends JnlpConnectionStateListener> listeners) throws IOException Creates theJnlpConnectionStateinstance for thisJnlpProtocolHandler.- Parameters:
socket- theSocketlisteners- the initialJnlpConnectionStateListenerinstances.- Returns:
- the
JnlpConnectionStatefor 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
Futurefor theChannelto 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
Futurefor theChannelto 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
Futurefor theChannelto 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
Futurefor theChannelto the server. - Throws:
IOException- if the protocol cannot be initiated.
-