import swarm.Selector;
. Z3 _, \& r Z7 Y& ~, X+ s6 W6 J) @5 u) D: [
public class SwarmUtils {6 ^& e4 V7 X# e& t( Y
public static Selector getSelector(String name, String method) {! Y- v" F& C7 r' R: W3 h$ y C1 L, N
Selector sel;
/ n: x- \& C: T" R try {4 m5 `4 q/ |3 z" S
sel = new Selector(Class.forName(name), method, false);& v) L, o# O5 b8 ?/ i
} catch (Exception e) {4 ]/ B9 ^7 D! e! Q5 w2 E2 z
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
$ n) L S% R' F9 Y- v System.err.println(name + "." + method + " returns " + e.getMessage());" V3 G6 A- t5 @) |2 \
System.err.println("The process will be terminated.");, E7 x! l" W) E9 }
System.exit(1);
$ Q- [! ?7 N; x; A H& O return null;
/ y( w% X9 z& I! ]+ I" h6 m: X. J) g }1 W- k/ r- F- X, p! T, U, ^! ^
return sel;
' j$ _0 _5 N" n. v }
1 z5 K% s) y/ N) x5 L6 Z% t9 g! e+ ]3 E! a/ A7 w7 k& w! V
public static Selector getSelector(Object obj, String method) {
, x/ K+ H( h { Selector sel;
: D) C8 v, h' K try {
" m! K V* q8 f q# _9 N+ h sel = new Selector(obj.getClass(), method, false);- D; M7 C P7 z a
} catch (Exception e) {
' S9 ?0 [9 N3 K+ |7 F' H$ c. M) b: ? System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
- b1 [ ^6 j( K6 @8 r + (obj.getClass()).getName() + ".");# r7 H* t0 u# M: ?" r
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());" O; W' G3 {. x; I3 c5 e
System.err.println("The process will be terminated.");) |. ]2 J% \ T
System.exit(1);4 r0 S6 V! \3 i
return null;' {1 t) m! I4 ~3 k* L+ @4 B7 U
}
) V9 _: J9 N1 M9 b4 Q return sel;
9 z4 ?/ ~* `8 m# Q8 {4 d }
- h% k2 x, S9 H! R7 `# Z9 ?} |