import swarm.Selector;6 S6 ?2 } M9 O9 Y
# D, j) b5 e- K& H/ N- Tpublic class SwarmUtils {
( u x: O6 }6 l# B6 M/ H public static Selector getSelector(String name, String method) {& Y7 I7 U* E. i8 d. Y
Selector sel;2 T3 g/ h+ z; g
try {4 n0 ]/ s+ z& E& `6 m* K4 {
sel = new Selector(Class.forName(name), method, false);; \- O* t! I- Y0 u
} catch (Exception e) {9 D5 r/ o6 q. q& u, T
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");, k9 W% y( X; {# ?& h# q# v0 G; j; x
System.err.println(name + "." + method + " returns " + e.getMessage());; K* M6 |2 u0 ]" s- Y5 ?$ D4 L7 w& }
System.err.println("The process will be terminated.");, B3 v- A- v( I3 \. j7 O
System.exit(1);/ @! Q* V6 B8 e/ v! P, I/ e
return null; x+ y+ ?1 ?' j) l! C- @
}) o- R# G% R R3 {2 F
return sel;
, v4 h- |( J: x7 j4 o }
& O$ j5 V; x/ f& b( w. Q, M( ^6 C) e# M4 `1 I: k2 C& l* \3 z. i
public static Selector getSelector(Object obj, String method) {7 g6 h' B) E; L7 e2 F
Selector sel;; B2 R% S4 z+ I7 e8 x8 H# U N& x
try {" {( g/ @8 E; K3 O: v
sel = new Selector(obj.getClass(), method, false);
( O% B" m$ @* c4 C/ ?" G5 ? } catch (Exception e) {% C6 [- B* s: q/ v: n; `
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
9 Y7 ^* W4 z9 J. b1 e + (obj.getClass()).getName() + ".");8 G3 R4 l/ Q/ n
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());( I5 F4 O* P; y0 m
System.err.println("The process will be terminated.");
+ ?* `: }7 h+ o1 {" Q System.exit(1);- ~" u5 m% d5 _1 k& L
return null;- i f2 U( C5 r) Z" S! Z: L* T/ |
}# r& M: D- ]7 \" J2 H: }! U& ]$ W# Y+ ?, l
return sel;/ O% U7 G3 Y. P: I8 {) |
}
$ ?; x1 w+ @9 G0 J0 A, o} |