import swarm.Selector;
( u, F% m! C: P3 W' g, `$ L1 [& W7 r3 A: U" I/ [# e
public class SwarmUtils {
- l& l) p; d3 W0 ^/ d) T3 r public static Selector getSelector(String name, String method) {% c( U6 Z: J9 O5 \9 r' Y" t
Selector sel;
- ]1 d. a% _2 b8 r) Z, g try {
" F& Y) D- _: `' f$ G9 T( @7 y4 x' Q9 S sel = new Selector(Class.forName(name), method, false);- m/ O. [' B$ r- \9 b4 R
} catch (Exception e) {0 }7 z: M; F" s- ~7 ~+ E: b
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");# ^* ~6 w2 J9 Y* i
System.err.println(name + "." + method + " returns " + e.getMessage());
* Q+ O h) k) w; t& @9 @. G System.err.println("The process will be terminated.");
4 ^- p: {- |7 l; e' ] S System.exit(1);
: W4 h& C% k6 u+ u7 E3 j; F return null;
4 ]( K/ f6 G7 D; r# y }/ A, V8 e/ X/ k6 N
return sel;
- l1 U) P9 H( }6 g: X) w( I( a }
p) S2 ]) H7 b. V" z1 K) a* U# T7 v! l v; T
public static Selector getSelector(Object obj, String method) {# G1 _$ V6 _/ P& o) u
Selector sel;( i3 O! d% }2 L% X$ e' X% \3 X! C
try {7 B. i( y+ o# N
sel = new Selector(obj.getClass(), method, false);
8 J( j1 ?0 G0 F' j! H f } catch (Exception e) {
+ \$ |' B% i: f& `/ w* j3 X3 j System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "8 \5 Z9 g, L( _& J5 e
+ (obj.getClass()).getName() + ".");
4 z8 @* @+ @4 n% q7 t5 v System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());0 _% w' \) \/ `
System.err.println("The process will be terminated.");+ O h' r+ g$ c$ f" k D9 k
System.exit(1);
" @3 M8 h- d7 z" e0 S return null;6 r8 ?" j+ K0 }5 N8 `
}. Z5 G& B; c$ K
return sel;
4 p* \. R+ H+ v `0 {* s0 } }
+ Y. j0 D1 m6 J5 ?1 A} |