import swarm.Selector;, I: Q" {% K: k5 J, m. r' l( c' ]
/ z: @+ _' }/ `! v
public class SwarmUtils {
5 G2 `5 {0 r0 v( f' j; M. z6 Y public static Selector getSelector(String name, String method) {3 d @: }7 ^. `8 j/ L2 C
Selector sel;8 l7 p, C2 K" ^. ^9 Q2 R7 M" h, l+ f
try {8 A; H- ?5 t% I3 b6 ^) c- A
sel = new Selector(Class.forName(name), method, false);- z4 w) e0 R1 o$ b1 Q2 F6 d% a
} catch (Exception e) {- W" w" T k: C/ K
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
4 ]1 i K+ c' `: y% H- R System.err.println(name + "." + method + " returns " + e.getMessage());3 {0 e4 C9 Y, N6 |; w) @, R& s* j
System.err.println("The process will be terminated.");# k' F& Y2 a$ u8 I
System.exit(1);
, `3 j2 t2 O2 W return null; o( [6 e( n/ z1 a7 |
}
9 t- I# `! o& b# h5 k( u return sel;
5 j8 Z- k; Y3 \4 b( J }
- {: b2 X7 V: ~- N1 s
/ f2 t# y. J. p; T public static Selector getSelector(Object obj, String method) {9 i0 ^* H: V2 G$ j# ]
Selector sel;
9 O9 D4 q+ T4 ~: `1 ?) }1 g try {
# Y [+ b9 M" d/ R sel = new Selector(obj.getClass(), method, false);' z+ |# L! Z4 V* s W
} catch (Exception e) {5 d0 D3 e* M. }7 e
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
$ C0 R' U, a4 }, r- k5 y; o + (obj.getClass()).getName() + ".");3 H B* F4 |# P& k
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
* w4 K I8 [- \# K. E2 _5 p System.err.println("The process will be terminated.");4 O6 m8 ]) Q+ L" f) E4 Y
System.exit(1); I, a3 @: \" |& V) S
return null;
3 \+ n8 l- F# t3 I. H# { }
' T/ x$ _. \ f3 j' t1 @* ]2 T# _ W return sel;" A, z, Z6 O6 S, Q
}
6 _+ P% f. z9 M) y1 T o$ Q, {} |