import swarm.Selector;3 u9 q7 t {* Y* i' ]
1 w7 l7 N) z* Cpublic class SwarmUtils {
) Y5 r& {, ^$ F S* l8 S/ O/ w! W public static Selector getSelector(String name, String method) {8 K) L, K2 F/ O" ?8 T2 C2 v0 C0 H
Selector sel;' N$ M; [* H* O: d) ^
try {' Q& Q; _! u$ p! s6 h
sel = new Selector(Class.forName(name), method, false);
% w, F2 ?5 x7 o. a+ g } catch (Exception e) {
) ?9 E9 u O' n6 D6 C. U System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
. |& O( ^; l; N0 _ System.err.println(name + "." + method + " returns " + e.getMessage());
6 ]6 A6 j. }+ t% a4 k e# V2 Y System.err.println("The process will be terminated.");$ _8 x% W1 M( ~! \8 [0 H; M/ v
System.exit(1); i+ ?* @. a1 Y; r8 N7 g8 }
return null;( c, c: E/ Z/ a4 B1 c9 }& F3 O
}8 o& s B. P# f; L" x
return sel;0 e6 P/ `) i, C) E. r+ {; S
}' n* w% K x- \- m( W4 x* I; M
7 ?0 _ h, t7 F$ R* @4 N% ~+ z
public static Selector getSelector(Object obj, String method) {' d/ X' [% ?, v9 x2 h4 y* m% h
Selector sel;1 M, x7 L# N! W& S7 I
try {, V# g2 T3 z& [+ F3 z% \9 N
sel = new Selector(obj.getClass(), method, false);! o3 [9 x, a! y6 A( M! R
} catch (Exception e) {9 X H( ^, U- x% |6 g$ e* g, M
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "7 L" G7 r2 Z0 Y8 q6 a) E6 d \
+ (obj.getClass()).getName() + ".");$ w* `; F2 }3 F. R0 X1 I9 x8 q
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
0 y2 L: W4 }6 ~0 y. d3 v System.err.println("The process will be terminated.");
7 C6 _/ Z5 T6 a& Q System.exit(1);
3 p& i7 o7 _3 G' ]' n9 F3 }* \# H return null;
! w" n: v7 U+ L7 S) @ }
6 J4 z' u1 J+ v return sel;- A9 ]3 O" L/ P$ i2 a9 r
}6 S s d2 {/ G7 L
} |