import swarm.Selector;+ L0 j; u' V5 r9 q! H
+ L c1 @& B5 m9 V3 {& Hpublic class SwarmUtils {
R4 v6 s. D, S5 p% E t public static Selector getSelector(String name, String method) {# `+ V( c# m. x! [0 Z
Selector sel;+ U6 U& v4 U K6 h6 x
try {; j. X6 R4 V$ U* Z
sel = new Selector(Class.forName(name), method, false);( o9 s9 r1 y1 g! s9 a
} catch (Exception e) {7 h. g, X. U! }% I2 Q
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
n/ A2 {- Q$ Z w4 j& b5 f; g9 d1 B System.err.println(name + "." + method + " returns " + e.getMessage());2 m. u7 e4 {3 q- j+ O+ a z" Y3 e
System.err.println("The process will be terminated.");5 m# Y9 g/ W, b" u; Y
System.exit(1);2 u# Y, N2 O5 Q: O: r
return null;0 [7 T4 o& A- A0 z3 R
}
$ k8 h- K5 L: K# t) w return sel;% l- O6 i% w1 M
}# g5 d- S; q2 g. X$ N
5 }% K# `# Q0 f2 Z; ^% s
public static Selector getSelector(Object obj, String method) {3 E6 N% ^. ~, R% N
Selector sel;8 d! }, [, h) ]' _
try {
( L8 n' }$ P) E5 F+ y4 A9 k7 y1 c) Q sel = new Selector(obj.getClass(), method, false);% c9 G* F; x- y: F3 D* i r
} catch (Exception e) {5 ]% d [ g y0 ?% R
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "/ k) d J0 F$ S8 d% N1 K
+ (obj.getClass()).getName() + ".");; ~. P: U! h6 g. a' i& |9 F. [
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());, t+ H# D9 t/ }6 D
System.err.println("The process will be terminated.");
2 T9 g0 b- j4 q& r System.exit(1);
8 C% b, z$ z5 @% j6 q' N return null;; ]6 u6 M& S' y. v* Z( V. |
}
; b$ M) z$ L7 U% [9 g3 J* x return sel;
! W5 L1 x: }: M; ^# D. D) a& I( l }
5 t+ [/ k- w7 I, n2 W; r' U/ k} |