|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.grizzly.AbstractTransport
public abstract class AbstractTransport
Abstract Transport.
Implements common transport functionality.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.sun.grizzly.Transport |
|---|
Transport.State |
| Nested classes/interfaces inherited from interface com.sun.grizzly.utils.ExceptionHandler |
|---|
ExceptionHandler.Severity |
| Field Summary | |
|---|---|
protected AttributeBuilder |
attributeBuilder
Transport AttributeBuilder, which will be used to create Attributes |
protected LinkedTransferQueue<ExceptionHandler> |
exceptionHandlers
Transport ExceptionHandler list |
protected ExecutorService |
internalThreadPool
Transport internal thread pool |
protected boolean |
isBlocking
Transport mode |
protected MemoryManager |
memoryManager
Transport MemoryManager |
protected String |
name
Transport name |
protected Processor |
processor
Transport default Processor |
protected ProcessorSelector |
processorSelector
Transport default ProcessorSelector |
protected int |
readBufferSize
Transport default buffer size for read operations |
protected StateHolder<Transport.State> |
state
Transport state controller |
protected Strategy |
strategy
Transport Strategy |
protected ExecutorService |
workerThreadPool
Transport worker thread pool |
protected int |
writeBufferSize
Transport default buffer size for write operations |
| Constructor Summary | |
|---|---|
AbstractTransport(String name)
|
|
| Method Summary | |
|---|---|
void |
addExceptionHandler(ExceptionHandler handler)
Add ExceptionHandler to handle errors, occurred during the
Transport execution. |
protected abstract void |
closeConnection(Connection connection)
Close the connection, managed by Transport |
void |
configureBlocking(boolean isBlocking)
Sets the Transport mode. |
void |
fireIOEvent(IOEvent ioEvent,
Connection connection)
Fires specific IOEvent on the Connection |
AttributeBuilder |
getAttributeBuilder()
Get Transport associated AttributeBuilder, which will
be used by Transport and its Connections to store custom
Attributes. |
ExecutorService |
getInternalThreadPool()
Get a thread pool, which will process transport internal tasks like NIO Selector polling etc. |
MemoryManager |
getMemoryManager()
Get the Transport associated MemoryManager, which will
be used by the Transport, its Connections and by during
processing I/O events, occurred on Connections. |
String |
getName()
Gets the Transport name. |
Processor |
getProcessor()
Gets the default Processor, which will process Connection
I/O events in case, if Connection doesn't have own
Processor preferences. |
ProcessorSelector |
getProcessorSelector()
Gets the default ProcessorSelector, which will be used to get
Processor to process Connection I/O events, in case if
this Transport's Processor is null and
Connection doesn't have neither preferred Processor
nor ProcessorSelector. |
int |
getReadBufferSize()
Get the default size of Buffers, which will be allocated for
reading data from Transport's Connections. |
StateHolder<Transport.State> |
getState()
Return the Transport state controller. |
Strategy |
getStrategy()
Get the Strategy implementation, which will be used by
Transport to process IOEvent. |
ExecutorService |
getWorkerThreadPool()
Get a worker thread pool, which could be chosen to process occurred I/O operations. |
int |
getWriteBufferSize()
Get the default size of Buffers, which will be allocated for
writing data to Transport's Connections. |
boolean |
isBlocking()
Returns the Transport mode. |
boolean |
isStopped()
Returns true, if this Transport is in stopped state, false otherwise. |
void |
notifyException(ExceptionHandler.Severity severity,
Throwable throwable)
Notify about error, occurred during Transport execution. |
abstract void |
pause()
Pauses the transport |
void |
removeExceptionHandler(ExceptionHandler handler)
Remove ExceptionHandler from the list of Transport
ExceptionHandlers. |
abstract void |
resume()
Resumes the transport after a pause |
void |
setAttributeBuilder(AttributeBuilder attributeBuilder)
Set Transport associated AttributeBuilder, which will
be used by Transport and its Connections to store custom
Attributes. |
void |
setInternalThreadPool(ExecutorService internalThreadPool)
Set a thread pool, which will process transport internal tasks like NIO Selector polling etc. |
void |
setMemoryManager(MemoryManager memoryManager)
Set the Transport associated MemoryManager, which will
be used by the Transport, its Connections and by during
processing I/O events, occurred on Connections. |
void |
setName(String name)
Sets the Transport name. |
void |
setProcessor(Processor processor)
Sets the default Processor, which will process Connection
I/O events in case, if Connection doesn't have own
Processor preferences. |
void |
setProcessorSelector(ProcessorSelector selector)
Sets the default ProcessorSelector, which will be used to get
Processor to process Connection I/O events, in case if
this Transport's Processor is null and
Connection doesn't have neither preferred Processor
nor ProcessorSelector. |
void |
setReadBufferSize(int readBufferSize)
Set the default size of Buffers, which will be allocated for
reading data from Transport's Connections. |
void |
setStrategy(Strategy strategy)
Set the Strategy implementation, which will be used by
Transport to process IOEvent. |
void |
setWorkerThreadPool(ExecutorService workerThreadPool)
Set a worker thread pool, which could be chosen to process occurred I/O operations. |
void |
setWriteBufferSize(int writeBufferSize)
Set the default size of Buffers, which will be allocated for
writing data to Transport's Connections. |
abstract void |
start()
Starts the transport |
abstract void |
stop()
Stops the transport and closes all the connections |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.sun.grizzly.Transport |
|---|
fireIOEvent |
| Field Detail |
|---|
protected String name
protected boolean isBlocking
protected StateHolder<Transport.State> state
protected Processor processor
protected ProcessorSelector processorSelector
protected Strategy strategy
protected MemoryManager memoryManager
protected ExecutorService workerThreadPool
protected ExecutorService internalThreadPool
protected AttributeBuilder attributeBuilder
protected int readBufferSize
protected int writeBufferSize
protected LinkedTransferQueue<ExceptionHandler> exceptionHandlers
| Constructor Detail |
|---|
public AbstractTransport(String name)
| Method Detail |
|---|
public String getName()
Transport name.
getName in interface TransportTransport name.public void setName(String name)
Transport name.
setName in interface Transportname - the Transport name.public boolean isBlocking()
Transport mode.
true, if Transport is operating in blocking mode, or
false otherwise.
Specific Transport Connections may override this setting
by Connection.isBlocking().
isBlocking in interface TransportTransport mode.
true, if Transport is operating in blocking mode, or
false otherwise.public void configureBlocking(boolean isBlocking)
Transport mode.
Specific Transport Connections may override this setting
by Connection.configureBlocking(boolean).
configureBlocking in interface TransportisBlocking - the Transport mode. true,
if Transport should operate in blocking mode, or
false otherwise.public StateHolder<Transport.State> getState()
Transport state controller. Using the state controller,
it is possible to get/set the Transport state in thread-safe manner.
getState in interface TransportStateHolder state controller.public int getReadBufferSize()
Buffers, which will be allocated for
reading data from Transport's Connections.
For particullar Connection, this setting could be overriden by
Connection.getReadBufferSize().
getReadBufferSize in interface TransportBuffers, which will be allocated for
reading data from Transport's Connections.public void setReadBufferSize(int readBufferSize)
Buffers, which will be allocated for
reading data from Transport's Connections.
For particullar Connection, this setting could be overriden by
Connection.setReadBufferSize(int).
setReadBufferSize in interface TransportreadBufferSize - the default size of Buffers, which will
be allocated for reading data from Transport's
Connections.public int getWriteBufferSize()
Buffers, which will be allocated for
writing data to Transport's Connections.
For particullar Connection, this setting could be overriden by
Connection.getWriteBufferSize().
getWriteBufferSize in interface TransportBuffers, which will be allocated for
writing data to Transport's Connections.public void setWriteBufferSize(int writeBufferSize)
Buffers, which will be allocated for
writing data to Transport's Connections.
For particullar Connection, this setting could be overriden by
Connection.setWriteBufferSize(int).
setWriteBufferSize in interface TransportwriteBufferSize - the default size of Buffers, which will
be allocated for writing data to Transport's
Connections.public boolean isStopped()
isStopped in interface Transportpublic Processor getProcessor()
Processor, which will process Connection
I/O events in case, if Connection doesn't have own
Processor preferences.
If Transport associated Processor is null,
and Connection doesn't have any preferred Processor -
then Transport will try to get Processor using
ProcessorSelector.select(IOEvent, Connection).
getProcessor in interface TransportProcessor, which will process
Connection I/O events, if one doesn't have
own Processor preferences.public void setProcessor(Processor processor)
Processor, which will process Connection
I/O events in case, if Connection doesn't have own
Processor preferences.
If Transport associated Processor is null,
and Connection doesn't have any preferred Processor -
then Transport will try to get Processor using
ProcessorSelector.select(IOEvent, Connection).
setProcessor in interface Transportprocessor - the default Processor, which will process
Connection I/O events, if one doesn't have own
Processor preferences.public ProcessorSelector getProcessorSelector()
ProcessorSelector, which will be used to get
Processor to process Connection I/O events, in case if
this Transport's Processor is null and
Connection doesn't have neither preferred Processor
nor ProcessorSelector.
Transport's ProcessorSelector is the last place, where
Transport will try to get Processor to process
Connection I/O event. If ProcessorSelector is not set -
IllegalStateException will be thrown.
getProcessorSelector in interface TransportProcessorSelector, which will be used to get
Processor to process Connection I/O events, in case if
this Transport's Processor is null and
Connection doesn't have neither preferred Processor
nor ProcessorSelector.public void setProcessorSelector(ProcessorSelector selector)
ProcessorSelector, which will be used to get
Processor to process Connection I/O events, in case if
this Transport's Processor is null and
Connection doesn't have neither preferred Processor
nor ProcessorSelector.
Transport's ProcessorSelector is the last place, where
Transport will try to get Processor to process
Connection I/O event. If ProcessorSelector is not set -
IllegalStateException will be thrown.
setProcessorSelector in interface Transportpublic Strategy getStrategy()
Strategy implementation, which will be used by
Transport to process IOEvent.
Strategy is responsible for choosing the way, how I/O event
will be processed: using current Thread, worker Thread;
or make any other decisions.
getStrategy in interface TransportStrategy implementation, which will be used by
Transport to process IOEvent.public void setStrategy(Strategy strategy)
Strategy implementation, which will be used by
Transport to process IOEvent.
Strategy is responsible for choosing the way, how I/O event
will be processed: using current Thread, worker Thread;
or make any other decisions.
setStrategy in interface Transportstrategy - the Strategy implementation, which will be used
by Transport to process IOEvent.public MemoryManager getMemoryManager()
Transport associated MemoryManager, which will
be used by the Transport, its Connections and by during
processing I/O events, occurred on Connections.
getMemoryManager in interface TransportTransport associated MemoryManager,
which will be used by the Transport, its Connections
and by during processing I/O events, occurred on Connections.public void setMemoryManager(MemoryManager memoryManager)
Transport associated MemoryManager, which will
be used by the Transport, its Connections and by during
processing I/O events, occurred on Connections.
setMemoryManager in interface TransportmemoryManager - the Transport associated
MemoryManager, which will be used by the Transport,
its Connections and by during processing I/O events, occurred
on Connections.public ExecutorService getWorkerThreadPool()
Processors could be executed by this
thread pool.
getWorkerThreadPool in interface TransportExecutorService worker thread pool.public void setWorkerThreadPool(ExecutorService workerThreadPool)
Processor could be executed by this
thread pool.
setWorkerThreadPool in interface TransportworkerThreadPool - ExecutorService worker thread pool.public ExecutorService getInternalThreadPool()
Selector polling etc.
getInternalThreadPool in interface TransportExecutorService internal thread pool.public void setInternalThreadPool(ExecutorService internalThreadPool)
Selector polling etc.
setInternalThreadPool in interface TransportinternalThreadPool - ExecutorService internal thread pool.public AttributeBuilder getAttributeBuilder()
Transport associated AttributeBuilder, which will
be used by Transport and its Connections to store custom
Attributes.
getAttributeBuilder in interface TransportTransport associated AttributeBuilder, which will
be used by Transport and its Connections to store custom
Attributes.public void setAttributeBuilder(AttributeBuilder attributeBuilder)
Transport associated AttributeBuilder, which will
be used by Transport and its Connections to store custom
Attributes.
setAttributeBuilder in interface TransportattributeBuilder - Transport associated
AttributeBuilder, which will be used by Transport and
its Connections to store custom Attributes.public void addExceptionHandler(ExceptionHandler handler)
ExceptionHandler to handle errors, occurred during the
Transport execution.
addExceptionHandler in interface Transporthandler - ExceptionHandler to be added.public void removeExceptionHandler(ExceptionHandler handler)
ExceptionHandler from the list of Transport
ExceptionHandlers.
removeExceptionHandler in interface Transporthandler - ExceptionHandler to be removed.
public void notifyException(ExceptionHandler.Severity severity,
Throwable throwable)
Transport execution.
notifyException in interface TransportnotifyException in interface ExceptionHandlerseverity - the error severity.throwable - the error description.
public void fireIOEvent(IOEvent ioEvent,
Connection connection)
throws IOException
IOEvent on the Connection
fireIOEvent in interface TransportioEvent - I/O eventconnection - Connection, on which we fire the event.
IOException
protected abstract void closeConnection(Connection connection)
throws IOException
connection -
IOException
public abstract void start()
throws IOException
start in interface TransportIOException
public abstract void stop()
throws IOException
stop in interface TransportIOException
public abstract void pause()
throws IOException
pause in interface TransportIOException
public abstract void resume()
throws IOException
resume in interface TransportIOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||