public abstract class NIOTransportBuilder<T extends NIOTransportBuilder> extends Object
NIOTransport
implementations
as well as providing basic configuration for IOStrategies
and
thread pools.NIOTransport
,
IOStrategy
,
ThreadPoolConfig
Modifier and Type | Field and Description |
---|---|
protected NIOTransport |
transport
The
NIOTransport implementation. |
Modifier | Constructor and Description |
---|---|
protected |
NIOTransportBuilder(Class<? extends NIOTransport> transportClass,
IOStrategy strategy)
|
protected NIOTransport transport
NIOTransport
implementation.protected NIOTransportBuilder(Class<? extends NIOTransport> transportClass, IOStrategy strategy) throws IllegalAccessException, InstantiationException
Constructs a new NIOTransport
using the given
transportClass
and IOStrategy
.
The builder's worker thread pool configuration will be based on the return
value of WorkerThreadPoolConfigProducer.createDefaultWorkerPoolConfig(Transport)
.
If worker thread configuration is non-null, the initial selector thread pool
configuration will be cloned from it, otherwise a default configuration
will be chosen.
transportClass
- the class of the NIOTransport
implementation to be used.strategy
- the IOStrategy
.IllegalAccessException
InstantiationException
public ThreadPoolConfig getWorkerThreadPoolConfig()
ThreadPoolConfig
that will be used to construct the
ExecutorService
for IOStrategies
that require worker threads. Depending on the IOStrategy
being
used, this may return null
.public ThreadPoolConfig getSelectorThreadPoolConfig()
ThreadPoolConfig
that will be used to construct the
ExecutorService
which will run the NIOTransport
's
SelectorRunner
s.public IOStrategy getIOStrategy()
IOStrategy
that will be used by the created NIOTransport
.public T setIOStrategy(IOStrategy strategy)
Changes the IOStrategy
that will be used. Invoking this method
may change the return value of getWorkerThreadPoolConfig()
strategy
- the IOStrategy
to use.NIOTransportBuilder
public MemoryManager getMemoryManager()
MemoryManager
that will be used by the created NIOTransport
.
If not explicitly set, then MemoryManager.DEFAULT_MEMORY_MANAGER
will be used.public T setMemoryManager(MemoryManager memoryManager)
MemoryManager
to be used by the created NIOTransport
.memoryManager
- the MemoryManager
.NIOTransportBuilder
public SelectorHandler getSelectorHandler()
SelectorHandler
that will be used by the created NIOTransport
.
If not explicitly set, then SelectorHandler.DEFAULT_SELECTOR_HANDLER
will be used.public T setSelectorHandler(SelectorHandler selectorHandler)
SelectorHandler
to be used by the created NIOTransport
.selectorHandler
- the SelectorHandler
.NIOTransportBuilder
public SelectionKeyHandler getSelectionKeyHandler()
SelectionKeyHandler
that will be used by the created NIOTransport
.
If not explicitly set, then SelectionKeyHandler.DEFAULT_SELECTION_KEY_HANDLER
will be used.public T setSelectionKeyHandler(SelectionKeyHandler selectionKeyHandler)
SelectionKeyHandler
to be used by the created NIOTransport
.selectionKeyHandler
- the SelectionKeyHandler
.NIOTransportBuilder
public AttributeBuilder getAttributeBuilder()
AttributeBuilder
that will be used by the created NIOTransport
.
If not explicitly set, then AttributeBuilder.DEFAULT_ATTRIBUTE_BUILDER
will be used.public T setAttributeBuilder(AttributeBuilder attributeBuilder)
AttributeBuilder
to be used by the created NIOTransport
.attributeBuilder
- the AttributeBuilder
.NIOTransportBuilder
public NIOChannelDistributor getNIOChannelDistributor()
NIOChannelDistributor
that will be used by the created NIOTransport
.
If not explicitly set, then AttributeBuilder.DEFAULT_ATTRIBUTE_BUILDER
will be used.public T setNIOChannelDistributor(NIOChannelDistributor nioChannelDistributor)
NIOChannelDistributor
to be used by the created NIOTransport
.nioChannelDistributor
- the NIOChannelDistributor
.NIOTransportBuilder
public SelectorProvider getSelectorProvider()
SelectorProvider
that will be used by the created NIOTransport
.
If not explicitly set, then SelectorProvider.provider()
will be used.public T setSelectorProvider(SelectorProvider selectorProvider)
SelectorProvider
to be used by the created NIOTransport
.selectorProvider
- the SelectorProvider
.NIOTransportBuilder
public String getName()
Transport.getName()
public T setName(String name)
NIOTransportBuilder
Transport.setName(String)
public Processor getProcessor()
Transport.getProcessor()
public T setProcessor(Processor processor)
NIOTransportBuilder
Transport.setProcessor(Processor)
public ProcessorSelector getProcessorSelector()
()
public T setProcessorSelector(ProcessorSelector processorSelector)
NIOTransportBuilder
Transport.setProcessorSelector(ProcessorSelector)
public int getReadBufferSize()
()
public T setReadBufferSize(int readBufferSize)
NIOTransportBuilder
Transport.setReadBufferSize(int)
public int getWriteBufferSize()
Transport.getWriteBufferSize()
public T setWriteBufferSize(int writeBufferSize)
NIOTransportBuilder
Transport.setWriteBufferSize(int)
public NIOTransport build()
NIOTransport
based on the builder's configuration.protected ThreadPoolConfig configSelectorPool(ThreadPoolConfig config)
Configure the SelectorRunner
pool's
default core and max pool size.
config
- protected abstract T getThis()
Copyright © 2013 Oracle Corporation. All Rights Reserved.