|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jumpi.impl.AbstractConnector | +--org.jumpi.impl.connector.loopback.LoopbackConnector
The LoopbackConnector simulates a loopback network adapter where sends are passed straight back to receives without actually performing the operations on the network layer. This can be helpful for testing purposes. There is a configurable send delay for simulating network delays.
Field Summary |
Fields inherited from class org.jumpi.impl.AbstractConnector |
cancelledRecvs_, cancelledSends_, controller_, joinFailInterval_, joinTestInterval_, jumpi_, maxRecvBacklog_, maxSendBacklog_, name_, protocol_, recvQueue_, recvTransformer_, sendQueue_, sendTransformer_, started_, stopping_, taskId_, url_format_, url_prefix_ |
Constructor Summary | |
LoopbackConnector()
|
Method Summary | |
void |
cancelRecv(Envelope env)
Cancel a receive operation which is registered by removing it from the registered operations table. |
protected boolean |
checkJoinCondition()
Return true if the buffered send queue is empty and there are no registered receive filters. |
void |
configure(java.lang.String name,
Properties props)
Configure the LoopbackConnector. |
Destination |
getDestination(java.lang.String url,
java.util.Hashtable clientProps)
Any Urls are managed which have the configured protocol prefix. |
void |
manage(Component root,
Component parent,
java.lang.String operation,
java.util.Hashtable parameters)
Perform a recursive management operation through the Jumpi component tree, using the parameters provided. |
protected boolean |
onRecv(Envelope env)
Synchronous receive is not used. |
protected boolean |
onSend(Envelope env)
Send a message asynchronously to a receiver on the Destination, providing configurable send delay. |
void |
recv(Envelope env)
Receive a message asynchronously from a Destination. |
protected void |
shutdownState()
Clear the buffered send queue and registered receives. |
Methods inherited from class org.jumpi.impl.AbstractConnector |
cancelSend, getName, getTaskId, isLongRunning, isSchedulable, run, send |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.jumpi.spi.component.Task |
getTaskId, isLongRunning, isSchedulable |
Methods inherited from interface java.lang.Runnable |
run |
Constructor Detail |
public LoopbackConnector()
Method Detail |
public void configure(java.lang.String name, Properties props) throws java.lang.Exception
The following configuration attributes are defined in addition to those of the superclass:
senddelay - integer[0..MAX-INT] - optional[0].
The default time interval to delay the sending thread to simulate a real send.
configure
in interface Configurable
configure
in class AbstractConnector
name
- the fully qualified instance name.props
- the read-only properties to configure the instance with.
java.lang.Exception
- when configuration is unsuccessful.public void manage(Component root, Component parent, java.lang.String operation, java.util.Hashtable parameters) throws java.lang.Exception
manage
in interface Manageable
manage
in class AbstractConnector
root
- the Jumpi instance at the root of the component tree.parent
- the immediate parent of the component.operation
- the operation.parameters
- the operation parameters.
java.lang.Exception
- if any failure to perform management occurs.public Destination getDestination(java.lang.String url, java.util.Hashtable clientProps)
Any Urls are managed which have the configured protocol prefix. The syntax of supported Urls is defined as:
<protocol>://<uri> where <protocol> is the configured protocol and <uri> is any string. The <uri> value * represents a wildcard, matching any other <uri;>
getDestination
in interface Connector
getDestination
in class AbstractConnector
url
- the Destination Url.clientProps
- not used.
java.lang.IllegalArgumentException
- when url is null.public void recv(Envelope env) throws java.lang.Exception
Receive a message asynchronously from a Destination. The receive operations are registered in two tables. One table for specific Destinations, and the other for the wildcard Destination. A send operation matching a registered receive will be passed back to the receiver. A send operation matching no receive operation will fail.
The message format required on reception is determined by the receive transformer.
Allows concurrent receive operations to different Destinations, yet only a single receive operation to each Destination.
Non blocking always.
All manipulations of the receive filters are synchronized.
recv
in interface Connector
recv
in class AbstractConnector
env
- the Envelope containing the Destination to receive from.
java.lang.Exception
- if a failure condition occurs.
java.lang.IllegalArgumentException
- when env is null.
java.lang.IllegalStateException
- when not started or stopping.Controller.callbackRecv(org.jumpi.spi.Envelope, boolean, java.lang.String)
protected boolean onRecv(Envelope env) throws java.lang.Exception
onRecv
in class AbstractConnector
env
- the Envelope containing the Destination to receive from.
java.lang.Exception
- never.public void cancelRecv(Envelope env)
Cancel a receive operation which is registered by removing it from the registered operations table.
All manipulations of the receive filters are synchronized.
cancelRecv
in interface Connector
cancelRecv
in class AbstractConnector
env
- the receive Envelope to cancel.
java.lang.IllegalArgumentException
- when env is null.protected boolean onSend(Envelope env) throws java.lang.Exception
Send a message asynchronously to a receiver on the Destination, providing configurable send delay. If no receiver is registered on the Destination at the time of sending, then the send will fail. The message is not sent over any network. Illegal to send to the wildcard Destination, since this is not a real Destination.
The message format required on entry is determined by the send transformer. The transformed message is passed unchanged by value to the receiver.
Allows multiple concurrent send operations to the same Destination and different Destinations. The sends are however processes sequentially by the instance's task working off the buffered send queue.
Non blocking until the buffered send queue has filled, at which time send flow control prohibits further sending until there is space in the queue.
onSend
in class AbstractConnector
env
- the Envelope containing the Destination to send to and the
message.
java.lang.Exception
- if a failure condition occurs, or no receiver is
registered.protected boolean checkJoinCondition()
checkJoinCondition
in class AbstractConnector
protected void shutdownState()
shutdownState
in class AbstractConnector
|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |