import swarm.Selector;9 |2 k, n0 Q3 ?( U: H
8 w |2 u. j. f) f) ]; \
public class SwarmUtils {
9 o2 v7 l% ?% ~) t% n+ Y public static Selector getSelector(String name, String method) {
; H2 n y* C2 d4 U7 `. S$ S Selector sel;
1 n. o2 J- O+ s5 B try {
9 F; `% e' Q& l( h! c$ ? sel = new Selector(Class.forName(name), method, false);, T$ w' G* w% L3 R; I8 J% _
} catch (Exception e) {0 e2 R6 m" ^7 j% W' P
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
1 s7 N- s# v8 w* g ~" E0 L System.err.println(name + "." + method + " returns " + e.getMessage());+ j) R! k# ]' e+ Y0 v
System.err.println("The process will be terminated.");, s R% G( k: R
System.exit(1); Q8 K& n, {. n6 z' X. |/ Q
return null;
. {* K- X0 h0 Y' h) L/ e }: g; c! {1 _6 ?) \
return sel;
8 b( M. |8 R& B" S0 m* z* D9 o$ o }: z+ T7 e6 c9 l0 ~
0 {$ |% w9 ^# C+ D0 a* i/ A: K public static Selector getSelector(Object obj, String method) {
; z! ~ X7 P& s# I9 |2 ]& E Selector sel;
1 E9 X" h- N' Q6 l7 m+ }% u try {2 R: p2 W5 V, x |
sel = new Selector(obj.getClass(), method, false);
* y! o6 Q U; `6 o) e } catch (Exception e) {& U6 w% X) D! K( h* m; m/ {) n# {9 ~
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
4 _* l6 J/ h% S( s, M- T + (obj.getClass()).getName() + ".");* J7 l# i* x; L# w. Z' l! }9 e
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
8 x9 x5 U# s/ C g2 { System.err.println("The process will be terminated.");' y& V" K- j; s! m: s0 z/ N
System.exit(1);, @* s3 d6 Y" a2 }5 Q+ Z# C- m
return null;! V3 @ L7 G! }- {& W8 D
}
9 }; M7 X" h) r' L o/ |+ i" C0 m return sel;
7 f) ?7 h3 \( F7 D }
6 ~, [" _7 T. r) S5 @' M9 n} |