import swarm.Selector;
- a8 S; b9 i# D: ~7 U) S8 e
0 w( u }2 y" [# v) H7 qpublic class SwarmUtils {& [5 ?# u O9 C0 b. ` c8 f5 x0 }
public static Selector getSelector(String name, String method) {
- p$ F% ]( L* ? Selector sel;
6 l: X( D0 x. m' S. ]1 \" `4 z try {
7 n* F. P& c+ U+ v% c; M sel = new Selector(Class.forName(name), method, false);
$ L$ [9 c* Q: b& u; y9 |# ] } catch (Exception e) {
B7 ]: K$ c+ z6 T" T System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
8 k: l+ G6 K; E+ h) z System.err.println(name + "." + method + " returns " + e.getMessage());. @+ J1 A1 x; w
System.err.println("The process will be terminated.");
( n4 Q: G. J S- O8 P6 u3 M! ? System.exit(1);
6 I) b2 _2 J, f. h) }5 F0 g return null;# k8 I2 g9 f5 ]8 c. `7 F9 v
}
8 O) B7 ~; t2 E0 n8 J2 E return sel;
& ?, z& g" F4 Z8 q( d( B }4 H$ m; M$ b+ q) q. b
9 q9 s, Z& m5 j& R. \ public static Selector getSelector(Object obj, String method) { _3 V1 z$ f! y' n' d& F
Selector sel;7 S2 Q& Z7 ?0 v! z# e2 R! S# e7 V
try {" z6 F U; p/ T% U6 d
sel = new Selector(obj.getClass(), method, false);
- T, v+ \# H& e5 T H& _ } catch (Exception e) {
v/ f* K8 W+ B' z; Q! ~" D System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
8 X- o& o( P! x: F$ _; ~ + (obj.getClass()).getName() + ".");2 s+ a: ?9 C/ F
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());% ]9 L# c7 e6 ]( h- r: D
System.err.println("The process will be terminated.");
& E: q( D; ?: z8 s9 B; Z3 K6 [ System.exit(1);
' a4 g3 ?- p% X" g' f$ e' C) g) S return null;4 t( R* N+ K& A6 v
}' j) {4 r9 p. k' H& J
return sel;0 Q4 { j4 |1 T: ^7 P( `* O4 Y
}' Y( z/ [' ^; N- I" y9 C
} |