import swarm.Selector;
8 W# F& [$ B d6 t) |; R% r& n, `. y* v3 `, S: p9 P; m
public class SwarmUtils {
) s% B/ b) M) } public static Selector getSelector(String name, String method) {$ s9 O% }" B3 ~+ `1 Z7 [& [
Selector sel;4 t+ q/ S. W, o$ Y9 l( R2 e1 n" j
try {8 |& V/ U/ b( n6 ^/ R+ i: i
sel = new Selector(Class.forName(name), method, false);
; d, J1 o7 G9 _. _: B& Q } catch (Exception e) {( e. c \$ {1 n. f) h
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");( O! K: X3 o, S0 M4 D
System.err.println(name + "." + method + " returns " + e.getMessage());# L, v/ v$ V) S) m, J: P
System.err.println("The process will be terminated.");) I! f" Y4 \5 w8 @; Z% K
System.exit(1);) k6 g5 V$ v7 q& C! O4 m
return null;. n- H8 p; }& F
}% K) @4 z" H7 M
return sel;" K, I4 h0 o* C' K) ^7 H+ @$ A
}5 ?' N k7 s+ s# K3 ^& F
& ]2 z0 @' o) Y5 J1 \% [
public static Selector getSelector(Object obj, String method) {( k q1 h/ h' @% ]7 |
Selector sel;0 I% e- F4 z2 d- b3 U
try {! l# \7 A' l0 ]
sel = new Selector(obj.getClass(), method, false);& v0 Q1 m% ^7 Y
} catch (Exception e) {
. P* ]8 u9 K! }7 ^. z7 a/ ^2 f s System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
- w3 B! A+ ^9 @; B7 L4 l) W* c/ ] + (obj.getClass()).getName() + ".");
* `% j# S O: R5 |; M& O; l# q System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage()); ^) `6 T1 p1 \7 h% K$ ^0 Z6 |& M
System.err.println("The process will be terminated.");4 W! E/ i0 b- m, e6 H
System.exit(1);
+ C3 Y1 M: J7 O3 k0 N5 q return null;6 h u. `. D& l4 H( k8 _1 d
}7 ?& `7 R& v6 R) p0 d
return sel;
9 k1 l- |! Q/ ^4 k3 C }* b3 ^' t: N K2 o6 R T$ G
} |