import swarm.Selector; H7 s; }6 S; J6 ?0 F6 A, D
/ R( ^, s' y+ G& I# o4 l% ]
public class SwarmUtils {
1 t) z/ j& }- V: E3 t0 |. ? public static Selector getSelector(String name, String method) {7 ]0 F4 w7 I$ X) g" r
Selector sel;7 U- T; j3 x1 m# y
try {
3 @: O* c9 J% c sel = new Selector(Class.forName(name), method, false);' G' j$ H/ w% Q- s( u* v
} catch (Exception e) {. z, M; [: _% i1 u; {, J$ G
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");. F5 g2 v! Q6 ~1 r5 A6 b* k8 D
System.err.println(name + "." + method + " returns " + e.getMessage());
6 t' T2 H; v2 c System.err.println("The process will be terminated.");
5 x0 h3 R8 t5 l4 o3 G System.exit(1);
7 b" i; I/ T0 T return null;
- e0 N( e/ x5 E9 C }9 P9 `) U& F; g: v* r+ _& W, P
return sel;" \ I) L. k1 t7 q
}
# p! X+ Z# h( k7 s4 m- @, H/ A5 L6 d$ k* m# `1 d
public static Selector getSelector(Object obj, String method) {3 D9 e4 L7 l9 N3 U9 g. L
Selector sel;
, ?" f8 c* m, R9 \6 b- h try {
/ T& i. r& ?9 W/ H3 N sel = new Selector(obj.getClass(), method, false);5 Q; T& n8 H6 c% M% n1 [
} catch (Exception e) {0 z& [! [& q' y
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
: b5 o5 D. ^2 L + (obj.getClass()).getName() + ".");
/ }3 r8 S& [2 } System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());0 u8 }$ M' w3 C+ D% \
System.err.println("The process will be terminated.");4 i* }" N$ G9 C4 m9 q: K3 `
System.exit(1);
% o* n% d& j* a* Z5 C9 e) ~5 b return null;
5 |% j4 T) d0 N- p1 A1 ^# j: R: B }( Z, E: }- }) j3 C1 q/ X* Y8 J
return sel;) D+ K5 S1 R' D$ `' T7 N
}
; Y& X" z0 e' N0 Q9 S$ k} |