import swarm.Selector;
9 I; j3 L$ I8 B# q2 ?6 V8 e4 r/ A2 s; s% V
public class SwarmUtils {! }9 x" T; t) E+ K, M
public static Selector getSelector(String name, String method) {
8 z+ c6 z) G& T! ]4 n9 _ Selector sel;
$ [, t0 e; q4 a( y [! m7 [ try {4 L& n. L) L0 ~! ~4 H" o5 g$ ^$ @& C
sel = new Selector(Class.forName(name), method, false);
, v; y) z# P9 {/ k$ {7 p } catch (Exception e) {, ^8 f- _1 B% x
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
' u$ x' J6 ~& i) {+ J5 x6 o8 R System.err.println(name + "." + method + " returns " + e.getMessage());" j7 t0 J9 ~, [$ O! X0 y6 [
System.err.println("The process will be terminated.");
) ~2 n7 p/ R# s; x O p4 J System.exit(1);
/ d, @2 Y4 q/ u; d return null;
+ t5 ~& w( R/ t8 U; \# _ }
. }/ [; a, Y$ j% ` v% O, [* e return sel;" A" a+ N/ D4 H3 O$ u: ]) n1 I
}% M1 K7 n1 z( x, U6 J, s
: c, Y# t8 L+ E+ }
public static Selector getSelector(Object obj, String method) {7 H u" `3 K* H3 m5 D
Selector sel;, t* J: [6 w6 ^& j" S" G2 G& m$ e
try {
/ N0 O: c, @) n" [8 q1 [ sel = new Selector(obj.getClass(), method, false);
2 P1 j* |4 |- \! j& [& f8 W } catch (Exception e) {9 T8 Z Y9 a# V- G- z( B/ X! ^' \1 B
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
/ \* d. V% F7 Q; E + (obj.getClass()).getName() + ".");5 W; B4 x1 ]( p) }; o% N
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
$ j, L# _+ n" E& s% c5 O0 L- j System.err.println("The process will be terminated."); Q3 R7 N/ y# X' ~
System.exit(1);* b1 r" E9 C! b5 f x
return null;
6 _0 X6 X4 y1 w# N }! L1 H8 `" o, y7 K8 T+ i v/ w
return sel;+ m1 E1 x0 g0 H( v( J
}6 x$ O# }* L6 G
} |