import swarm.Selector;
' A0 ? j2 |! k% d. N0 ]- Z2 u+ M; G0 O4 ~9 {) i: v
public class SwarmUtils {
7 ?+ q( |" T7 Q- O% l! Q public static Selector getSelector(String name, String method) {8 k3 C/ R9 M. Q6 H, C7 P
Selector sel;
& _. A2 X+ ]3 f+ B try {
5 ]7 x$ k# Q9 w3 z sel = new Selector(Class.forName(name), method, false);# k0 Q9 T- A4 G$ e9 ` x0 _* Q
} catch (Exception e) {) P$ O8 B7 S9 N0 v' `+ Y5 ~0 s
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
9 Z+ {! v5 l) X& f4 } System.err.println(name + "." + method + " returns " + e.getMessage());
. U. _0 j. D+ l System.err.println("The process will be terminated.");1 e/ R3 W8 o8 h, y1 R
System.exit(1);
: v# V, x* N( J0 M. m return null;
8 i. V# K. E. N1 j7 k+ E }
3 |7 p0 p$ e6 p" ~3 a( J' U8 u/ G return sel;
^0 ]7 G1 ?- v7 |% N H% ] }- o! ?; g5 P8 r+ f4 p; M
1 p, k; v" W, n2 ?4 h7 \7 R' H public static Selector getSelector(Object obj, String method) {* z4 P4 u+ V U' m
Selector sel;, ^4 p- F# J# t5 y" y
try {8 e, U; X0 ^2 s$ m& T6 ]
sel = new Selector(obj.getClass(), method, false);
; [; s5 C' r, k# S$ y# M q } catch (Exception e) {
+ K2 L: I: e8 {, k1 n System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
$ ^& p: ?- T4 w9 @# ` + (obj.getClass()).getName() + ".");
, {! R6 @; Y2 R5 K, c7 d System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
" ], j5 |3 c' i1 \' ^: s3 A+ W! @ System.err.println("The process will be terminated.");
5 L8 k7 U/ a; e, u System.exit(1);, ?# ]3 {6 S( Q0 I' H* W
return null;
) P& h) D3 }- g }5 W9 P8 ~) T1 V8 U% f
return sel;
0 [/ y) P' C; \& g }% e' k( C% I; D2 g5 ^
} |