import swarm.Selector;3 s* k' z4 B/ j- F: [; H
' j5 O3 k/ I4 x3 c. n: v
public class SwarmUtils {: K+ N) d k0 w# P0 S
public static Selector getSelector(String name, String method) {
6 D4 b$ F; I; G- j& G Selector sel;. g7 P/ a' n9 L: y5 d
try {
$ `, w! w; p8 s/ |' l sel = new Selector(Class.forName(name), method, false);, [& U& x7 a6 a" O2 F& ~& y7 N
} catch (Exception e) {
1 D2 s9 F2 p0 U9 ?+ o% ? System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");; o( T8 \" g. t% `- ]
System.err.println(name + "." + method + " returns " + e.getMessage());
% X% V* K: }' _$ E& p) { System.err.println("The process will be terminated.");
5 e, Q9 v& @5 x5 O$ J System.exit(1);8 s: v8 V* P7 v G. A; e2 l
return null;# p( M" t5 P: {
}
- c4 f( {( k/ S$ x/ K% H return sel;
; ?: _, A5 z& k+ ^ u }
! j& x% o* A e% n) H1 p* l3 N5 e( G# l; T( }( P) h8 V- B
public static Selector getSelector(Object obj, String method) {
( Y7 h+ z8 m' C6 e: g, ^ Selector sel;& ^# t4 g" y9 Y. j
try {7 {7 `, s* k5 P* s* _
sel = new Selector(obj.getClass(), method, false);+ p' K6 I1 t# x: ^
} catch (Exception e) {6 V8 u% M* B d) [9 N+ ?4 p$ `
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
) r1 N+ ~/ X: `& b0 |( T! a + (obj.getClass()).getName() + ".");! }7 z$ s H% r5 o1 u5 ~ @
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
p w4 h3 y9 k6 c o: m System.err.println("The process will be terminated.");$ H. |6 n# R5 D$ e: [/ }
System.exit(1);
. f' l/ }0 C& F$ s return null;
) J/ C3 J- q8 a' d, @" N+ p% ] }7 J9 ]" u; n- t( j5 h" t
return sel;
5 D2 y% W# L0 K! d- a6 m }4 {' w* y# M3 H" O* A2 O! x
} |