|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfr.dgac.ivy.Ivy
public class Ivy
Field Summary | |
---|---|
protected int |
applicationPort
|
static java.lang.String |
DEFAULT_DOMAIN
the domain for the UDP rendez vous |
static int |
DEFAULT_PORT
the port for the UDP rendez vous, if none is supplied |
protected boolean |
doProtectNewlines
|
static java.lang.String |
libVersion
the library version, useful for development purposes only, when java is invoked with -DIVY_DEBUG |
static int |
PROTOCOLMINIMUM
|
static int |
PROTOCOLVERSION
the protocol version number |
protected java.lang.String |
ready_message
|
protected fr.dgac.ivy.SelfIvyClient |
selfIvyClient
|
static int |
TIMEOUTLENGTH
|
Constructor Summary | |
---|---|
Ivy(java.lang.String name,
java.lang.String message,
IvyApplicationListener appcb)
Readies the structures for the software bus connexion. |
Method Summary | |
---|---|
int |
addApplicationListener(IvyApplicationListener callback)
adds an application listener to a bus |
int |
addBindListener(IvyBindListener callback)
adds a bind listener to a bus |
protected static IvyClient |
alreadyThere(java.util.Hashtable c,
java.lang.String name)
|
int |
bindAsyncMsg(java.lang.String sregexp,
IvyMessageListener callback)
Subscribes to a regular expression with asyncrhonous callback execution. |
int |
bindMsg(java.lang.String sregexp,
IvyMessageListener callback)
Subscribes to a regular expression. |
int |
bindMsg(java.lang.String sregexp,
IvyMessageListener callback,
boolean async)
Subscribes to a regular expression. |
int |
bindMsgOnce(java.lang.String sregexp,
IvyMessageListener callback)
Subscribes to a regular expression for one time only, useful for requests, in cunjunction with getWBUId() The callback will be executed once and only once, and the agent will unsubscribe |
boolean |
CheckRegexp(java.lang.String exp)
|
protected void |
clientConnects(IvyClient client)
|
protected void |
clientDisconnects(IvyClient client)
|
protected void |
dieReceived(IvyClient client,
int id,
java.lang.String message)
|
void |
directMessage(IvyClient client,
int id,
java.lang.String msgarg)
|
java.lang.String |
domains(java.lang.String toparse)
|
static java.lang.String |
getDomain(java.lang.String domainbus)
returns the domain bus |
static java.lang.String |
getDomainArgs(java.lang.String progname,
java.lang.String[] args)
returns the domain bus |
java.util.Vector |
getIvyClients()
gives the IvyClient() at a given instant |
java.util.Vector |
getIvyClientsByName(java.lang.String name)
gives a list of IvyClient(s) with the name given in parameter |
IvyClient |
getSelfIvyClient()
returns our self IvyClient. |
protected int |
getSerial()
|
protected java.lang.String |
getWatcherId()
|
java.lang.String |
getWBUId()
returns a "wana be unique" ID to make requests on the bus |
boolean |
isSendToSelf()
do I send messsages to myself ? |
static void |
main(java.lang.String[] args)
|
fr.dgac.ivy.Ivy.Domain[] |
parseDomains(java.lang.String domainbus)
|
void |
protectNewlines(boolean b)
Toggles the encoding/decoding of messages to prevent bugs related to the presence of a "\n" |
protected void |
regexpDeleted(IvyClient client,
int id,
java.lang.String sregexp)
|
protected void |
regexpReceived(IvyClient client,
int id,
java.lang.String sregexp)
|
void |
removeApplicationListener(int id)
removes an application listener |
void |
removeBindListener(int id)
removes a bind listener |
void |
run()
|
int |
sendMsg(java.lang.String message)
Performs a pattern matching according to everyone's regexps, and sends the results to the relevant ivy agents. |
void |
sendToSelf(boolean b)
Toggles the sending of messages to oneself, the remote client's IvyMessageListeners are processed first, and ourself afterwards. |
void |
setFilter(java.lang.String[] filter)
sets the filter expression |
void |
start(java.lang.String domainbus)
connects the Ivy bus to a domain or list of domains. |
void |
stop()
disconnects from the Ivy bus |
void |
unBindMsg(int id)
unsubscribes a regular expression |
boolean |
unBindMsg(java.lang.String re)
unsubscribes a regular expression |
IvyClient |
waitForClient(java.lang.String name,
int timeout)
Waits for an other IvyClient to join the bus |
IvyClient |
waitForMsg(java.lang.String regexp,
int timeout)
Waits for a message to be received |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int PROTOCOLVERSION
public static final int PROTOCOLMINIMUM
public static final int DEFAULT_PORT
public static final java.lang.String DEFAULT_DOMAIN
public static final java.lang.String libVersion
protected int applicationPort
protected java.lang.String ready_message
protected boolean doProtectNewlines
protected fr.dgac.ivy.SelfIvyClient selfIvyClient
public static final int TIMEOUTLENGTH
Constructor Detail |
---|
public Ivy(java.lang.String name, java.lang.String message, IvyApplicationListener appcb)
name
- The name of your Ivy agent on the software busmessage
- The hellow message you will send once readyappcb
- A callback handling the notification of connexions and
disconnections, may be nullstart(java.lang.String)
Method Detail |
---|
public IvyClient waitForMsg(java.lang.String regexp, int timeout) throws IvyException
regexp
- the message we're waiting for to continue the main thread.timeout
- in millisecond, 0 if infinite
IvyException
public IvyClient waitForClient(java.lang.String name, int timeout) throws IvyException
name
- the name of the client we're waiting for to continue the main thread.timeout
- in millisecond, 0 if infinite
IvyException
protected static IvyClient alreadyThere(java.util.Hashtable c, java.lang.String name)
public void start(java.lang.String domainbus) throws IvyException
domainbus
- a domain of the form 10.0.0:1234, it is similar to the
netmask without the trailing .255. This will determine the meeting point
of the different applications. Right now, this is done with an UDP
broadcast. Beware of routing problems ! You can also use a comma
separated list of domains.
1.2.8: goes synchronized. I don't know if it's really useful
IvyException
public fr.dgac.ivy.Ivy.Domain[] parseDomains(java.lang.String domainbus)
public void stop()
public void sendToSelf(boolean b)
b
- true if you want to send the message to yourself. Default
is falsepublic boolean isSendToSelf()
public IvyClient getSelfIvyClient()
public void protectNewlines(boolean b)
b
- true if you want to enforce encoding of newlines. Default
is false. Every receiver will have to decode newlinespublic int sendMsg(java.lang.String message) throws IvyException
message
- A String which will be compared to the regular
expressions of the different clients
IvyException
public int bindMsg(java.lang.String sregexp, IvyMessageListener callback) throws IvyException
Example:
the Ivy agent A performs
b.bindMsg("^Hello (*)",cb);
b2.sendMsg("Hello world");
sregexp
- a perl regular expression, groups are done with parenthesiscallback
- any objects implementing the IvyMessageListener
interface, on the AWT/Swing framework
IvyException
public int bindAsyncMsg(java.lang.String sregexp, IvyMessageListener callback) throws IvyException
sregexp
- a perl compatible regular expression, groups are done with parenthesiscallback
- any objects implementing the IvyMessageListener
interface, on the AWT/Swing framework
IvyException
public int bindMsg(java.lang.String sregexp, IvyMessageListener callback, boolean async) throws IvyException
Example:
the Ivy agent A performs
b.bindMsg("^Hello (*)",cb);
b2.sendMsg("Hello world");
sregexp
- a perl regular expression, groups are done with parenthesiscallback
- any objects implementing the IvyMessageListener
interface, on the AWT/Swing frameworkasync
- if true, each callback will be run in a separate thread,
default is false
IvyException
public int bindMsgOnce(java.lang.String sregexp, IvyMessageListener callback) throws IvyException
sregexp
- a perl regular expression, groups are done with parenthesiscallback
- any objects implementing the IvyMessageListener
interface, on the AWT/Swing framework
IvyException
public void unBindMsg(int id) throws IvyException
id
- the id of the regular expression, returned when it was bound
IvyException
public boolean unBindMsg(java.lang.String re)
re
- the string for the regular expression
public int addBindListener(IvyBindListener callback)
callback
- is an object implementing the IvyBindListener interface
public void removeBindListener(int id) throws IvyException
id
- the id of the bind listener to remove
IvyException
public int addApplicationListener(IvyApplicationListener callback)
callback
- is an object implementing the IvyApplicationListener
interface
public void removeApplicationListener(int id) throws IvyException
id
- the id of the application listener to remove
IvyException
public void setFilter(java.lang.String[] filter)
filter
- the extensive list of strings beginning the messagespublic boolean CheckRegexp(java.lang.String exp)
protected void clientConnects(IvyClient client)
protected void clientDisconnects(IvyClient client)
protected void regexpReceived(IvyClient client, int id, java.lang.String sregexp)
protected void regexpDeleted(IvyClient client, int id, java.lang.String sregexp)
protected void dieReceived(IvyClient client, int id, java.lang.String message)
public void directMessage(IvyClient client, int id, java.lang.String msgarg)
public java.util.Vector getIvyClients()
public java.util.Vector getIvyClientsByName(java.lang.String name)
name
- The name of the Ivy agent you're looking forpublic static java.lang.String getDomain(java.lang.String domainbus)
domainbus
- if non null, returns the argument
public static java.lang.String getDomainArgs(java.lang.String progname, java.lang.String[] args)
progname
- The name of your program, for error messageargs
- the String[] of arguments passed to your main()
public java.lang.String getWBUId()
public void run()
run
in interface java.lang.Runnable
protected java.lang.String getWatcherId()
protected int getSerial()
public java.lang.String domains(java.lang.String toparse)
public static void main(java.lang.String[] args)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |