import swarm.Selector;3 ~6 x" ]: [1 H4 C
8 u Z1 q, I' u6 G ]1 qpublic class SwarmUtils {
- \# T ]" S9 X* L. v public static Selector getSelector(String name, String method) {
- B0 |, y* ^* R4 f6 [, F& r Selector sel;$ F- S* z. @' B4 ?7 E4 ~
try {$ x$ i$ b' t# f, r6 w; ?' w( U% C
sel = new Selector(Class.forName(name), method, false);
# l, B1 l: w4 D+ q9 f } catch (Exception e) {
# l( r2 Q; l) S5 O System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
: A/ @! l4 L2 A' N0 w1 D System.err.println(name + "." + method + " returns " + e.getMessage());
- }# Q: U1 V- h% I7 w System.err.println("The process will be terminated.");
+ ] z |! |. P: f6 j+ X System.exit(1);
' v5 v. U: P& }2 t4 ?2 n return null;, G/ Y) r, G2 C
}' R" K2 G* ^2 n' M
return sel;+ q! P0 d$ e. c* H0 ~9 j
} G) G+ C* w5 g
3 v# b: u% M8 a' `4 s6 A
public static Selector getSelector(Object obj, String method) {" n; h& {3 {0 {; u2 [8 W* _: N3 V* E; d) n
Selector sel;1 B, r* M6 e1 C
try {$ R3 w* S9 f7 m* T8 k( w$ j
sel = new Selector(obj.getClass(), method, false);1 B6 p( m B4 U* T- N9 L
} catch (Exception e) {6 t) x( k' H1 C! l: l8 J
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " e0 Q% @1 \4 t1 w) S' i
+ (obj.getClass()).getName() + ".");
& f0 E9 t0 _) j( X- G, n System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());4 W" u# `. T! e( R2 ]6 n9 _ Z, c; X
System.err.println("The process will be terminated.");
6 Y' d* M3 ]8 M4 p* ^8 R# x System.exit(1);
! U- p9 A8 T. K. O9 K: z return null;: c: H7 W0 V/ |4 c7 ?9 @" n
} p) t$ R" j- l' r$ u
return sel;
3 q( W' m# {% A; S1 p. L9 Z }
6 O/ ~# z4 T. ~- |, t6 q} |