import swarm.Selector;
" F; ~" r/ _5 [7 d0 o8 w
e j) x H6 C3 Ppublic class SwarmUtils {
0 A/ W, I/ c+ d( b. D o public static Selector getSelector(String name, String method) {+ ^% x3 X+ @2 C: @6 s3 R
Selector sel;
1 j+ M; G0 `, T8 M; N# L* s try {3 b8 Y) K3 f# a# F" l# X! ~
sel = new Selector(Class.forName(name), method, false);
0 ^; \# n; }- V2 f$ Q1 _, w! `! R } catch (Exception e) {
; |& d5 b8 F* ]% n6 t System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");( @% ? f4 f! q0 ?. M+ {! V
System.err.println(name + "." + method + " returns " + e.getMessage());9 z1 U7 \9 u4 S1 ?
System.err.println("The process will be terminated.");
0 h, K; i% P1 t: p- x3 x. O4 T System.exit(1);
' s# h |% Q! }' k$ R return null;
$ W% S# e% c+ h% I. b* C: S }1 M$ R# R7 m |* X- \* ?2 q
return sel;
8 s9 f: S6 v. h. d }
" J9 s+ i; c( Z# N* y) J8 @& Z) B* [( P" ^5 N p. D
public static Selector getSelector(Object obj, String method) {) o) C7 g E+ v3 r- U6 a) \
Selector sel;( H) R9 j5 y) F9 o& r; B+ ^2 M4 B
try {, y: n5 K7 p/ l. i
sel = new Selector(obj.getClass(), method, false);; K7 ?( ^/ G3 h7 E
} catch (Exception e) {9 a9 {, a" l9 j2 q1 l. X9 e
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
0 G: X$ {; n ~8 O4 O1 d + (obj.getClass()).getName() + ".");% u9 @9 @& k9 x+ t( n! }
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());' D* ]' j4 }2 x$ `6 `1 q
System.err.println("The process will be terminated.");' R% B, C! Z9 p' c) d3 X: T: f
System.exit(1);# {2 F, ^/ L0 [: e5 a9 o3 }
return null;
7 F, ~2 O: m% S9 C/ s: x }/ w; R3 @% N# C4 O+ |" | b) @$ \
return sel;& g. `4 [8 m+ B0 Z
}# W3 _) e/ W: _9 W- U# ^- W' Q
} |