Class ProtocolStack<T>

java.lang.Object
org.jenkinsci.remoting.protocol.ProtocolStack<T>
Type Parameters:
T - the application specific API.
All Implemented Interfaces:
Closeable, AutoCloseable, ByteBufferPool

public class ProtocolStack<T> extends Object implements Closeable, ByteBufferPool
A stack of ProtocolLayer that make a network protocol. The stack will start with a NetworkLayer instance, optionally followed by a series of FilterLayer instances and terminated by a ApplicationLayer instance. Instances are created using the on(NetworkLayer) entry point, for example ProtocolStack.on(netLayer).filter(filterLayer1).filter(filterLayer2).filter(filterLayer3).build(appLayer) For this stack, the layers will be initialized and started in the following sequence:
  1. NetworkLayer.init(ProtocolStack.Ptr) (netLayer)
  2. FilterLayer.init(ProtocolStack.Ptr) (filterLayer1)
  3. FilterLayer.init(ProtocolStack.Ptr) (filterLayer2)
  4. FilterLayer.init(ProtocolStack.Ptr) (filterLayer3)
  5. ApplicationLayer.init(ProtocolStack.Ptr) (appLayer)
  6. NetworkLayer.start() (netLayer)
  7. FilterLayer.start() (filterLayer1)
  8. FilterLayer.start() (filterLayer2)
  9. FilterLayer.start() (filterLayer3)
  10. ProtocolLayer.start() (appLayer)
If this stack is closed via the network layer - a network initiated close - then the close will be propagated in the following sequence:
  1. NetworkLayer (netLayer) detects close
  2. FilterLayer.onRecvClosed(IOException) (filterLayer1)
  3. FilterLayer.onRecvClosed(IOException) (filterLayer2)
  4. FilterLayer.onRecvClosed(IOException) (filterLayer3)
  5. FilterLayer.onRecvClosed(IOException) (appLayer)
  6. FilterLayer.doCloseSend() (filterLayer3)
  7. FilterLayer.doCloseSend() (filterLayer2)
  8. FilterLayer.doCloseSend() (filterLayer1)
  9. ProtocolLayer.Send.doCloseSend() (netLayer)
If this stack is closed via a protocol layer - a mid-stack initiated close - then the close will be propagated in the following sequence:
  1. FilterLayer (filterLayer2) initiates close
  2. FilterLayer.onRecvClosed(IOException) (filterLayer3)
  3. FilterLayer.onRecvClosed(IOException) (appLayer)
  4. FilterLayer.doCloseSend() (filterLayer3)
  5. FilterLayer.doCloseSend() (filterLayer2)
  6. FilterLayer.doCloseSend() (filterLayer1)
  7. ProtocolLayer.Send.doCloseSend() (netLayer)
  8. FilterLayer.onRecvClosed(IOException) (filterLayer1)
Since:
3.0