Package org.drasyl.pipeline
Class AbstractPipeline
- java.lang.Object
-
- org.drasyl.pipeline.AbstractPipeline
-
- All Implemented Interfaces:
Pipeline
- Direct Known Subclasses:
DrasylPipeline
,EmbeddedPipeline
public abstract class AbstractPipeline extends Object implements Pipeline
AbstractPipeline
implementation, that needs head and tail.
-
-
Field Summary
Fields Modifier and Type Field Description protected DrasylConfig
config
protected DrasylScheduler
dependentScheduler
protected Map<String,org.drasyl.pipeline.AbstractHandlerContext>
handlerNames
protected org.drasyl.pipeline.AbstractEndHandler
head
protected Identity
identity
protected Serialization
inboundSerialization
protected DrasylScheduler
independentScheduler
protected Serialization
outboundSerialization
protected PeersManager
peersManager
protected org.drasyl.pipeline.AbstractEndHandler
tail
-
Constructor Summary
Constructors Constructor Description AbstractPipeline()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Pipeline
addAfter(String baseName, String name, Handler handler)
Inserts aHandler
after an existing handler of this pipeline.Pipeline
addBefore(String baseName, String name, Handler handler)
Inserts aHandler
before an existing handler of this pipeline.Pipeline
addFirst(String name, Handler handler)
Inserts aHandler
at the first position of this pipeline.Pipeline
addLast(String name, Handler handler)
Appends aHandler
at the last position of this pipeline.HandlerContext
context(String name)
Returns the context object of theHandler
with the specified name in this pipeline.Handler
get(String name)
Returns theHandler
with the specified name in this pipeline.protected void
initPointer()
CompletableFuture<Void>
processInbound(Event event)
Processes an inbound event by the pipeline.CompletableFuture<Void>
processInbound(Address sender, Object msg)
Processes an inbound message by the pipeline.CompletableFuture<Void>
processOutbound(Address recipient, Object msg)
Processes an outbound message by the pipeline.Pipeline
remove(String name)
Removes theHandler
with the specified name from this pipeline.Pipeline
replace(String oldName, String newName, Handler newHandler)
Replaces theHandler
of the specified name with a new handler in this pipeline.
-
-
-
Field Detail
-
head
protected org.drasyl.pipeline.AbstractEndHandler head
-
tail
protected org.drasyl.pipeline.AbstractEndHandler tail
-
dependentScheduler
protected DrasylScheduler dependentScheduler
-
independentScheduler
protected DrasylScheduler independentScheduler
-
config
protected DrasylConfig config
-
identity
protected Identity identity
-
peersManager
protected PeersManager peersManager
-
inboundSerialization
protected Serialization inboundSerialization
-
outboundSerialization
protected Serialization outboundSerialization
-
-
Method Detail
-
initPointer
protected void initPointer()
-
addFirst
public Pipeline addFirst(String name, Handler handler)
Description copied from interface:Pipeline
Inserts aHandler
at the first position of this pipeline.
-
addLast
public Pipeline addLast(String name, Handler handler)
Description copied from interface:Pipeline
Appends aHandler
at the last position of this pipeline.
-
addBefore
public Pipeline addBefore(String baseName, String name, Handler handler)
Description copied from interface:Pipeline
Inserts aHandler
before an existing handler of this pipeline.
-
addAfter
public Pipeline addAfter(String baseName, String name, Handler handler)
Description copied from interface:Pipeline
Inserts aHandler
after an existing handler of this pipeline.
-
remove
public Pipeline remove(String name)
Description copied from interface:Pipeline
Removes theHandler
with the specified name from this pipeline.
-
replace
public Pipeline replace(String oldName, String newName, Handler newHandler)
Description copied from interface:Pipeline
Replaces theHandler
of the specified name with a new handler in this pipeline.
-
get
public Handler get(String name)
Description copied from interface:Pipeline
Returns theHandler
with the specified name in this pipeline.
-
context
public HandlerContext context(String name)
Description copied from interface:Pipeline
Returns the context object of theHandler
with the specified name in this pipeline.
-
processInbound
public CompletableFuture<Void> processInbound(Address sender, Object msg)
Description copied from interface:Pipeline
Processes an inbound message by the pipeline.If an exception occurs during the execution of this method, the given
msg
is automatically released when it is of typeReferenceCounted
.- Specified by:
processInbound
in interfacePipeline
- Parameters:
sender
- the sender of the messagemsg
- the inbound message
-
processInbound
public CompletableFuture<Void> processInbound(Event event)
Description copied from interface:Pipeline
Processes an inbound event by the pipeline.- Specified by:
processInbound
in interfacePipeline
- Parameters:
event
- the inbound event
-
processOutbound
public CompletableFuture<Void> processOutbound(Address recipient, Object msg)
Description copied from interface:Pipeline
Processes an outbound message by the pipeline.If an exception occurs during the execution of this method, the given
msg
is automatically released when it is of typeReferenceCounted
.- Specified by:
processOutbound
in interfacePipeline
- Parameters:
recipient
- the recipient of the messagemsg
- the outbound message- Returns:
- a completed future if the message was successfully processed, otherwise an exceptionally future
-
-