import swarm.Selector;
+ o/ f1 @/ K1 e% S) S7 W* Q7 V) w. d& e: t5 W$ E; E+ `
public class SwarmUtils {8 Y( c' \$ {& h
public static Selector getSelector(String name, String method) {
# z9 g1 F) L' ~+ i9 p; j8 f3 S4 Z Selector sel;
0 [+ v% g& y/ K/ g try {& |) r5 ~/ I! @; r
sel = new Selector(Class.forName(name), method, false);
) G% V/ L4 b. d" _3 Q# m% G a } catch (Exception e) {
& R: H, L- m0 J& _ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
) W; ~, X, T3 Z3 m8 x' c6 |* v System.err.println(name + "." + method + " returns " + e.getMessage());; s2 T- g3 S5 h% r/ P1 `8 y S
System.err.println("The process will be terminated.");
0 T: L$ J& l- L. d5 L System.exit(1);
2 l6 n* }2 u8 Y$ F- Z9 [ return null;
! Z1 Z( `3 S- Z* N/ G" S( _9 A }
8 X8 y2 c2 g5 r8 I, {$ A) |3 n return sel;
; l: i, s& v1 V }
" M9 _$ _* B `5 U* @! x
{+ [7 e) K3 ^( t; V public static Selector getSelector(Object obj, String method) {. Z! y0 \9 t# u) O
Selector sel;
& ]; c. T# a! A7 T try {
4 b5 j, g T. A/ ]! q) I# k. k9 g sel = new Selector(obj.getClass(), method, false);
8 |5 I* e- e( } } catch (Exception e) {0 V4 z3 _; v C% s& J
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "5 n, h' q/ ?/ b; m q0 }' C
+ (obj.getClass()).getName() + ".");
! p- V# ?5 m% M$ c System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());: k) ^0 f% K, A' v( |# H
System.err.println("The process will be terminated.");
: [& d# I/ K: O" x+ l System.exit(1);
; A3 @: L3 l4 i. T3 m return null;, ^. X7 o+ G3 @% @8 E4 n
}
3 v8 h. T% v& p return sel;2 D: D) F1 [9 h3 V
}7 f9 D1 [7 r) p D" N
} |