import swarm.Selector;
& p; k$ E. `8 R) c
- m8 ~4 m# D1 `$ O3 G$ Upublic class SwarmUtils {
# M; @) J2 K- p6 h* m+ e public static Selector getSelector(String name, String method) {3 B" s& Y9 x' w8 j( \$ n
Selector sel;
# Z4 S3 R8 Y- n" Z& z' I# t7 u try {
! F; ]4 S9 X, f& i: J7 l sel = new Selector(Class.forName(name), method, false);
" ]: ?$ q' \& I! p8 z& t } catch (Exception e) {
$ K3 v2 U1 y0 t# ]! P. x System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");* V. L8 X( l; P0 l
System.err.println(name + "." + method + " returns " + e.getMessage());) M0 I3 c. o5 P( R4 z
System.err.println("The process will be terminated.");1 B# c. R) k2 o
System.exit(1);
) ]. ]5 b1 ~8 z, y return null;$ d' v* G2 J0 V8 W8 W2 y* B$ g
}
" L) B: W. f) X9 a5 d return sel;
9 Z& P+ D+ h7 a# H1 U3 u }* u3 S3 `/ k: z( y; ], @ }/ s
# X/ [9 q, ]. p) m8 Z+ } public static Selector getSelector(Object obj, String method) {
; m) W4 ]5 t4 {6 H8 U3 Z' d Selector sel;
+ m7 G) `1 e: a, H+ b. x try {( S! M; `7 K% d. m7 v/ o
sel = new Selector(obj.getClass(), method, false);
& Y3 t0 b' g9 n5 J a" b+ M! I( l" y } catch (Exception e) {9 y: |* B" X; U; h
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
& _/ t; f3 [8 r* W + (obj.getClass()).getName() + ".");! J6 f( z: ~! J- y0 k5 Z1 b4 T
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
$ T5 [0 I9 ~( U System.err.println("The process will be terminated.");
4 m r8 k/ i0 }( h' A0 \. v7 t6 b& T System.exit(1);' l2 S. S5 n+ O
return null;4 B" G. L7 B' S$ H* I5 J1 E
}
, R: U! l. o5 H7 [$ f% ]/ Q return sel;% a, T8 r6 O, t. ]0 O) w% i
}
: ?# n3 s" |4 r. }) l+ d} |