import swarm.Selector;
4 d4 l) b+ c" h0 @. G2 q6 L \' U* j5 ~
public class SwarmUtils {+ X. p9 [. f1 c% K; p# u
public static Selector getSelector(String name, String method) {5 ^, J& j0 b; A6 W6 W# c
Selector sel;
, {, f- _% d6 _$ [( f1 J' _8 U# r try {4 S. T, y3 q; I3 a6 C
sel = new Selector(Class.forName(name), method, false);7 v% }1 X z* _8 Z
} catch (Exception e) {
% J7 l' V& `# v6 Z) Z9 l c* X System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");9 f1 A9 i; b2 c* n5 \$ ~
System.err.println(name + "." + method + " returns " + e.getMessage());7 }6 p* x: S% _1 ~9 d; t
System.err.println("The process will be terminated.");
* \9 N: U9 h* w$ r! ]' Z8 l: _, d System.exit(1);% y, J% _- Y$ r& p- ]9 T' Z
return null;
1 E% j0 }. h2 u& c& f }" Q) Q& A- c+ A
return sel;, v3 c) x) I. r/ k. q
}4 o) |& ?9 p* B
. t7 J3 C4 X n9 z, p* J public static Selector getSelector(Object obj, String method) {
1 P# N8 o" ?* e+ r+ @. | Selector sel;
0 Z3 e* v9 Q8 T+ s6 N' l try {
7 u f8 ?$ p+ v1 e7 m sel = new Selector(obj.getClass(), method, false);
9 ?6 C3 u8 s1 D) M" j8 H* d8 Z } catch (Exception e) {
7 w6 J& [' I& M2 N5 O1 Y+ P+ U& \ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
: f: Q5 n" j5 A* | + (obj.getClass()).getName() + ".");
5 {9 ?+ N% N5 C* j System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
) o& {8 r e, @/ V) }) v System.err.println("The process will be terminated.");
) i3 }8 d2 N8 t |# ~+ b. ^ t System.exit(1); s# e5 R1 `/ p/ v$ M; f" O
return null;: f. W2 K- T! E) }
}
) i& U/ S+ t' d- o6 C3 z9 ] return sel;
4 h" s1 E* X0 t& N; t" ` }
, {& W* l/ O) F: O( h* ?} |