import swarm.Selector;" a' I4 F9 N- [ h
* m! J' y1 _$ ?' @. S S) o' p, wpublic class SwarmUtils {
4 F- p. v- S" o" H public static Selector getSelector(String name, String method) {* u5 V6 I! m0 u. `" a0 G; V+ E
Selector sel;7 Y4 c6 Q; L" m( T
try {" p) \( o4 e! g7 c) e! l8 c. O
sel = new Selector(Class.forName(name), method, false);
1 Z) l% Z# i/ K } catch (Exception e) {
" I8 X1 K. D* d9 m) Q* b9 o; X System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");0 R: j& {% E! Z0 w( ^9 r! u% R
System.err.println(name + "." + method + " returns " + e.getMessage());) ?7 a% Q2 n+ m: @, |
System.err.println("The process will be terminated.");
* ?. g: ?, J; p k: b8 r5 [ System.exit(1);' ]; r6 Q' g8 {) w
return null;
7 D+ ]7 } M. ]3 e: W }6 Z9 v) x2 f E! z- P
return sel;
+ N9 n3 i& g3 U5 e1 a) V }
; l* V- {9 g1 E: W h# q. C
0 o6 ^3 A' c, S$ p7 u! r) } public static Selector getSelector(Object obj, String method) {
. S3 h* U6 ]% f/ U+ T Selector sel;
: H- Y6 r( B( i' J, F try {& q* M* m7 b% q( D) j+ \, i
sel = new Selector(obj.getClass(), method, false);
$ n4 u* R( }; H) u3 P- t% E A } catch (Exception e) {. }; X2 r% `! s8 w8 L2 F5 b
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " J% I5 Y5 i5 \ |. D7 q0 D
+ (obj.getClass()).getName() + ".");
: J* f1 i6 v% |+ Q1 u0 @ System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());& ~* K- s, K. K8 ~4 q! {" A
System.err.println("The process will be terminated.");
+ j$ C! Q6 b' t* Q6 C7 Q System.exit(1);
2 i" p" L& E" B) T, _* Z" c9 u5 l. Y return null;$ J2 x1 ?' |2 W: C& i& c) ]$ d
}
" `. ]* g+ D, m0 B9 ?" [, i! V return sel;
' Y3 P6 {; N6 g( f! ~2 C2 v } g6 Y2 u# Q+ ^) U3 Y7 B
} |