Package io.netty.channel.embedded
Class Plc4xEmbeddedChannel
java.lang.Object
io.netty.util.DefaultAttributeMap
io.netty.channel.AbstractChannel
io.netty.channel.embedded.Plc4xEmbeddedChannel
- All Implemented Interfaces:
EventLoopProvider,io.netty.channel.Channel,io.netty.channel.ChannelOutboundInvoker,io.netty.util.AttributeMap,Comparable<io.netty.channel.Channel>
public class Plc4xEmbeddedChannel
extends io.netty.channel.AbstractChannel
implements EventLoopProvider
Base class for
Channel implementations that are used in an embedded fashion.-
Nested Class Summary
Nested classes/interfaces inherited from class io.netty.channel.AbstractChannel
io.netty.channel.AbstractChannel.AbstractUnsafeNested classes/interfaces inherited from interface io.netty.channel.Channel
io.netty.channel.Channel.Unsafe -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance with anEmbeddedChannelIdand an empty pipeline.Plc4xEmbeddedChannel(boolean register, boolean hasDisconnect, io.netty.channel.ChannelHandler... handlers) Create a new instance with the pipeline initialized with the specified handlers.Plc4xEmbeddedChannel(boolean hasDisconnect, io.netty.channel.ChannelHandler... handlers) Create a new instance with the pipeline initialized with the specified handlers.Plc4xEmbeddedChannel(io.netty.channel.ChannelHandler... handlers) Create a new instance with the pipeline initialized with the specified handlers.Plc4xEmbeddedChannel(io.netty.channel.ChannelId channelId) Create a new instance with the specified ID and an empty pipeline.Plc4xEmbeddedChannel(io.netty.channel.ChannelId channelId, boolean register, boolean hasDisconnect, io.netty.channel.ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.Plc4xEmbeddedChannel(io.netty.channel.ChannelId channelId, boolean hasDisconnect, io.netty.channel.ChannelConfig config, io.netty.channel.ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.Plc4xEmbeddedChannel(io.netty.channel.ChannelId channelId, boolean hasDisconnect, io.netty.channel.ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.Plc4xEmbeddedChannel(io.netty.channel.ChannelId channelId, io.netty.channel.ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.Plc4xEmbeddedChannel(io.netty.channel.Channel parent, io.netty.channel.ChannelId channelId, boolean register, boolean hasDisconnect, io.netty.channel.ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers. -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck if there was anyThrowablereceived and if so rethrow it.final io.netty.channel.ChannelFutureclose()final io.netty.channel.ChannelFutureclose(io.netty.channel.ChannelPromise promise) io.netty.channel.ChannelConfigconfig()final io.netty.channel.ChannelFuturefinal io.netty.channel.ChannelFuturedisconnect(io.netty.channel.ChannelPromise promise) protected voidprotected voiddoBind(SocketAddress localAddress) protected voiddoClose()protected voidprotected voidprotected voiddoWrite(io.netty.channel.ChannelOutboundBuffer in) protected final voidEnsure theChannelis open and if not throw an exception.booleanfinish()Mark thisChannelas finished.booleanMark thisChannelas finished and release all pending message in the inbound and outbound buffer.Flushes the inbound of thisChannel.Flushes the outbound of thisChannel.io.netty.channel.EventLoopprotected voidCalled for each inbound message.protected voidCalled for each outbound message.booleanisActive()protected booleanisCompatible(io.netty.channel.EventLoop loop) booleanisOpen()booleanDeprecated.Deprecated.protected SocketAddressio.netty.channel.ChannelMetadatametadata()protected final io.netty.channel.DefaultChannelPipelineprotected io.netty.channel.AbstractChannel.AbstractUnsafe<T> TReturn received data from thisChannel<T> TRead data from the outbound.voidregister()Register thisChannelon itsEventLoop.booleanRelease all buffered inbound messages and returntrueif any were in the inbound buffer,falseotherwise.booleanRelease all buffered outbound messages and returntrueif any were in the outbound buffer,falseotherwise.protected SocketAddressvoidRun all tasks (which also includes scheduled tasks) that are pending in theEventLoopfor thisChannellongRun all pending scheduled tasks in theEventLoopfor thisChanneland return thenanosecondswhen the next scheduled task is ready to run.io.netty.channel.Channel.Unsafeunsafe()booleanwriteInbound(Object... msgs) Write messages to the inbound of thisChannel.io.netty.channel.ChannelFuturewriteOneInbound(Object msg) Writes one message to the inbound of thisChanneland does not flush it.io.netty.channel.ChannelFuturewriteOneInbound(Object msg, io.netty.channel.ChannelPromise promise) Writes one message to the inbound of thisChanneland does not flush it.io.netty.channel.ChannelFuturewriteOneOutbound(Object msg) Writes one message to the outbound of thisChanneland does not flush it.io.netty.channel.ChannelFuturewriteOneOutbound(Object msg, io.netty.channel.ChannelPromise promise) Writes one message to the outbound of thisChanneland does not flush it.booleanwriteOutbound(Object... msgs) Write messages to the outbound of thisChannel.Methods inherited from class io.netty.channel.AbstractChannel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, doDeregister, doShutdownOutput, equals, eventLoop, filterOutboundMessage, flush, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isWritable, localAddress, maxMessagesPerWrite, newFailedFuture, newId, newProgressivePromise, newPromise, newSucceededFuture, parent, pipeline, read, remoteAddress, toString, validateFileRegion, voidPromise, write, write, writeAndFlush, writeAndFlushMethods inherited from class io.netty.util.DefaultAttributeMap
attr, hasAttrMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.netty.util.AttributeMap
attr, hasAttr
-
Constructor Details
-
Plc4xEmbeddedChannel
public Plc4xEmbeddedChannel()Create a new instance with anEmbeddedChannelIdand an empty pipeline. -
Plc4xEmbeddedChannel
public Plc4xEmbeddedChannel(io.netty.channel.ChannelId channelId) Create a new instance with the specified ID and an empty pipeline.- Parameters:
channelId- theChannelIdthat will be used to identify this channel
-
Plc4xEmbeddedChannel
public Plc4xEmbeddedChannel(io.netty.channel.ChannelHandler... handlers) Create a new instance with the pipeline initialized with the specified handlers.- Parameters:
handlers- theChannelHandlers which will be add in theChannelPipeline
-
Plc4xEmbeddedChannel
public Plc4xEmbeddedChannel(boolean hasDisconnect, io.netty.channel.ChannelHandler... handlers) Create a new instance with the pipeline initialized with the specified handlers.- Parameters:
hasDisconnect-falseif thisChannelwill delegatedisconnect()toclose(), false otherwise.handlers- theChannelHandlers which will be add in theChannelPipeline
-
Plc4xEmbeddedChannel
public Plc4xEmbeddedChannel(boolean register, boolean hasDisconnect, io.netty.channel.ChannelHandler... handlers) Create a new instance with the pipeline initialized with the specified handlers.- Parameters:
register-trueif thisChannelis registered to theEventLoopin the constructor. Iffalsethe user will need to callregister().hasDisconnect-falseif thisChannelwill delegatedisconnect()toclose(), false otherwise.handlers- theChannelHandlers which will be add in theChannelPipeline
-
Plc4xEmbeddedChannel
public Plc4xEmbeddedChannel(io.netty.channel.ChannelId channelId, io.netty.channel.ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.- Parameters:
channelId- theChannelIdthat will be used to identify this channelhandlers- theChannelHandlers which will be add in theChannelPipeline
-
Plc4xEmbeddedChannel
public Plc4xEmbeddedChannel(io.netty.channel.ChannelId channelId, boolean hasDisconnect, io.netty.channel.ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.- Parameters:
channelId- theChannelIdthat will be used to identify this channelhasDisconnect-falseif thisChannelwill delegatedisconnect()toclose(), false otherwise.handlers- theChannelHandlers which will be add in theChannelPipeline
-
Plc4xEmbeddedChannel
public Plc4xEmbeddedChannel(io.netty.channel.ChannelId channelId, boolean register, boolean hasDisconnect, io.netty.channel.ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.- Parameters:
channelId- theChannelIdthat will be used to identify this channelregister-trueif thisChannelis registered to theEventLoopin the constructor. Iffalsethe user will need to callregister().hasDisconnect-falseif thisChannelwill delegatedisconnect()toclose(), false otherwise.handlers- theChannelHandlers which will be add in theChannelPipeline
-
Plc4xEmbeddedChannel
public Plc4xEmbeddedChannel(io.netty.channel.Channel parent, io.netty.channel.ChannelId channelId, boolean register, boolean hasDisconnect, io.netty.channel.ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.- Parameters:
parent- the parentChannelof thisEmbeddedChannel.channelId- theChannelIdthat will be used to identify this channelregister-trueif thisChannelis registered to theEventLoopin the constructor. Iffalsethe user will need to callregister().hasDisconnect-falseif thisChannelwill delegatedisconnect()toclose(), false otherwise.handlers- theChannelHandlers which will be add in theChannelPipeline
-
Plc4xEmbeddedChannel
public Plc4xEmbeddedChannel(io.netty.channel.ChannelId channelId, boolean hasDisconnect, io.netty.channel.ChannelConfig config, io.netty.channel.ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.- Parameters:
channelId- theChannelIdthat will be used to identify this channelhasDisconnect-falseif thisChannelwill delegatedisconnect()toclose(), false otherwise.config- theChannelConfigwhich will be returned byconfig().handlers- theChannelHandlers which will be add in theChannelPipeline
-
-
Method Details
-
getEventLoop
public io.netty.channel.EventLoop getEventLoop()- Specified by:
getEventLoopin interfaceEventLoopProvider
-
isRegistered
public boolean isRegistered()- Specified by:
isRegisteredin interfaceio.netty.channel.Channel- Overrides:
isRegisteredin classio.netty.channel.AbstractChannel
-
register
Register thisChannelon itsEventLoop.- Throws:
Exception
-
newChannelPipeline
protected final io.netty.channel.DefaultChannelPipeline newChannelPipeline()- Overrides:
newChannelPipelinein classio.netty.channel.AbstractChannel
-
metadata
public io.netty.channel.ChannelMetadata metadata()- Specified by:
metadatain interfaceio.netty.channel.Channel
-
config
public io.netty.channel.ChannelConfig config()- Specified by:
configin interfaceio.netty.channel.Channel
-
isOpen
public boolean isOpen()- Specified by:
isOpenin interfaceio.netty.channel.Channel
-
isActive
public boolean isActive()- Specified by:
isActivein interfaceio.netty.channel.Channel
-
inboundMessages
-
lastInboundBuffer
Deprecated. -
outboundMessages
-
lastOutboundBuffer
Deprecated. -
readInbound
public <T> T readInbound()Return received data from thisChannel -
readOutbound
public <T> T readOutbound()Read data from the outbound. This may returnnullif nothing is readable. -
writeInbound
Write messages to the inbound of thisChannel.- Parameters:
msgs- the messages to be written- Returns:
trueif the write operation did add something to the inbound buffer
-
writeOneInbound
Writes one message to the inbound of thisChanneland does not flush it. This method is conceptually equivalent toAbstractChannel.write(Object).- See Also:
-
writeOneInbound
public io.netty.channel.ChannelFuture writeOneInbound(Object msg, io.netty.channel.ChannelPromise promise) Writes one message to the inbound of thisChanneland does not flush it. This method is conceptually equivalent toAbstractChannel.write(Object, ChannelPromise).- See Also:
-
flushInbound
Flushes the inbound of thisChannel. This method is conceptually equivalent toAbstractChannel.flush().- See Also:
-
writeOutbound
Write messages to the outbound of thisChannel.- Parameters:
msgs- the messages to be written- Returns:
- bufferReadable returns
trueif the write operation did add something to the outbound buffer
-
writeOneOutbound
Writes one message to the outbound of thisChanneland does not flush it. This method is conceptually equivalent toAbstractChannel.write(Object).- See Also:
-
writeOneOutbound
public io.netty.channel.ChannelFuture writeOneOutbound(Object msg, io.netty.channel.ChannelPromise promise) Writes one message to the outbound of thisChanneland does not flush it. This method is conceptually equivalent toAbstractChannel.write(Object, ChannelPromise).- See Also:
-
flushOutbound
Flushes the outbound of thisChannel. This method is conceptually equivalent toAbstractChannel.flush().- See Also:
-
finish
public boolean finish()Mark thisChannelas finished. Any further try to write data to it will fail.- Returns:
- bufferReadable returns
trueif any of the used buffers has something left to read
-
finishAndReleaseAll
public boolean finishAndReleaseAll()Mark thisChannelas finished and release all pending message in the inbound and outbound buffer. Any further try to write data to it will fail.- Returns:
- bufferReadable returns
trueif any of the used buffers has something left to read
-
releaseInbound
public boolean releaseInbound()Release all buffered inbound messages and returntrueif any were in the inbound buffer,falseotherwise. -
releaseOutbound
public boolean releaseOutbound()Release all buffered outbound messages and returntrueif any were in the outbound buffer,falseotherwise. -
close
public final io.netty.channel.ChannelFuture close()- Specified by:
closein interfaceio.netty.channel.ChannelOutboundInvoker- Overrides:
closein classio.netty.channel.AbstractChannel
-
disconnect
public final io.netty.channel.ChannelFuture disconnect()- Specified by:
disconnectin interfaceio.netty.channel.ChannelOutboundInvoker- Overrides:
disconnectin classio.netty.channel.AbstractChannel
-
close
public final io.netty.channel.ChannelFuture close(io.netty.channel.ChannelPromise promise) - Specified by:
closein interfaceio.netty.channel.ChannelOutboundInvoker- Overrides:
closein classio.netty.channel.AbstractChannel
-
disconnect
public final io.netty.channel.ChannelFuture disconnect(io.netty.channel.ChannelPromise promise) - Specified by:
disconnectin interfaceio.netty.channel.ChannelOutboundInvoker- Overrides:
disconnectin classio.netty.channel.AbstractChannel
-
runPendingTasks
public void runPendingTasks()Run all tasks (which also includes scheduled tasks) that are pending in theEventLoopfor thisChannel -
runScheduledPendingTasks
public long runScheduledPendingTasks()Run all pending scheduled tasks in theEventLoopfor thisChanneland return thenanosecondswhen the next scheduled task is ready to run. If no other task was scheduled it will return-1. -
checkException
public void checkException()Check if there was anyThrowablereceived and if so rethrow it. -
ensureOpen
protected final void ensureOpen()Ensure theChannelis open and if not throw an exception. -
isCompatible
protected boolean isCompatible(io.netty.channel.EventLoop loop) - Specified by:
isCompatiblein classio.netty.channel.AbstractChannel
-
localAddress0
- Specified by:
localAddress0in classio.netty.channel.AbstractChannel
-
remoteAddress0
- Specified by:
remoteAddress0in classio.netty.channel.AbstractChannel
-
doRegister
- Overrides:
doRegisterin classio.netty.channel.AbstractChannel- Throws:
Exception
-
doBind
- Specified by:
doBindin classio.netty.channel.AbstractChannel- Throws:
Exception
-
doDisconnect
- Specified by:
doDisconnectin classio.netty.channel.AbstractChannel- Throws:
Exception
-
doClose
- Specified by:
doClosein classio.netty.channel.AbstractChannel- Throws:
Exception
-
doBeginRead
- Specified by:
doBeginReadin classio.netty.channel.AbstractChannel- Throws:
Exception
-
newUnsafe
protected io.netty.channel.AbstractChannel.AbstractUnsafe newUnsafe()- Specified by:
newUnsafein classio.netty.channel.AbstractChannel
-
unsafe
public io.netty.channel.Channel.Unsafe unsafe()- Specified by:
unsafein interfaceio.netty.channel.Channel- Overrides:
unsafein classio.netty.channel.AbstractChannel
-
doWrite
- Specified by:
doWritein classio.netty.channel.AbstractChannel- Throws:
Exception
-
handleOutboundMessage
Called for each outbound message.- See Also:
-
handleInboundMessage
Called for each inbound message.
-
inboundMessages()