import swarm.Selector;
8 p" C$ @ _& {( A: Y, I6 U( O( W1 K: a2 _
public class SwarmUtils {
& ^" ~1 j+ W y+ g public static Selector getSelector(String name, String method) {
1 `9 m& F, @+ J& r* X2 E Selector sel;
& b1 M: o: m# O( m1 Z try {
& g- ]3 e9 Z5 {4 S$ b% P sel = new Selector(Class.forName(name), method, false);
8 w& S+ H% U5 T$ r' C } catch (Exception e) {- b, B: f. A) e
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
- j3 M# Z D7 @; o1 S: D System.err.println(name + "." + method + " returns " + e.getMessage());
' ~+ s7 X' Z& W. N/ R' v System.err.println("The process will be terminated.");& |: s, q; x* F' V" d. }
System.exit(1);
) d' j& ^) ?: |4 U9 P: N$ _; ? return null;& ?1 \# W; k$ D" r
}
% M: D' |2 C9 }8 P& W p return sel;& O( A) k' M, }) s( I
}% T% g$ A2 u7 U# [: J3 O* `
; y* |: I& M7 j8 V; ~( v public static Selector getSelector(Object obj, String method) {0 [4 ] G2 ~+ F. c4 b' ?! k& y
Selector sel;3 j6 `9 B" q. h! q6 A3 q* J
try {6 G% E2 K3 O# w
sel = new Selector(obj.getClass(), method, false);
6 n* d0 F2 R: S% x: ~ } catch (Exception e) {- y. O: V" }! O9 b5 S# e8 K& v' o
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
+ V v8 L6 w: Y' Q; _ + (obj.getClass()).getName() + ".");- I$ a; }( H- L' A
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
+ |3 G/ N, K6 ] System.err.println("The process will be terminated.");; n/ i4 x- c4 C' | A
System.exit(1);
k. B8 Y* E4 ]9 w% ]2 _" N return null;
" |: A% S m3 t3 _ }$ n+ ^' J( M2 ^4 N# y
return sel;+ C# L" X' _. A. o1 D+ [: o- \
}
; x+ @( S3 V& N} |