public abstract class AbstractHandler extends Object implements IHandler
IHandler interface.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractHandler()
Default constructor creating an unnamed handler.
|
protected |
AbstractHandler(ISessionConfig config)
Default constructor creating an unnamed handler with given session
configuration object.
|
protected |
AbstractHandler(String name)
Constructor creating a named handler.
|
protected |
AbstractHandler(String name,
ISessionConfig config)
Constructor creating a named handler with given session configuration object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
event(DataEvent event,
long length)
Called to notify about an I/O operation.
|
void |
event(SessionEvent event)
Called to notify about a change of the associated session state.
|
void |
exception(Throwable t)
Called to notify about an exception caught during processing of I/O or
protocol related operations.
|
ISessionConfig |
getConfig()
Returns the configuration object that will be used to configure the
behavior of the associated session.
|
ISessionStructureFactory |
getFactory()
Returns the factory object that will be used to configure the internal
structure of the associated session.
|
String |
getName()
Returns the name of the handler.
|
ISession |
getSession()
Returns the session that is associated with this handler.
|
boolean |
incident(SessionIncident incident,
Throwable t)
Called to notify about an incident that occurred during processing of I/O
or protocol related operations.
|
void |
read(byte[] data)
Called when new bytes were read from the input buffer.
|
void |
read(ByteBuffer data)
Called when new bytes were read from the input buffer.
|
void |
setSession(ISession session)
Sets the session that will be associated with this handler.
|
void |
timer(Object event)
Called to notify about an expiration of the timer identified by the
specified event object.
|
void |
timer(Runnable task)
Called to notify about an expiration of the timer associated with the
specified task.
|
protected AbstractHandler()
protected AbstractHandler(ISessionConfig config)
config - the session configuration object, or null to
use the default configurationprotected AbstractHandler(String name)
name - the name for this handlerprotected AbstractHandler(String name, ISessionConfig config)
name - the name for this handlerconfig - the session configuration object, or null to
use the default configurationpublic void setSession(ISession session)
IHandlersetSession in interface IHandlersession - the sessionpublic ISession getSession()
IHandlergetSession in interface IHandlerpublic String getName()
IHandlerpublic void event(SessionEvent event)
IHandlerevent in interface IHandlerevent - an event related with the change of the session stateSessionEventpublic void event(DataEvent event, long length)
IHandlerpublic void exception(Throwable t)
IHandlerpublic boolean incident(SessionIncident incident, Throwable t)
IHandlerpublic void timer(Object event)
IHandlerpublic void timer(Runnable task)
IHandlerpublic ISessionStructureFactory getFactory()
IHandlergetFactory in interface IHandlerISessionStructureFactorypublic ISessionConfig getConfig()
IHandlergetConfig in interface IHandlerISessionConfigpublic void read(byte[] data)
read methods are
met.
The passed array can be safely stored or modified by this method as it will not be used by the caller.
By default it simply passes the data value to the
IHandler.read(Object) method.
public void read(ByteBuffer data)
ByteBuffer objects or when the associated
session is configured to optimize data copying and uses an allocator
supporting the releasing of no longer used buffers
The passed byte buffer can be safely stored or modified by this method as it will not be used by the caller. However, if the associated session is configured to optimize data copying and uses an allocator supporting the releasing of no longer used buffers it may be required to release it in this method unless the original buffer has been already released by one of the associated decoders.
By default it simply passes the data value to the
IHandler.read(Object) method.
Copyright © 2017–2022 SNF4J.ORG. All rights reserved.