import swarm.Selector;" m& o. L/ m- g2 U+ J
6 a7 ~; [" [' g" y% ?public class SwarmUtils {
* z6 g) Y, C: l public static Selector getSelector(String name, String method) {
9 |) c3 R! b: ?- f, o Selector sel;! {9 Z& W% }- I5 U
try {
7 v7 M3 d7 F6 m" X/ V4 `- ~8 U; K# X sel = new Selector(Class.forName(name), method, false);" T: W* R. D2 V8 \; s3 W1 J
} catch (Exception e) {
8 h$ {7 n& F% N& x" Z* h# Z$ x System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
" Q: l e" Z! O System.err.println(name + "." + method + " returns " + e.getMessage());
) v' G& L4 G0 r System.err.println("The process will be terminated.");, d# v9 t7 c4 I- X; t$ a
System.exit(1);5 K- O: ?) }) [" @6 j: o' X* b4 b L
return null;
! H) K- Z6 {) ]3 g }
/ H" \/ d! x6 [) C; s( N" i return sel;
! L9 T$ j/ X6 K8 @ }
2 N+ v% J; m K) j: r% ^! M- S3 g9 A$ k% X4 o" y# V$ @
public static Selector getSelector(Object obj, String method) {: }& W- ~% N, ?# g" @) S1 W! x a
Selector sel;
" A, m% |1 X0 D0 A2 {( S" @ try {, R8 V8 w& H' [, i0 k# r! l ^
sel = new Selector(obj.getClass(), method, false);
9 V8 t( o/ J. R } catch (Exception e) {5 l3 v! l" a( ~ q% Z
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class ": [ g0 n; g1 A3 [+ d
+ (obj.getClass()).getName() + ".");
# K! }6 v2 t5 a System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());8 T9 t6 n; [6 F. }6 Q$ m" W
System.err.println("The process will be terminated.");
; z0 E! h0 W& t6 w8 d0 b System.exit(1);
3 T1 \5 V; d6 m6 K. Y$ O6 G6 L" z return null;
( L3 G* @$ G2 Q r3 v; S }$ |, [+ D/ O& f0 p$ j1 J" t: n
return sel;
) q P# [. s+ x6 \8 C }6 L# i0 a# Y5 b- z0 ~
} |