public class FORK extends Protocol
限定符和类型 | 类和说明 |
---|---|
static class |
FORK.ForkHeader |
限定符和类型 | 字段和说明 |
---|---|
protected java.lang.String |
config |
protected java.util.concurrent.ConcurrentMap<java.lang.String,Protocol> |
fork_stacks |
static short |
ID |
构造器和说明 |
---|
FORK() |
限定符和类型 | 方法和说明 |
---|---|
Protocol |
createForkStack(java.lang.String fork_stack_id,
ProtocolStack stack,
boolean replace_existing,
java.util.List<Protocol> protocols)
Creates a new fork-stack from protocols and adds it into the hashmap of fork-stack (key is fork_stack_id).
|
protected void |
createForkStacks(java.util.Map<java.lang.String,java.util.List<ProtocolConfiguration>> protocols,
boolean replace_existing) |
protected void |
createForkStacks(java.lang.String config,
boolean replace_existing) |
protected static java.util.List<Protocol> |
createProtocols(ProtocolStack stack,
java.util.List<ProtocolConfiguration> protocol_configs)
Creates a fork-stack from the configuration, initializes all protocols (setting values),
sets the protocol stack as top protocol, connects the protocols and calls init() on them.
|
Protocol |
get(java.lang.String fork_stack_id) |
int |
getForkStacks() |
static java.io.InputStream |
getForkStream(java.lang.String config) |
void |
init()
Called after instance has been created (null constructor) and before protocol is started.
|
void |
parse(org.w3c.dom.Node node)
Called by the XML parser when subelements are found in the configuration of a protocol.
|
Protocol |
putIfAbsent(java.lang.String fork_stack_id,
Protocol prot) |
java.lang.Object |
up(Event evt)
An event was received from the layer below.
|
void |
up(MessageBatch batch)
Sends up a multiple messages in a
MessageBatch . |
accept, destroy, down, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled, stop
public static short ID
protected java.lang.String config
protected final java.util.concurrent.ConcurrentMap<java.lang.String,Protocol> fork_stacks
public Protocol get(java.lang.String fork_stack_id)
public int getForkStacks()
public void init() throws java.lang.Exception
Protocol
public java.lang.Object up(Event evt)
Protocol
down_prot.down()
or c) the event (or another event) is sent up
the stack using up_prot.up()
.public void up(MessageBatch batch)
Protocol
MessageBatch
. The sender of the batch is always the same, and so is the
destination (null == multicast messages). Messages in a batch can be OOB messages, regular messages, or mixed
messages, although the transport itself will create initial MessageBatches that contain only either OOB or
regular messages.
The default processing below sends messages up the stack individually, based on a matching criteria
(calling Protocol.accept(Message)
), and - if true - calls Protocol.up(Event)
for that message and removes the message. If the batch is not empty, it is passed up, or else it is dropped.
Subclasses should check if there are any messages destined for them (e.g. using
MessageBatch.getMatchingMessages(short, boolean)
), then possibly remove and process them and finally pass
the batch up to the next protocol. Protocols can also modify messages in place, e.g. ENCRYPT could decrypt all
encrypted messages in the batch, not remove them, and pass the batch up when done.protected void createForkStacks(java.lang.String config, boolean replace_existing) throws java.lang.Exception
java.lang.Exception
protected void createForkStacks(java.util.Map<java.lang.String,java.util.List<ProtocolConfiguration>> protocols, boolean replace_existing) throws java.lang.Exception
java.lang.Exception
public void parse(org.w3c.dom.Node node) throws java.lang.Exception
Protocol
public Protocol createForkStack(java.lang.String fork_stack_id, ProtocolStack stack, boolean replace_existing, java.util.List<Protocol> protocols) throws java.lang.Exception
fork_stack_id
- The key under which the new fork-stack should be added to the fork-stacks hashmapstack
- The protocol stack under which to create the protocolsreplace_existing
- If true, and existing fork-stack is simply replaced (de-initializing it first).
Otherwise, if the stack already exists, the new fork-stack will not be created.protocols
- A list of protocols from bottom to top to be inserted. They will be sandwiched
between ForkProtocolStack (top) and ForkProtocol (bottom). The list can be empty (or null) in
which case we won't create any protocols, but still have a separate fork-stack inserted.java.lang.Exception
protected static java.util.List<Protocol> createProtocols(ProtocolStack stack, java.util.List<ProtocolConfiguration> protocol_configs) throws java.lang.Exception
java.lang.Exception
public static java.io.InputStream getForkStream(java.lang.String config) throws java.io.IOException
java.io.IOException