import swarm.Selector;
' K; m! v v; {( u9 J
8 d, _* j+ s2 a& d3 [2 F& Tpublic class SwarmUtils {; h5 e" U" c$ A( V2 C( M
public static Selector getSelector(String name, String method) {) G5 i* b% m: P6 a
Selector sel;
' s! F1 d1 h X- w) Q | try {
! U# m% Z ~2 ?6 a8 E sel = new Selector(Class.forName(name), method, false);
4 n% G& C* q r4 W2 `- Q) o6 d } catch (Exception e) {6 E# Z! _7 o* r" l+ \; [9 _
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");& n1 y7 J. i- O* i6 b% h
System.err.println(name + "." + method + " returns " + e.getMessage());
& f% S3 i# F5 D. c8 j/ M, k8 J$ a2 n System.err.println("The process will be terminated.");
+ u% d6 j. X% R0 c! f3 V System.exit(1);2 O* h2 I' }, F, J1 e1 u0 u
return null;4 S4 h5 Q8 F1 s2 ]. Q" {2 H6 K7 s
}
8 P5 O% [2 o2 u" S8 ~$ [( } return sel;
5 U+ r P* l" z# E4 a9 T( B }$ C8 x0 D8 f" H: F8 u. [
" F) @) A' q: b2 J! }$ q. d. ] public static Selector getSelector(Object obj, String method) {
8 Z" T1 t u5 [& a9 ^) z Selector sel;
$ a! u0 w7 r" j. l0 D. o$ A! | try {, L1 S7 [) ]% `" o' U
sel = new Selector(obj.getClass(), method, false);' @' }- T& u& R- y& [
} catch (Exception e) {- D/ L& Q2 F1 h U
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "- `/ b$ ?! R/ X3 b3 {* b5 _
+ (obj.getClass()).getName() + ".");
) v5 c% ]4 @$ ~1 D" K System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());" E" P. T+ q" V$ ^& D
System.err.println("The process will be terminated.");
5 T! ~% M0 X. W& T4 y System.exit(1);- r& ?! Z, I$ R* x: N$ M! z E
return null;8 @7 {/ r6 s5 N& E, A X: P8 W
}
8 J8 e, _5 \+ V' l4 E0 } return sel;- Z: s1 [) M, L5 O, @: y7 \$ t
}( C* p* Q1 S1 Q, |, l) f$ t
} |