Class Context

java.lang.Object
org.glassfish.grizzly.Context
All Implemented Interfaces:
AttributeStorage, Cacheable

public class Context extends Object implements AttributeStorage, Cacheable
Object, which is responsible for holding context during I/O event processing.
Author:
Alexey Stashok
  • Field Details

    • ioEvent

      protected IOEvent ioEvent
      Processing IOEvent
    • lifeCycleListeners

      protected final Context.MinimalisticArrayList<IOEventLifeCycleListener> lifeCycleListeners
      IOEventProcessingHandler is called to notify about IOEvent processing life-cycle events like suspend, resume, complete.
    • wasSuspended

      protected boolean wasSuspended
      true if this IOEvent processing was suspended during its processing, or false otherwise.
    • isManualIOEventControl

      protected boolean isManualIOEventControl
  • Constructor Details

    • Context

      public Context()
  • Method Details

    • create

      public static Context create(Connection connection)
    • create

      public static Context create(Connection connection, Processor processor, IOEvent ioEvent, IOEventLifeCycleListener lifeCycleListener)
    • suspend

      public void suspend()
      Notify Context its processing will be suspended in the current thread.
    • resume

      public void resume()
      Notify Context its processing will be resumed in the current thread.
    • complete

      public void complete(ProcessorResult result)
    • wasSuspended

      public boolean wasSuspended()
      Returns:
      true if this IOEvent processing was suspended during its processing, or false otherwise.
    • setManualIOEventControl

      public void setManualIOEventControl()
      Switches processing to the manual IOEvent control. Connection.enableIOEvent(org.glassfish.grizzly.IOEvent) or Connection.disableIOEvent(org.glassfish.grizzly.IOEvent) might be explicitly called.
    • isManualIOEventControl

      public boolean isManualIOEventControl()
      Returns:
      true, if processing was switched to the manual IOEvent control, or false otherwise.
    • getIoEvent

      public IOEvent getIoEvent()
      Get the processing IOEvent.
      Returns:
      the processing IOEvent.
    • setIoEvent

      public void setIoEvent(IOEvent ioEvent)
      Set the processing IOEvent.
      Parameters:
      ioEvent - the processing IOEvent.
    • getConnection

      public Connection getConnection()
      Get the processing Connection.
      Returns:
      the processing Connection.
    • setConnection

      public void setConnection(Connection connection)
      Set the processing Connection.
      Parameters:
      connection - the processing Connection.
    • getProcessor

      public Processor getProcessor()
      Get the Processor, which is responsible to process the IOEvent.
      Returns:
      the Processor, which is responsible to process the IOEvent.
    • setProcessor

      public void setProcessor(Processor processor)
      Set the Processor, which is responsible to process the IOEvent.
      Parameters:
      processor - the Processor, which is responsible to process the IOEvent.
    • hasLifeCycleListener

      public boolean hasLifeCycleListener(IOEventLifeCycleListener listener)
    • addLifeCycleListener

      public void addLifeCycleListener(IOEventLifeCycleListener listener)
    • removeLifeCycleListener

      public boolean removeLifeCycleListener(IOEventLifeCycleListener listener)
    • removeAllLifeCycleListeners

      public void removeAllLifeCycleListeners()
    • getAttributes

      public AttributeHolder getAttributes()
      Get attributes (AttributeHolder), associated with the processing Context. AttributeHolder is cleared after each I/O event processing. Method may return null, if there were no attributes added before.
      Specified by:
      getAttributes in interface AttributeStorage
      Returns:
      attributes (AttributeHolder), associated with the processing Context.
    • reset

      public void reset()
      If implementation uses ObjectPool to store and reuse Context instances - this method will be called before Context will be offered to pool.
    • recycle

      public void recycle()
      Recycle this Context
      Specified by:
      recycle in interface Cacheable
    • release

      protected void release()
      Alternative to recycle() that allows cleanup actions to be performed without returning this instance to the cache. By default, this is a no-op.
      Since:
      2.3.29