import swarm.Selector;( ~; c( Z7 }7 d+ n' b/ W
. R. G0 }% q7 n8 R* Y5 L) Bpublic class SwarmUtils {
' y& r, e5 v; D1 B) d public static Selector getSelector(String name, String method) {
) p4 `9 ?6 i/ W5 n% O! h, s3 j Selector sel;/ X$ E( s0 f! u W) F9 B5 I
try {
- r4 @6 C! a& h sel = new Selector(Class.forName(name), method, false);
6 O9 u% J# V' |7 q; ^3 I } catch (Exception e) {" [- f# H" l8 x6 [
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
7 p f; d8 f9 W7 s System.err.println(name + "." + method + " returns " + e.getMessage());
4 `. q; r1 P* O( ^9 C" _0 c$ G System.err.println("The process will be terminated.");* P6 M; C' V& W8 O5 k8 I* n- V9 t
System.exit(1);
$ W& I' y& h5 h2 O3 M return null;
/ [: Q! C! Z7 s$ l: d5 Z. t( g }# R8 D. i' A2 M& A5 G* ?, @
return sel;
: M5 ~+ @( O2 p, b6 h& {0 N7 \ }
4 C( `2 U. H; F* V$ O' |7 f+ e, }" J
public static Selector getSelector(Object obj, String method) {
; {3 [9 x$ {% u6 [; o Selector sel;" @- U7 x% K) N( z
try {
8 P6 W0 D; i0 U4 }9 b7 x% } I sel = new Selector(obj.getClass(), method, false);! |- {$ P9 ~9 z+ e
} catch (Exception e) {3 [& x5 z+ o+ t& l1 S
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "' l0 Y- k1 G- [3 h$ n$ M
+ (obj.getClass()).getName() + ".");
2 |. h z. v! C0 P, o) `4 m System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());' I7 r2 X0 {$ i3 [/ ?- Q; ^( `2 e% Z
System.err.println("The process will be terminated.");
W+ d2 ~! V8 k `$ u# t, v: s! b" y System.exit(1);8 ~4 i4 C7 V0 t0 s
return null;
' K0 u, y- }. g8 `8 u( `. { }
Q& L: K8 R: O return sel;/ f5 ~! P9 {# n2 M# Q
}* q3 a3 c" ], H$ H/ n& M, u0 C2 S
} |