import swarm.Selector;% S( O1 ^/ }3 I8 a: R- Z1 x
( i! N8 m. D2 Kpublic class SwarmUtils {' L9 I- H" }7 @7 ? D5 X
public static Selector getSelector(String name, String method) {2 E1 r( N' j( Z2 w) h& O5 g
Selector sel;
2 z; Y1 t) q0 e7 @0 ~' Z4 x try {* C; t* s& W$ `0 O+ }
sel = new Selector(Class.forName(name), method, false);; V. \, K. I5 t# E2 x6 f
} catch (Exception e) {
8 E' s. d* B# s2 ] H/ s System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
+ N9 U4 M- H' f3 H% ^( z System.err.println(name + "." + method + " returns " + e.getMessage());
7 N8 C+ s' v5 S; b1 k* a System.err.println("The process will be terminated.");
) v: k) L0 |- J: u System.exit(1);) T, t' J5 R& L2 e' Z
return null;9 x. S g& _ `2 W- X% a. M
}+ @0 R, E# l* L8 u L% A$ ]
return sel;
) c8 P3 R, _7 u R! {* t }8 E9 y7 f: ^( K
9 h- {% L8 R# v8 f public static Selector getSelector(Object obj, String method) {! Z$ s& P ?5 _' [" u# f& S% ]8 c
Selector sel;! b$ F( E I0 O
try {& ?3 O# m+ v& a6 g! u: c$ }& u
sel = new Selector(obj.getClass(), method, false);6 z& v9 P. b) o9 d
} catch (Exception e) {2 r* @8 d. M6 Q3 Q' h
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "$ Y- d1 Y6 a" m. V/ p" P" d
+ (obj.getClass()).getName() + ".");. l, l, j4 W8 B6 B- P) B* U
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());% y: u6 {* [5 b3 ~- g7 K F
System.err.println("The process will be terminated.");
6 O2 V$ {0 K1 e( }- r7 V9 O/ x* e9 z" Q System.exit(1);
' O2 }0 h9 \* |8 a return null;
+ o) a/ a; e6 o: N5 @' j }& R, K/ A. O/ h
return sel;
5 }! v1 a4 v/ j+ @% P) }7 _% e/ { }7 M0 w5 g1 Z/ \# U; i
} |