import swarm.Selector;( x1 ~8 ?# x( y4 A/ s& i( {0 [
1 {- O% K9 w3 S% l3 ~% Spublic class SwarmUtils {
6 Z" d. C- L) w, w6 s. U7 x) J public static Selector getSelector(String name, String method) {/ H. j7 t; ^& L2 |
Selector sel;. } C& U- ]! [4 n
try {8 L' C9 @4 r; v4 n: M5 l
sel = new Selector(Class.forName(name), method, false);
6 z6 E \: R) R) F7 |+ T+ P" a } catch (Exception e) {
* L' F n0 s1 B' q System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
* Y5 K! N# t4 V+ D I0 e* V System.err.println(name + "." + method + " returns " + e.getMessage());
1 F. r+ _& O; d% | System.err.println("The process will be terminated.");
4 V; f& P) u) T0 k System.exit(1);* j- O4 G- z/ e
return null;
6 P! u b+ Y9 M( D/ D$ o6 x; C }" I' B; W( ?6 X0 U( C
return sel;: Z2 h0 L _8 V( S" d
}
" d# t2 u: |- m$ \/ Q
) r# Z* D9 m' _+ x" L" R public static Selector getSelector(Object obj, String method) {! L3 p+ y5 ]$ Z" |& R
Selector sel;& ]' Y A, D, \& \
try {
7 e6 ^1 B @6 F. d6 W sel = new Selector(obj.getClass(), method, false);
' \; T& ^" C3 y9 x7 B/ z2 Z. R" {1 c } catch (Exception e) {& b- l4 p: a/ [% D$ Z0 e& q) _
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "4 L ~9 Z# E& P8 Y3 o3 P
+ (obj.getClass()).getName() + ".");
9 ^6 e+ z9 u1 p2 L: n) Y i- f System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
* S, o, F1 E) o3 o, _8 Q System.err.println("The process will be terminated.");
' P) N+ m% _+ M9 x X System.exit(1);' @ e F- {& I" F5 H6 G' C
return null;
0 u* Y& a- ]$ B. K7 k( h }5 _, ], X* {. f9 T% K# u2 V' ~
return sel;
' L: c; p! Z- t& h- }: R1 o }5 }; L& j9 ~3 L
} |