import swarm.Selector;
. y$ r4 m) n* [7 D' j
( ?* i; ?, T" t# M8 h9 G' D' Zpublic class SwarmUtils {0 |( A! ]' ~! y/ H- l
public static Selector getSelector(String name, String method) {
* R1 P7 D4 B E5 _+ K Selector sel;7 p3 \8 N9 o, M# F1 c
try {. C5 f2 t/ } ]6 K. s
sel = new Selector(Class.forName(name), method, false);% D8 b( ]/ i- u/ ~6 v
} catch (Exception e) {
' {" v( j5 G) V0 E$ h System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");( k+ r) W4 \# F& ?! n r$ V& {
System.err.println(name + "." + method + " returns " + e.getMessage());" b( i* A. |2 j( v B. K4 Q
System.err.println("The process will be terminated.");
+ g6 r; y# z; ^7 e7 v System.exit(1);
6 X& z% Z& i" s# d' S return null;
% F! ?0 ?3 H* M# K* J- g" } }
$ Q/ z( {, ?1 u. }% @& Q return sel;6 ~ Q- \* }& a) K1 B! I' V" W r d
}/ I* Y9 z& q( C& v2 `& ]( E
* |) \) v. Z. x0 L" J
public static Selector getSelector(Object obj, String method) {2 A& X6 }6 B1 v+ H# L" f8 @* t
Selector sel;
6 F7 F) A- I1 g try {8 v2 `& r6 |4 e, r4 A' p. D' g, x6 d
sel = new Selector(obj.getClass(), method, false);" j/ Q/ h- D' C6 D- I! ]$ T- c. R
} catch (Exception e) {0 M% D$ K$ m% a0 C
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "% F# _: ?2 t/ K+ `
+ (obj.getClass()).getName() + ".");8 }1 X% c' }; P
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
1 \' }/ S6 _4 Q% _ System.err.println("The process will be terminated.");
$ P4 w2 J1 n$ b/ F System.exit(1);
+ k$ P1 ~8 x5 ^5 }& F! ^) T return null;. O5 ] I& ]$ ^
}* _3 X4 g5 R; N3 \( _
return sel;
. ~* Y; C; L0 ]% S! Q( i+ U }9 Q+ S. s. ]( a2 H# V2 h
} |