import swarm.Selector;0 \" W$ V+ ^2 s' i: p0 j u
' x( @2 ?4 M; y7 J- N( Bpublic class SwarmUtils {
6 i+ d$ |) m9 l% o public static Selector getSelector(String name, String method) {
X ]5 P' i: i: Y( [# A) Z Selector sel;
8 G6 E) }) R# V try {
- _4 `) L: n V; `4 d7 K sel = new Selector(Class.forName(name), method, false);
/ l# P7 a) ]9 G5 S } catch (Exception e) {9 t8 D! t6 J5 s& ~) O
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");7 c. t: R h3 u1 T
System.err.println(name + "." + method + " returns " + e.getMessage());
& M/ b8 f' G- k7 l( U System.err.println("The process will be terminated.");' j1 L0 D& x7 ~6 m8 T' L
System.exit(1);
" B5 _! G$ M2 q. m6 M/ r return null;
: q& O0 `5 @5 c+ M: `' A }
. q6 a: R, N4 c4 |* z return sel;- K2 s4 O9 F2 s
}
( W9 e: ?/ S, X& `9 x& J! `3 T, u& i+ Q
public static Selector getSelector(Object obj, String method) {8 {4 Q2 t) _' {, _; v1 L
Selector sel;
5 F2 a8 h+ z3 y" H. f try {& o; w! l+ F$ T/ v
sel = new Selector(obj.getClass(), method, false);
( H6 \4 g# C( @; H/ v5 o } catch (Exception e) {
9 S% n# X, K; c) i/ v System.err.println("There was an error in creating a Selector for method " + method + "\nin Class ": B8 q5 z: |$ z! U" T" g
+ (obj.getClass()).getName() + ".");1 N! `& t/ o: x' O
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
/ j f. X+ Q2 z0 `9 u System.err.println("The process will be terminated.");
' O2 ~* q5 J. u$ ^# `; G2 ` System.exit(1);
# F) k; S* m4 E. Y8 K" S return null;
# l" |! ^% R0 g& o+ C" K0 C Q5 r" O. t }. @% ?3 o. v$ e5 ~
return sel;
3 e) K2 L8 n. J' v }
! ~* j$ z! P7 ^6 y a. M8 m} |