Class ChannelApplicationLayer
- java.lang.Object
-
- org.jenkinsci.remoting.protocol.ApplicationLayer<Future<Channel>>
-
- org.jenkinsci.remoting.protocol.impl.ChannelApplicationLayer
-
- All Implemented Interfaces:
ProtocolLayer
,ProtocolLayer.Recv
public class ChannelApplicationLayer extends ApplicationLayer<Future<Channel>>
AnApplicationLayer
that produces aChannel
.- Since:
- 3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ChannelApplicationLayer.ChannelDecorator
Callback for decorating theChannelBuilder
before theChannel
is created.static interface
ChannelApplicationLayer.Listener
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
Constructors Constructor Description ChannelApplicationLayer(ExecutorService executorService, ChannelApplicationLayer.Listener listener)
Creates a newChannelApplicationLayer
ChannelApplicationLayer(ExecutorService executorService, ChannelApplicationLayer.Listener listener, String cookie)
Creates a newChannelApplicationLayer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChannelBuilder
decorate(ChannelBuilder builder)
Allows subclasses to decorate theChannelBuilder
Future<Channel>
get()
SPI: Returns the application specific API instance.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.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 Detail
-
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 Detail
-
get
public Future<Channel> 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
public void onRead(@NonNull ByteBuffer data) throws IOException
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
public void onReadClosed(IOException cause)
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
public ChannelBuilder decorate(ChannelBuilder builder)
Allows subclasses to decorate theChannelBuilder
- Parameters:
builder
- theChannelBuilder
to decorate- Returns:
- the provided
ChannelBuilder
for method chaining.
-
-