Package org.glassfish.grizzly
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classContext.MinimalisticArrayList<E>
-
Field Summary
Fields Modifier and Type Field Description protected IOEventioEventProcessing IOEventprotected booleanisManualIOEventControlprotected Context.MinimalisticArrayList<IOEventLifeCycleListener>lifeCycleListenersIOEventProcessingHandler is called to notify about IOEvent processing life-cycle events like suspend, resume, complete.protected booleanwasSuspendedtrue if this IOEvent processing was suspended during its processing, or false otherwise.
-
Constructor Summary
Constructors Constructor Description Context()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLifeCycleListener(IOEventLifeCycleListener listener)voidcomplete(ProcessorResult result)static Contextcreate(Connection connection)static Contextcreate(Connection connection, Processor processor, IOEvent ioEvent, IOEventLifeCycleListener lifeCycleListener)AttributeHoldergetAttributes()Get attributes (AttributeHolder), associated with the processingContext.ConnectiongetConnection()Get the processingConnection.IOEventgetIoEvent()Get the processingIOEvent.ProcessorgetProcessor()booleanhasLifeCycleListener(IOEventLifeCycleListener listener)booleanisManualIOEventControl()voidrecycle()Recycle thisContextprotected voidrelease()Alternative torecycle()that allows cleanup actions to be performed without returning this instance to the cache.voidremoveAllLifeCycleListeners()booleanremoveLifeCycleListener(IOEventLifeCycleListener listener)voidreset()If implementation usesObjectPoolto store and reuseContextinstances - this method will be called beforeContextwill be offered to pool.voidresume()Notify Context its processing will be resumed in the current thread.voidsetConnection(Connection connection)Set the processingConnection.voidsetIoEvent(IOEvent ioEvent)Set the processingIOEvent.voidsetManualIOEventControl()Switches processing to the manual IOEvent control.voidsetProcessor(Processor processor)voidsuspend()Notify Context its processing will be suspended in the current thread.booleanwasSuspended()
-
-
-
Field Detail
-
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
-
-
Method Detail
-
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)orConnection.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.
-
setIoEvent
public void setIoEvent(IOEvent ioEvent)
Set the processingIOEvent.- Parameters:
ioEvent- the processingIOEvent.
-
getConnection
public Connection getConnection()
Get the processingConnection.- Returns:
- the processing
Connection.
-
setConnection
public void setConnection(Connection connection)
Set the processingConnection.- Parameters:
connection- the processingConnection.
-
getProcessor
public Processor getProcessor()
-
setProcessor
public void setProcessor(Processor processor)
-
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 processingContext.AttributeHolderis cleared after each I/O event processing. Method may return null, if there were no attributes added before.- Specified by:
getAttributesin interfaceAttributeStorage- Returns:
- attributes (
AttributeHolder), associated with the processingContext.
-
reset
public void reset()
If implementation usesObjectPoolto store and reuseContextinstances - this method will be called beforeContextwill be offered to pool.
-
release
protected void release()
Alternative torecycle()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
-
-