import swarm.Selector;; E S: k( Y: K; J5 v5 o
0 Z; @/ d% Y: l r+ _8 `& O
public class SwarmUtils {
$ M. O- N# `8 L6 z! Y+ j public static Selector getSelector(String name, String method) {
6 M$ i K- h) ~+ B, D6 c Selector sel;
: |( R5 I6 Q4 `' C9 l3 z# g* j9 C try {
( v0 n7 T% E m/ T8 `2 G sel = new Selector(Class.forName(name), method, false);) o5 J9 @* O) T" P$ I: l T
} catch (Exception e) {: @. J9 ^8 o; r; {$ h
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
. J' Z( L( t6 R# f" ]9 b! r* o. N System.err.println(name + "." + method + " returns " + e.getMessage());
( |- T4 S1 A# x System.err.println("The process will be terminated.");
3 H. L2 f0 X# g) X! Q( r: ?* a System.exit(1);
3 u- R Q, [( }2 m- F" a return null;
8 C) [' h& B8 Z2 s' d. c6 V r }4 v* M5 C1 I; k: r; B
return sel;
4 I* u: i; j$ R# i3 B }
4 r. W5 a) z4 _. l* x
1 ~1 ^' w( I- N* X. L3 [% \- x2 y public static Selector getSelector(Object obj, String method) {
" J; N& r4 u: S2 l Selector sel;# H4 }9 b/ d3 N8 }# x: ?7 D
try {; P1 t7 X: ?) l- T
sel = new Selector(obj.getClass(), method, false);, _; u+ O$ E. w: n% B$ ^3 o
} catch (Exception e) {. V5 X3 Z* e/ M- O% P
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "& Y- t' z4 \$ M
+ (obj.getClass()).getName() + ".");
# |2 I2 y) Y) t; [7 w System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());$ E- q5 D1 z- q
System.err.println("The process will be terminated.");" U# e/ h4 L1 }+ }$ O( g
System.exit(1);0 J O3 I# I$ A" d! @2 k
return null;
8 L# Q* w7 A. c7 P2 j }
9 i1 V% l y. u return sel;
. s/ o. [+ N& K7 b' H }
( |- g/ o9 l0 o4 k& ]} |