import swarm.Selector;
* c* d* p6 i, ?
0 i5 p9 B0 E. ]" s3 A+ Npublic class SwarmUtils {7 V L% R+ F+ S' [
public static Selector getSelector(String name, String method) {9 f/ [/ O& o8 ~$ Y; `
Selector sel;9 M/ P2 E" N5 _7 a
try {
4 z1 c& t1 L z sel = new Selector(Class.forName(name), method, false);/ z e5 |) f7 e1 }
} catch (Exception e) {9 C( L3 O0 |& x
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
: [: b. J9 R0 ?; i9 G System.err.println(name + "." + method + " returns " + e.getMessage());" c3 g4 y) q2 ]
System.err.println("The process will be terminated.");5 r- p3 D# i$ H; ?) g+ ~
System.exit(1);
5 y" q2 `$ h7 Q4 x" R0 A7 ~/ J return null;
6 L- t% ~1 C- x0 k/ C1 q } Z6 Q) m- X4 L, ^( d) A
return sel;
0 I, G% E% V& _/ U- n }
5 `3 w$ S$ R9 B) P$ u$ a) i0 J9 |* A1 { N. h3 r; ^/ }2 f8 e
public static Selector getSelector(Object obj, String method) {
$ L0 o6 u/ v, Q9 i# U( W7 |7 G) M Selector sel;
' G' B% Q: C% j; C try {9 c B# m0 V+ H0 J2 K8 r: Z
sel = new Selector(obj.getClass(), method, false);
. M: w1 J$ X; v% C, I. Z: Y } catch (Exception e) {% s$ I B3 A& l$ [) g3 x0 W
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "& ~6 i( l0 u/ h( H C6 B/ A; W
+ (obj.getClass()).getName() + ".");
* Q$ ?; X; F6 `* t3 c) v' @ System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
- e) h2 ~: d3 M$ _# y# [ System.err.println("The process will be terminated.");9 f. L9 _( z/ c- W
System.exit(1);9 G9 p; Q8 H/ g. I7 N! r! O8 D
return null;
% O) ?5 Q$ l, z8 V2 c V }
: j- |' r" M: H! M7 B return sel;
, r# ?6 M+ q5 y }, K2 x; F5 I# V* _7 [
} |