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 objectprotected AbstractHandler(String name)
name
- the name for this handlerprotected AbstractHandler(String name, ISessionConfig config)
name
- the name for this handlerconfig
- the session configuration objectpublic void setSession(ISession session)
IHandler
setSession
in interface IHandler
session
- the sessionpublic ISession getSession()
IHandler
getSession
in interface IHandler
public String getName()
IHandler
public void event(SessionEvent event)
IHandler
event
in interface IHandler
event
- an event related with the change of the session stateSessionEvent
public void event(DataEvent event, long length)
IHandler
public void exception(Throwable t)
IHandler
public boolean incident(SessionIncident incident, Throwable t)
IHandler
public void timer(Object event)
IHandler
public void timer(Runnable task)
IHandler
public ISessionStructureFactory getFactory()
IHandler
getFactory
in interface IHandler
ISessionStructureFactory
public ISessionConfig getConfig()
IHandler
getConfig
in interface IHandler
ISessionConfig
public 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–2021 SNF4J.ORG. All rights reserved.