import swarm.Selector;
e( A2 p. } q" [) A" ^. P- H% m9 ?# X8 D3 a
public class SwarmUtils {
# _, w; V( n7 k6 ^' k public static Selector getSelector(String name, String method) {0 l) m- J* ?& h' I5 q
Selector sel;
$ w$ o1 e8 U w" E$ a try {: Z" `' y, _6 z+ l p
sel = new Selector(Class.forName(name), method, false);
% o y6 V ]9 w* a& M% \: b) L } catch (Exception e) {8 B" u" L$ r7 J a6 c
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");9 ?# K4 C) Q; N
System.err.println(name + "." + method + " returns " + e.getMessage());
0 u+ J6 P G, {9 |& o& x0 D1 s System.err.println("The process will be terminated.");
8 P w9 h) _( v& F$ X. Q1 v System.exit(1);
. p9 p" O$ ?& z* f3 p0 h return null;
& \$ y- C |2 U1 m) r: T5 ] }. v3 N1 R5 R% ~' E6 }
return sel;, [/ Q2 r3 V" t6 \' Z% o
}
+ ^# |( U2 f. u6 H4 t. w- I' b, \5 O$ \% j' \+ z
public static Selector getSelector(Object obj, String method) {" B. b9 d' j( I" Y: @9 U
Selector sel;3 ~+ G" g- b: w( A' m) i# E
try {) Z3 g2 ?: y: d1 s, G+ c
sel = new Selector(obj.getClass(), method, false);
# R& J9 [! s! k7 Q% \; f8 D" i } catch (Exception e) {0 Z( V, l) W6 O. K/ s, g
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "7 T; }. W$ s9 C5 _4 {
+ (obj.getClass()).getName() + ".");
+ ~+ ^! D& F1 K% { System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
& n5 Y0 w4 l; j' ^9 T; C1 M System.err.println("The process will be terminated.");! C9 i5 O% ^+ D$ D+ X( u0 p
System.exit(1);" I1 Q; o3 s9 ?$ f9 d! j1 p
return null;( I2 y1 ~1 u" [* R$ p
}7 e! R. R9 ?+ N: g& g f) r; a
return sel;. g. c1 V8 V% ~% @& N5 G
}; Q5 Q! M9 ~5 x
} |