Class ChannelApplicationLayer
java.lang.Object
org.jenkinsci.remoting.protocol.ApplicationLayer<Future<Channel>>
org.jenkinsci.remoting.protocol.impl.ChannelApplicationLayer
- All Implemented Interfaces:
ProtocolLayer
,ProtocolLayer.Recv
An
ApplicationLayer
that produces a Channel
.- Since:
- 3.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Callback for decorating theChannelBuilder
before theChannel
is created.static interface
Callback interface for notification of theChannel
being created.Nested classes/interfaces inherited from interface org.jenkinsci.remoting.protocol.ProtocolLayer
ProtocolLayer.Recv, ProtocolLayer.Send
-
Field Summary
Fields inherited from interface org.jenkinsci.remoting.protocol.ProtocolLayer
EMPTY_BUFFER
-
Constructor Summary
ConstructorsConstructorDescriptionChannelApplicationLayer
(ExecutorService executorService, ChannelApplicationLayer.Listener listener) Creates a newChannelApplicationLayer
ChannelApplicationLayer
(ExecutorService executorService, ChannelApplicationLayer.Listener listener, String cookie) Creates a newChannelApplicationLayer
-
Method Summary
Modifier and TypeMethodDescriptiondecorate
(ChannelBuilder builder) Allows subclasses to decorate theChannelBuilder
get()
SPI: Returns the application specific API instance.boolean
SPI: Implementations ofApplicationLayer
must ensure this method either returnstrue
while the application specific API instance (ApplicationLayer.get()
) is accepting data viaApplicationLayer.onRead(ByteBuffer)
or returnsfalse
once it is permanently closed to incoming data.void
onRead
(ByteBuffer data) SPI: Callback on data being received from the protocol stack.void
onReadClosed
(IOException cause) Callback on the lower layer's source of data being closed.void
start()
Starts this layer.Methods inherited from class org.jenkinsci.remoting.protocol.ApplicationLayer
doCloseRead, doCloseWrite, init, isRecvOpen, isWriteOpen, onRecv, onRecvClosed, stack, write
-
Constructor Details
-
ChannelApplicationLayer
public ChannelApplicationLayer(@NonNull ExecutorService executorService, @CheckForNull ChannelApplicationLayer.Listener listener) Creates a newChannelApplicationLayer
- Parameters:
executorService
- theExecutorService
to use for theChannel
.listener
- theChannelApplicationLayer.Listener
to notify when theChannel
is available.
-
ChannelApplicationLayer
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public ChannelApplicationLayer(@NonNull ExecutorService executorService, @CheckForNull ChannelApplicationLayer.Listener listener, String cookie) Creates a newChannelApplicationLayer
- Parameters:
executorService
- theExecutorService
to use for theChannel
.listener
- theChannelApplicationLayer.Listener
to notify when theChannel
is available.cookie
- a cookie to pass through the channel.
-
-
Method Details
-
get
SPI: Returns the application specific API instance.- Specified by:
get
in classApplicationLayer<Future<Channel>>
- Returns:
- the application specific API instance.
-
isReadOpen
public boolean isReadOpen()SPI: Implementations ofApplicationLayer
must ensure this method either returnstrue
while the application specific API instance (ApplicationLayer.get()
) is accepting data viaApplicationLayer.onRead(ByteBuffer)
or returnsfalse
once it is permanently closed to incoming data. If the application specific API instance is temporarily not accepting data then this method should returntrue
and the implementation is responsible for caching the data submitted in calls toApplicationLayer.onRead(ByteBuffer)
Once this method returnsfalse
it must always returnfalse
and can be assumed to behave in this way.- Specified by:
isReadOpen
in classApplicationLayer<Future<Channel>>
- Returns:
true
if the application specific API instance (ApplicationLayer.get()
is accepting data viaApplicationLayer.onRead(ByteBuffer)
-
onRead
SPI: Callback on data being received from the protocol stack.- Specified by:
onRead
in classApplicationLayer<Future<Channel>>
- Parameters:
data
- the data received. Any data consumed from theByteBuffer
can be assumed as processed. Any data not consumed from theByteBuffer
will be the responsibility of the caller to resubmit in subsequent calls.- Throws:
IOException
- if there was an error during processing of the received data.
-
onReadClosed
Callback on the lower layer's source of data being closed.- Specified by:
onReadClosed
in classApplicationLayer<Future<Channel>>
- Parameters:
cause
- the cause of the lower layer being closed ornull
.
-
start
public void start()Starts this layer. All layers in the stack will be initialized before a call to this method. All lower layers in the stack will have been started before this layer is started. -
decorate
Allows subclasses to decorate theChannelBuilder
- Parameters:
builder
- theChannelBuilder
to decorate- Returns:
- the provided
ChannelBuilder
for method chaining.
-