org.glassfish.grizzly
Class Context

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

public class Context
extends java.lang.Object
implements AttributeStorage, Cacheable

Object, which is responsible for holding context during I/O event processing.

Author:
Alexey Stashok

Field Summary
protected  IOEvent ioEvent
          Processing IOEvent
protected  boolean isManualIOEventControl
           
protected  IOEventProcessingHandler processingHandler
          IOEventProcessingHandler is called to notify about IOEvent processing life-cycle events like suspend, resume, complete.
protected  boolean wasSuspended
          true if this IOEvent processing was suspended during its processing, or false otherwise.
 
Constructor Summary
Context()
           
 
Method Summary
static Context create(Connection connection)
           
static Context create(Connection connection, Processor processor, IOEvent ioEvent, IOEventProcessingHandler processingHandler)
           
 AttributeHolder getAttributes()
          Get attributes (AttributeHolder), associated with the processing Context.
 Connection getConnection()
          Get the processing Connection.
 IOEvent getIoEvent()
          Get the processing IOEvent.
 IOEventProcessingHandler getProcessingHandler()
           
 Processor getProcessor()
          Get the Processor, which is responsible to process the IOEvent.
 boolean isManualIOEventControl()
           
 void recycle()
          Recycle this Context
 void reset()
          If implementation uses ObjectPool to store and reuse Context instances - this method will be called before Context will be offered to pool.
 void resume()
          Notify Context its processing will be resumed in the current thread.
 void setConnection(Connection connection)
          Set the processing Connection.
 void setIoEvent(IOEvent ioEvent)
          Set the processing IOEvent.
 void setManualIOEventControl()
          Switches processing to the manual IOEvent control.
 void setProcessingHandler(IOEventProcessingHandler processingHandler)
           
 void setProcessor(Processor processor)
          Set the Processor, which is responsible to process the IOEvent.
 void suspend()
          Notify Context its processing will be suspended in the current thread.
 boolean wasSuspended()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ioEvent

protected IOEvent ioEvent
Processing IOEvent


processingHandler

protected IOEventProcessingHandler processingHandler
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 Detail

Context

public Context()
Method Detail

create

public static Context create(Connection connection)

create

public static Context create(Connection connection,
                             Processor processor,
                             IOEvent ioEvent,
                             IOEventProcessingHandler processingHandler)

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.


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.

getProcessingHandler

public IOEventProcessingHandler getProcessingHandler()

setProcessingHandler

public void setProcessingHandler(IOEventProcessingHandler processingHandler)

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


Copyright © 2012 Oracle Corporation. All Rights Reserved.