import swarm.Selector;
- u& ?5 I9 e/ v' W+ ^- H
8 Y/ Y; c, d8 d* @- K# T ypublic class SwarmUtils {1 Y+ j% @: c8 i
public static Selector getSelector(String name, String method) {
2 |# { j# e) v Selector sel;; c) F* `& i( s8 f ~4 h8 o" ]
try {
9 O9 c* S' z$ L, J sel = new Selector(Class.forName(name), method, false);% P/ F/ U6 z- r: r* @
} catch (Exception e) {& s8 o# e$ X$ s" f c7 @
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");1 P. D8 C, K5 T9 G$ ^
System.err.println(name + "." + method + " returns " + e.getMessage());5 ~7 K2 d/ M* M6 U" U# U
System.err.println("The process will be terminated.");
' W f. F- v/ d$ u* ~! O; g* ^ System.exit(1);
- M* i* _+ F. y& P return null;
% |1 K8 V/ P$ D }
, O. n* f9 u3 ~: O return sel;5 X8 k: l: f* c0 q" W* Q, B
}
& M- R& q0 _: b( E0 f) {/ B( m. h% P/ g, d Z8 M; ]
public static Selector getSelector(Object obj, String method) {# t, |# f+ l4 p9 _/ M* i0 G5 H
Selector sel;
$ \7 b7 o( Z; a$ j' ]9 M9 d try {
$ ~( }* W, n* {3 O! N sel = new Selector(obj.getClass(), method, false);
1 Y, U8 `4 C$ n3 O' J( t } catch (Exception e) {/ Z+ I4 x/ C$ F" a0 V- B! @
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
" z% l) p x" Z, R0 m9 Q, n. j + (obj.getClass()).getName() + ".");( H- j1 \0 D8 }4 F- S
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
. J8 J4 `/ x3 M. X7 ` System.err.println("The process will be terminated.");) G5 v7 g5 h* S; [
System.exit(1);
- \3 z" i% p/ b4 q/ \ return null;+ }" o$ V2 Y5 Y E; w" X
}
; w# m7 E4 \4 p$ M, j$ k- f return sel;, a4 ~+ l0 {8 i
}2 T f3 _2 b3 I& H& c4 a3 q) Y3 g' c
} |