import swarm.Selector;
& ~( ?/ e: W; W: A# S8 b+ Z9 i6 \6 O5 K' g2 g8 Z0 A4 [4 I! ]
public class SwarmUtils {5 X/ S0 _5 n7 ^- x- P" W0 L7 s
public static Selector getSelector(String name, String method) {
' j; q/ h* C; d2 s u# n Selector sel;0 V( ~# ]- ` A& ~/ Y z2 e: k
try {
: t- z7 `" h" i5 ~$ z \% R- ? sel = new Selector(Class.forName(name), method, false);$ ~. l& y0 v5 C1 Z& {2 X/ }
} catch (Exception e) {6 a! }2 w' B8 r3 D! p& y! ~9 K
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");+ z, O; z9 ^' W8 A( l( \ A
System.err.println(name + "." + method + " returns " + e.getMessage());# ?0 O& P- F: Y) X V& c
System.err.println("The process will be terminated.");
+ O; f% }7 l5 X) c System.exit(1);
. n# t% ^; r6 T" D return null;
: B H. X' M9 Z) E6 S }
. s( `; v9 {5 C3 K return sel;
5 j _2 o/ N% x }
8 I8 r: |/ {+ y- g
8 L3 E; q: R# ?4 w* X! R9 i0 G public static Selector getSelector(Object obj, String method) {
1 y! J* w' T$ ` Selector sel;
e( Q/ Z7 w3 A- ?2 o try {2 K) w; n' |" |
sel = new Selector(obj.getClass(), method, false);7 B5 n- } R6 z; m4 G
} catch (Exception e) {$ v. P+ m4 y. _" N
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
) e4 C: [, c( A! r$ r1 Z1 }" `2 Q + (obj.getClass()).getName() + ".");
1 ?( o2 r. t, v q9 v2 g System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
& U# q$ S& { Q+ {6 m" _8 I% B2 ^ System.err.println("The process will be terminated.");
+ u7 g7 c8 q* y2 P, u System.exit(1);5 P- @& M2 }( v. T. I: _6 t
return null;6 e1 C8 `+ [, l& ?5 M7 S1 _1 h
}4 u0 j/ c" T' W+ `: p
return sel;
% e5 q, [; ]8 K }
6 R5 c8 X% t9 [} |