import swarm.Selector;
p/ x$ e# e+ C0 `5 E9 t- {4 X
' D7 {9 G) y" Zpublic class SwarmUtils {1 M9 {2 I; V: G# a0 J. _
public static Selector getSelector(String name, String method) {
9 X4 F1 G5 j2 K7 j2 z Selector sel;
& p* v* `2 q# w8 U5 ~' u& j try {
" o! S/ D; {, n sel = new Selector(Class.forName(name), method, false);
! y/ K3 v5 w+ l! p } catch (Exception e) {4 O- Z: d" e: H( M
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");) y8 V/ i& A$ s$ K8 V
System.err.println(name + "." + method + " returns " + e.getMessage());9 e) ~. U9 T9 }: J
System.err.println("The process will be terminated.");
, v. P8 M2 v! l D0 e System.exit(1);( A) D( {# m d% r/ i
return null;
1 n( E1 q9 A) a, r5 r# C8 o }
! q0 T1 g: i ~) P return sel;
+ Q( R, K: I# ` }) s6 @1 f% ?# k& o# F7 B
# p. T' _0 d' o) G4 n public static Selector getSelector(Object obj, String method) {0 `- q5 q% T: R
Selector sel;
$ S8 `7 z1 ?! {: E8 ^ try {; f2 P; s# B3 k5 u I
sel = new Selector(obj.getClass(), method, false); O$ }1 Y0 q) y t
} catch (Exception e) {
1 g: k$ L8 B- Q% E3 ]& { System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
s S9 }1 s7 Y% l) M$ B' } + (obj.getClass()).getName() + ".");: l7 R% B2 S- [$ I- K
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
" \( l" ?) o" t8 {' _ System.err.println("The process will be terminated.");% S% `0 _3 Z O/ m
System.exit(1);4 |' g0 J/ z) B% X3 |
return null; }/ x- {" J8 }0 \3 c2 g6 M# B9 o
}+ T- ?; B! K& x
return sel;/ w# B) Q" h( @( @2 z
}* _! w6 R* o8 n0 b' t4 K
} |