import swarm.Selector;
, H6 f3 B) ~* E" \& L* A( B; s8 O- W3 B W) {
public class SwarmUtils {
, F# _, h' s4 A. e4 T public static Selector getSelector(String name, String method) {
% e; m+ p% M2 a6 n Selector sel;
( D0 ^, q' i f, T6 f8 r! L3 z9 J, G try {8 b$ I7 z# ?. m2 l F- g8 m
sel = new Selector(Class.forName(name), method, false);
$ v0 u; C; ~* `% H u } catch (Exception e) {( x7 w5 r. X( I6 Q
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
& F; b! z! o- J5 [6 n: a t: [ System.err.println(name + "." + method + " returns " + e.getMessage());3 N* Z" y0 [2 |/ Q& B; _
System.err.println("The process will be terminated.");
: t% M3 ]/ N6 y System.exit(1);% m1 _) p6 \' b0 M: E! j) t3 r9 Q
return null;
1 \2 [8 I4 d" z+ }6 T& N' ?. _ }
9 M- f- F* j7 M4 n3 B4 A return sel;
/ ~) F( ]7 I& n6 O+ |, a }- T4 }: L! m% d2 g n" |
9 X7 Q. e4 @& u: I& z public static Selector getSelector(Object obj, String method) {
, u. K/ Q9 t. [; P& I. K- q4 X Selector sel;( a, a, n6 x2 Y7 W6 u
try {' r W2 `5 f9 n% t, _$ @
sel = new Selector(obj.getClass(), method, false);
6 x& N3 ? S" P: z9 N } catch (Exception e) { |5 }' j4 B" G) g& ~: V/ _% Q
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
8 C3 m2 g: [; J: {0 d, ]0 T' X) F* _ + (obj.getClass()).getName() + ".");
3 f% Y7 p( ^ R3 p7 R z w# ~& x; `% u System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
" V' W" D. o X L& s System.err.println("The process will be terminated.");% B1 J) d4 }+ N, c1 F
System.exit(1);2 k: l a0 S3 {, y: c! k3 I# F
return null;
3 _% [" ~- D- i" y; Q }
: K4 d4 U" y4 }; r3 Z# x+ \ return sel;) D& H5 {/ h% j5 {. i8 Z
}
% v0 ^6 C5 ~: j* [$ W} |