import swarm.Selector;$ r, O( f/ g& [5 d
, V. m4 y$ W! P0 L# N
public class SwarmUtils {
% R' l) g6 }- z public static Selector getSelector(String name, String method) {
- f0 G* O" p, Q: P- V1 H Selector sel;
" Q2 _: G7 [5 u1 B& y! s2 w try {7 }; C1 o8 [+ I4 L" Y
sel = new Selector(Class.forName(name), method, false);! A% E$ Z5 Q# \- t, p- l$ q% V0 d
} catch (Exception e) {9 ]8 t. i5 W/ S0 `/ x
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");# s5 a1 D1 V! Q% }5 U- A* k1 b( S8 H
System.err.println(name + "." + method + " returns " + e.getMessage());
) Z7 T& S; o4 W System.err.println("The process will be terminated.");
4 k- m* N/ I* D- y. o6 ?1 j System.exit(1);+ R: g: [: _. E- }
return null;" A6 n% W- T. H
}
- s$ N: G, o6 f0 E0 E- c return sel;% J+ L4 \' a( N+ W
}2 k+ u/ h% e( ^4 N$ k
" x+ `1 K' ~) E& c. h* z4 s public static Selector getSelector(Object obj, String method) {
- }+ m9 x, [: y& p/ r; | Selector sel;7 j! N. N8 H7 s; J, V
try {
/ m+ U+ Y' B v V sel = new Selector(obj.getClass(), method, false);
2 r8 T1 Y. b+ W7 B6 f } catch (Exception e) {( u9 p+ l3 @. e: M1 k
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class ") k/ c% y- x3 @8 ~* _: X
+ (obj.getClass()).getName() + ".");& S6 Y8 q; S" {5 E! C1 H
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());6 O$ |* t* r: I2 E Z3 d) n5 u
System.err.println("The process will be terminated.");, B. d1 d& G% e6 i; l* I. _+ s
System.exit(1);
" D" i5 p3 z) I S" ]: {/ o return null;( Y- |6 ]4 H* v/ k" F8 d
}
; x6 D# p9 m0 p return sel;
7 W) H1 S: O1 Q0 _/ G }
7 s: @/ }" R1 v4 A! T- b+ V0 m} |