import swarm.Selector;
0 @( A0 M! d6 P& \' G
* ~% r! N: I% Z! b; `public class SwarmUtils {2 r) e5 Z, d; ~6 u- n1 i4 @4 p* F
public static Selector getSelector(String name, String method) { g c# f4 A: d, D( c
Selector sel;+ a0 ^- R) Y" Z( a& M4 ^% U% S( _
try {3 X% x: k# p5 i7 j7 U5 D! k
sel = new Selector(Class.forName(name), method, false);. k* m/ }( j$ G
} catch (Exception e) { h* y5 i) l# U K2 [" K
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");) r Z: a3 W) T$ r9 @1 J
System.err.println(name + "." + method + " returns " + e.getMessage());! q) r$ X+ K4 s6 h- `
System.err.println("The process will be terminated.");. v4 M1 ~- u: D$ Z
System.exit(1);
( ], V$ k3 C% E6 y. H" | return null;4 a+ |7 W6 \# k1 m& l" G; t
}
g! T# B, K q6 e$ s; C* M2 B return sel;
; G* Q$ ?. y6 f" G! Y4 c) O }- d0 A1 c# U9 n& X. R
+ U3 X! u$ c' N public static Selector getSelector(Object obj, String method) {
6 h5 J" l3 c' H( h5 M* m Selector sel;' \* W* _& ]& T
try { i3 J6 d5 n N8 w
sel = new Selector(obj.getClass(), method, false);6 F! E$ i9 ], D/ b5 ?
} catch (Exception e) {4 K I/ G! q5 l0 J+ J
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
7 a% k B2 k" q2 T h + (obj.getClass()).getName() + ".");
9 ~& k9 M& }8 c: @ System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
) j8 [. R$ ]7 G+ g/ o System.err.println("The process will be terminated.");
- _. K1 j o6 a) w6 `0 t System.exit(1);
& L; c2 r7 K3 Y6 y7 k1 t3 a return null;0 K: o' |! z( @2 b6 H2 y s
}
# w. t5 T& Y7 z% B. K0 ~" n/ Z return sel;# @( N* _. U" D- h
}
1 f+ \0 a) q+ n6 o0 I/ w6 j# m} |