import swarm.Selector;
, \% ^ G. E2 D: K' i
5 c5 ]) S" [3 A/ x/ a, Rpublic class SwarmUtils {
; b3 Y# n7 C- V- A: ^ O public static Selector getSelector(String name, String method) {4 y5 k0 L5 u, P$ F: r: m. S* f
Selector sel;$ M- T7 k9 K8 R Z M: |
try {% }5 D; w: M' ]" A4 }" @- l
sel = new Selector(Class.forName(name), method, false);
3 M5 l: l! o( C$ G+ D0 T: {# W } catch (Exception e) {
9 Y6 s) `( A; O# ~ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");* C+ I% I1 E$ `8 n l" Y
System.err.println(name + "." + method + " returns " + e.getMessage());6 d9 a9 {$ r; I( s% N; G, Q
System.err.println("The process will be terminated.");
- n% P! T; K) z7 @1 b System.exit(1);1 l5 C6 O% m/ s6 g i, N: u0 s
return null;0 e$ f: O9 F. n' Q3 ]6 M+ G
}
- i9 ]3 D$ O# Z/ |% n- h return sel;
" G7 F X0 _. c7 X. v4 y' { }
2 l9 h" N' G4 P {2 a7 F
. W0 I; l) s# C+ F: ` public static Selector getSelector(Object obj, String method) {4 _7 z# R7 ?+ T4 }3 \
Selector sel;
3 u# D7 U) q* i+ v0 s O try {
" X5 E3 o7 \ Q) t- Z" j* x sel = new Selector(obj.getClass(), method, false);
8 @' w: c/ Z- ^5 M8 N } catch (Exception e) {( A4 u' H6 y8 o9 z2 N+ D& b
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "' i' ~5 s6 y$ H8 \. w
+ (obj.getClass()).getName() + ".");1 ^, T) O0 m. o2 k9 p
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());8 L2 n: Y+ A) _. }+ M2 K7 C1 A- t- O
System.err.println("The process will be terminated.");
& ^( g2 W4 J8 n6 `' D' ?+ f& S System.exit(1);
0 c; p- J( C; k return null;
, {& p7 n. R0 ~* }5 z/ E }7 R5 C6 u7 S% K& F, i
return sel;' \. n9 S8 u$ Q9 U2 `
}5 d( O5 d+ I0 j; @. i$ A$ b! z# Z3 O2 S; ~& H
} |