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 interfaceCallback for decorating theChannelBuilderbefore theChannelis created.static interfaceCallback interface for notification of theChannelbeing 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 newChannelApplicationLayerChannelApplicationLayer(ExecutorService executorService, ChannelApplicationLayer.Listener listener, String cookie) Creates a newChannelApplicationLayer -
Method Summary
Modifier and TypeMethodDescriptiondecorate(ChannelBuilder builder) Allows subclasses to decorate theChannelBuilderget()SPI: Returns the application specific API instance.booleanSPI: Implementations ofApplicationLayermust ensure this method either returnstruewhile the application specific API instance (ApplicationLayer.get()) is accepting data viaApplicationLayer.onRead(ByteBuffer)or returnsfalseonce it is permanently closed to incoming data.voidonRead(ByteBuffer data) SPI: Callback on data being received from the protocol stack.voidonReadClosed(IOException cause) Callback on the lower layer's source of data being closed.voidstart()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- theExecutorServiceto use for theChannel.listener- theChannelApplicationLayer.Listenerto notify when theChannelis 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- theExecutorServiceto use for theChannel.listener- theChannelApplicationLayer.Listenerto notify when theChannelis available.cookie- a cookie to pass through the channel.
-
-
Method Details
-
get
SPI: Returns the application specific API instance.- Specified by:
getin classApplicationLayer<Future<Channel>>- Returns:
- the application specific API instance.
-
isReadOpen
public boolean isReadOpen()SPI: Implementations ofApplicationLayermust ensure this method either returnstruewhile the application specific API instance (ApplicationLayer.get()) is accepting data viaApplicationLayer.onRead(ByteBuffer)or returnsfalseonce it is permanently closed to incoming data. If the application specific API instance is temporarily not accepting data then this method should returntrueand the implementation is responsible for caching the data submitted in calls toApplicationLayer.onRead(ByteBuffer)Once this method returnsfalseit must always returnfalseand can be assumed to behave in this way.- Specified by:
isReadOpenin classApplicationLayer<Future<Channel>>- Returns:
trueif 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:
onReadin classApplicationLayer<Future<Channel>>- Parameters:
data- the data received. Any data consumed from theByteBuffercan be assumed as processed. Any data not consumed from theByteBufferwill 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:
onReadClosedin 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- theChannelBuilderto decorate- Returns:
- the provided
ChannelBuilderfor method chaining.
-