import swarm.Selector;
( n' q3 l5 `5 _: x. I1 [
4 x8 n2 M& a) x3 Cpublic class SwarmUtils {
5 W8 H# q( x. i/ b public static Selector getSelector(String name, String method) {/ J! y9 ^ A5 h6 L- S( Z5 Q
Selector sel;
) H" T8 w( u- O, ]) }8 ?& c try {, c7 y( ^4 n$ ?0 B) K3 S! Z) [- n
sel = new Selector(Class.forName(name), method, false);' F& [) n" E% t& @
} catch (Exception e) {7 U8 n. P' `4 s$ T! w
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
I2 n$ r; J0 X# u" l System.err.println(name + "." + method + " returns " + e.getMessage());
/ V2 Z. v) k6 P- c System.err.println("The process will be terminated.");
0 h3 h! J) S/ a* O System.exit(1);9 x+ w {; U8 M# e2 `+ c8 e8 k
return null;
5 K1 R' ~7 J8 ?' }8 T }) X2 c. m3 X- f6 S8 q0 U* ~
return sel;
& f) Z0 j8 [2 ?( \ }6 M4 E7 x8 @9 L3 b5 Y
5 a5 ]7 m5 q6 M9 m public static Selector getSelector(Object obj, String method) {
6 A ]! _) G# { Selector sel;
: g3 a9 i! g+ t' }% z try {( \! Q5 H. ?) |. W
sel = new Selector(obj.getClass(), method, false);
+ F$ ~9 w/ I/ q, E9 n } catch (Exception e) {
# j: m& m6 M$ A+ C% y2 Q, v System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
9 k5 m5 T* n& |' k; C. ? + (obj.getClass()).getName() + ".");
) _3 `5 A7 H9 h& [0 ?1 k& a! s9 x System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());: s6 q; `9 d. [" Y2 k
System.err.println("The process will be terminated.");
$ }: S: r6 b' m$ A. W" z0 |+ N System.exit(1);8 |1 T8 k7 e4 t2 K1 l4 y2 x
return null;) n6 \8 {( C. k
}% i' V5 X& q- M6 X
return sel;
+ m4 \7 h$ w3 k- p& T$ h: M; O }
( V- Z9 u7 y/ j+ f8 u/ A' G} |