diff options
Diffstat (limited to 'src/Probe.java')
-rw-r--r-- | src/Probe.java | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/Probe.java b/src/Probe.java index 6a4c75c..f362b38 100644 --- a/src/Probe.java +++ b/src/Probe.java @@ -103,7 +103,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin boolean timestamp=false; boolean quiet=false; boolean sendsToSelf=false; - String domain=Ivy.getDomain(null); + String domain=null; String name="JPROBE"; String[] messageClass=null; while ((c = opt.getopt()) != -1) switch (c) { @@ -113,11 +113,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin break; case 'b': domain=opt.getOptarg(); break; case 'c': - java.util.StringTokenizer classTok = new java.util.StringTokenizer(opt.getOptarg(),","); - messageClass=new String[classTok.countTokens()]; - System.out.println("YANNNN "+messageClass.length); - for (int i=0;classTok.hasMoreElements();) - messageClass[i++] = classTok.nextToken(); + messageClass = opt.getOptarg().split(","); break; case 'n': name=opt.getOptarg(); break; case 'q': quiet=true; break; @@ -133,7 +129,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin bus.sendToSelf(sendsToSelf); if (messageClass!=null) { System.out.println("using a message class filter of "+messageClass.length+" elements"); - for (String cls: messageClass) System.out.println(cls); + for (String cls: messageClass) System.out.println("\t "+cls); bus.setFilter(messageClass); } for (int i=opt.getOptind();i<args.length;i++) { @@ -144,7 +140,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin System.out.println("you have not subscribed to " + args[i]+ ", this regexp is invalid"); } } - if (!quiet) System.out.println("broadcasting on "+bus.domains(domain)); + if (!quiet) System.out.println("broadcasting on "+Domain.domains(domain)); bus.start(domain); p.start(bus); } @@ -165,6 +161,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin throw new RuntimeException(); } } + public Probe(BufferedReader in, boolean timestamp,boolean quiet,boolean debug) { this.in=in; this.timestamp=timestamp; @@ -223,7 +220,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin String target = m.group(1); int id = Integer.parseInt(m.group(2)); String message = m.group(3); - Vector<IvyClient>v=bus.getIvyClientsByName(target); + Collection<IvyClient>v=bus.getIvyClientsByName(target); if (v.size()==0) println("no Ivy client with the name \""+target+"\""); try { for (IvyClient ic : v) ic.sendDirectMsg(id,message); @@ -231,11 +228,10 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin println("-> not sent, the message contains incorrect characters"); } } else if (s.lastIndexOf(".dieall-yes-i-am-sure")>=0){ - Vector<IvyClient>v=bus.getIvyClients(); - for (IvyClient ic: v) ic.sendDie("java probe wants you to leave the bus"); + for (IvyClient ic: bus.getIvyClients()) ic.sendDie("java probe wants you to leave the bus"); } else if (s.lastIndexOf(".die ")>=0){ String target=s.substring(5); - Vector<IvyClient>v=bus.getIvyClientsByName(target); + Collection<IvyClient>v=bus.getIvyClientsByName(target); if (v.size()==0) println("no Ivy client with the name \""+target+"\""); for (IvyClient ic: v) ic.sendDie("java probe wants you to leave the bus"); } else if (s.lastIndexOf(".unbind ")>=0){ @@ -246,10 +242,9 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin println("you can't unsubscribe to " + regexp + ", your're not subscribed to it"); } } else if (s.lastIndexOf(".bound *")>=0){ - Vector<IvyClient>v=bus.getIvyClients(); int total=0; int boundedtotal=0; - for (IvyClient ic: v) { + for (IvyClient ic: bus.getIvyClients()) { for (String r : ic.getRegexps()) { total++; if (r.startsWith("^")) boundedtotal++; @@ -261,7 +256,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin int total=0; int boundedtotal=0; String target=s.substring(7); - Vector<IvyClient>v=bus.getIvyClientsByName(target); + Collection<IvyClient>v=bus.getIvyClientsByName(target); if (v.size()==0) println("no Ivy client with the name \""+target+"\""); for (IvyClient ic:v) { for (String r : ic.getRegexps()) { @@ -286,12 +281,12 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin bus.stop(); return false; } else if (s.lastIndexOf(".list")>=0) { - Vector<IvyClient> v = bus.getIvyClients(); - println(v.size()+" clients on the bus"); - for (IvyClient ic: v) println("-> "+ic.getApplicationName()); + Collection<IvyClient> c = bus.getIvyClients(); + println(c.size()+" clients on the bus"); + for (IvyClient ic: c) println("-> "+ic.getApplicationName()); } else if ( s.lastIndexOf(".ping ")>=0) { String target=s.substring(6); - Vector<IvyClient>v=bus.getIvyClientsByName(target); + Collection<IvyClient>v=bus.getIvyClientsByName(target); if (v.size()==0) println("no Ivy client with the name \""+target+"\""); for (IvyClient ic:v) { try { @@ -306,7 +301,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin } } else if ( s.lastIndexOf(".where ")>=0) { String target=s.substring(7); - Vector<IvyClient>v=bus.getIvyClientsByName(target); + Collection<IvyClient>v=bus.getIvyClientsByName(target); if (v.size()==0) println("no Ivy client with the name \""+target+"\""); for (IvyClient ic: v) println(target+" runs on "+ic.getHostName()); } else if (mtime.matches()) { |