import swarm.Selector;
: \8 [2 _! q% b
( \4 z3 R' f; A- Z7 Ypublic class SwarmUtils {
. M& U4 T( @( m: j: `! G public static Selector getSelector(String name, String method) {
' ?* ]- F+ O7 I9 g Selector sel;
1 T [6 H9 v/ L. t' e& ? try {" t) F+ K0 ^$ U0 |7 K' |
sel = new Selector(Class.forName(name), method, false);3 U, `2 r& s K# y
} catch (Exception e) {
6 w. X1 w. D. m! H9 u- y9 l) L System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");& L9 X* @' ^ e$ ^4 I3 g3 o/ {
System.err.println(name + "." + method + " returns " + e.getMessage());: j: O1 B8 q2 a( o+ N+ C V
System.err.println("The process will be terminated.");
0 v0 L4 j4 }) t2 F, B( n4 u System.exit(1);
. o2 p) ?. s3 Y2 k- o* H. g return null;
; ?/ v ~( ~' j7 O+ C- p }
( o& }8 d; @* _1 R4 e7 A% }3 _- } return sel;
. k Z! n+ d |+ r: T: @7 j; @ }4 V1 v% g& @6 Y/ _7 d
, E1 r7 @3 m+ U, G public static Selector getSelector(Object obj, String method) {; z* I9 |' S9 ]# r5 J( G9 h8 V- d
Selector sel;
; t- U0 ~+ r" a4 W( n7 `' L( k6 j try {
* {6 ]0 x( y6 X. A$ C5 r sel = new Selector(obj.getClass(), method, false);
" V* t+ j3 a3 c } catch (Exception e) {$ X4 `0 b- s) ~
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
1 S6 |7 j7 W' x + (obj.getClass()).getName() + ".");
Z# H2 M4 H+ Y, I% S4 j' ~$ [ System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());- `" l; G2 H+ U6 I
System.err.println("The process will be terminated.");1 D1 G! z* @3 S
System.exit(1);
) w7 ~7 {5 |) Q; ^( | return null;
" [: q/ p9 V2 T }5 N6 J- v1 ^) _: y2 w; R+ g
return sel;
2 l' Q9 _/ k2 e* K; s8 ?" E2 a }+ W' S% a0 f% n9 J: V+ b
} |