import swarm.Selector;
: O: [! ?5 Q+ p: C) e2 C5 Z
" L7 ?$ L, w- u, _# G. bpublic class SwarmUtils {
3 F/ {/ {7 M- B* \( p# P% M public static Selector getSelector(String name, String method) {
& t# A4 T" v% V" |* x6 } Selector sel;
/ o' `7 d( P! v' S" E) M try {; L; o- ^3 l8 v, ~7 g/ x% P/ V
sel = new Selector(Class.forName(name), method, false);# _, T% ^; ]* {% V
} catch (Exception e) {
/ x$ \& j _5 a+ `1 d3 K4 V System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");+ O& H4 D* N$ N3 c( H2 w2 a
System.err.println(name + "." + method + " returns " + e.getMessage());
4 J$ V" J3 w0 M- ]# i System.err.println("The process will be terminated."); O* j3 C: V5 ~
System.exit(1);
( X# E" U. I3 X, Z/ X$ e5 x return null;
; G; q1 Q% d9 m9 a2 M) } }0 d5 u4 S6 ^5 b+ D$ f% P. W7 g6 _
return sel;- a T5 N7 I' P, k4 G
}& s" F) D( [; {0 {: H
4 u* }" _% k& z9 t% B1 O# I7 e+ P public static Selector getSelector(Object obj, String method) {3 W2 V7 X/ E$ g9 @% W& S" L% T
Selector sel;+ W" r( G0 x( N+ h$ P& }
try {
) m6 P) M# n8 L( d5 u0 D sel = new Selector(obj.getClass(), method, false);6 H; q& u4 R& Q8 W, s4 S8 _9 S5 y
} catch (Exception e) {" t, d$ x; k- |4 K7 \8 ^! b0 r
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "- z8 y/ s! U) w
+ (obj.getClass()).getName() + ".");. Q# Z/ M. P; h
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
8 Y! Y% ?0 p) v, V4 q6 I% s System.err.println("The process will be terminated.");) S4 i) A6 }" l, @
System.exit(1);
2 k: k i% R2 E5 n' G+ X( }) o return null;
4 P& e+ a5 r; A5 v4 R% z }7 n. \# [4 S' r/ \3 P
return sel;
* J7 x: i+ E4 C! l0 p1 q1 N8 y0 X }
- t+ T- I8 J: W) k7 c1 Y. N6 v} |