/** * @param to output queue * @param from input queue * @param unhandled optional unhandled queue (may be null) */ public SpaceMUX (String to, String from, String unhandled) { this (); this.to = to; this.from = from; this.unhandled = unhandled; sp.addListener (from, this); }
public Connector (String from, String to) { this (); this.from = from; this.to = to; sp.addListener (from, this); } public void setConfiguration (Configuration cfg)
/** * @param ssp source space * @param dsp destination space * @param key key to monitor * @param tapKey key to use when copying * @param tapTimeout copy timeout in millis */ public SpaceTap (LocalSpace ssp, LocalSpace dsp, Object key, Object tapKey, long tapTimeout) { super(); this.ssp = ssp; this.dsp = dsp; this.key = key; this.tapKey = tapKey; this.tapTimeout = tapTimeout; if (key.equals (tapKey) && ssp == dsp) throw new IllegalArgumentException ("Possible deadlock - key equals tap-key within same space"); ssp.addListener (key, this); } public void notify (Object key, Object value) {
public SpaceSource(LocalSpace sp, ISOSource source, long timeout) { this.key = "SS." + UUID.randomUUID().toString(); this.connected = source.isConnected(); this.sp = sp; sp.addListener(key, this, timeout + 10000L); isp.out (key, source, timeout); }
public void startService () { if (!listenerRegistered) { listenerRegistered = true; // Handle messages that could be in the in queue at start time synchronized (sp) { Object[] pending = SpaceUtil.inpAll(sp, in); sp.addListener (in, this); for (Object o : pending) sp.out(in, o); } } } public void stopService () {
private void initIn() { Element persist = getPersist(); inQueue = persist.getChildText("in"); if (inQueue != null) { /* * We have an 'in' queue to monitor for messages we will * send out through server in our (SpaceListener)notify(Object, Object) method. */ sp.addListener(inQueue, this); } } private void initOut() {
public void setConfiguration (Configuration cfg) { if (this.cfg != null) sp.removeListener (from, this); this.cfg = cfg; from = cfg.get ("from"); to = cfg.get ("to"); sp.addListener (from, this); } public void notify (Object key, Object value) {
public void run (){ sp1.addListener(key, this); long stamp = System.nanoTime(); for (int i=0; i<COUNT; i++) sp1.out(key, Boolean.TRUE); long stamp2 = System.nanoTime(); t1.add(stamp2-stamp); System.err.println("Perform. "+key+" out: "+(stamp2-stamp)/1000000); }
public void run (){ sp1.addListener(key, this); for (int i=0; i<COUNT; i++) sp1.out(key, Boolean.TRUE); } public void notify(String key, Object value) {
/** * reads "to", "from" and optional "unhandled" properties * @param cfg */ public void setConfiguration (Configuration cfg) throws ConfigurationException { this.cfg = cfg; to = get ("to"); from = get ("from"); unhandled = cfg.get ("unhandled"); // can be null sp.addListener (from, this); } /**