import swarm.Selector;8 }* x$ t6 m) S3 g/ z% s. o3 w$ V( y- X
* Y u4 W: J1 D! o* Gpublic class SwarmUtils {
0 V0 N% H" k$ E8 b" q u% L; M public static Selector getSelector(String name, String method) {
H+ n( Y. p+ `( D1 a Selector sel;
2 p; q0 |3 x6 D, B; Z try {2 l) k& l+ X0 m7 W) Y
sel = new Selector(Class.forName(name), method, false);6 ]) x! q Z7 c; k% T& }5 I
} catch (Exception e) {0 q1 ^3 o% R5 W( | e
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");3 t3 f+ F) b" z1 A- V5 S
System.err.println(name + "." + method + " returns " + e.getMessage());+ E: v# f( ? ~. e3 P$ w
System.err.println("The process will be terminated.");/ r& E J C8 Y
System.exit(1);
8 `$ M/ x# @: W2 P) X return null;
9 A7 \0 }# W0 v [. @' S8 x }0 \' Q: @; F/ W; [# u- _" `: J1 e0 `
return sel;
! Q# g r$ m0 @# ^2 x) B$ S }! H' v6 j. Z( Z/ G& r
2 h8 g6 U. r j public static Selector getSelector(Object obj, String method) {' i: x( | `$ Y" g4 _# ~7 Z
Selector sel;
+ p3 t0 K* j! j& F) u try {6 `9 N8 [- ~4 R/ J2 [% \- E
sel = new Selector(obj.getClass(), method, false);
C7 n; s6 {( K8 s. f+ K } catch (Exception e) {
5 ^1 t; \* }, W% Y7 d System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
/ r( J; i' \/ K% M- ~3 M5 W + (obj.getClass()).getName() + ".");- r8 E! {) x: z. a( g; A
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());0 q" {5 G4 y/ P3 J A; p( f
System.err.println("The process will be terminated.");5 y& l$ W) `7 t6 | H
System.exit(1);! h: R9 N/ [/ ~' M" D9 ]
return null;
# n% ^' G" T H }
% J; H ?: K/ O" f4 }! n N2 s return sel;
2 w' J/ f- S2 O8 K; c3 V* a }2 e$ ^" v* u, @9 C; K) X1 t
} |