import swarm.Selector; W |2 E X0 Z4 b# ~+ a! T
4 \( b2 [. ^' E" G) k
public class SwarmUtils {
5 A7 E) A' L" `( l7 H$ Y( G) d public static Selector getSelector(String name, String method) {
- E$ Z9 D5 V: r$ S/ X* [8 ~, D* S, } Selector sel;; H4 [3 f$ \( Q, z( D
try {
$ a2 y" G! _( {4 W8 q- ~' } sel = new Selector(Class.forName(name), method, false);* V) B7 a8 f1 ?6 m; C
} catch (Exception e) {: l4 F# F$ i+ O9 n( O' v5 b
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");7 W: k/ a) `- r0 h. ], s8 O! M
System.err.println(name + "." + method + " returns " + e.getMessage());
* d% p* b2 r9 T! L( S. X# f! q System.err.println("The process will be terminated.");
2 v9 ^% j! ~$ C2 \ System.exit(1);' H9 ~) D. G' z% I; d) u% Y
return null;! m- p5 y9 }0 ~0 {( d- V4 X4 R2 g0 H
}
" Y- n8 a; W; w4 I4 q+ u return sel;
. y/ r2 N/ j9 m) q }
( _0 q* R V1 i2 I
. c |9 x7 o7 P* c public static Selector getSelector(Object obj, String method) {
5 K, x5 z* b6 y Selector sel;
; d1 A, Z* t! U0 j/ _3 T7 @8 j try {( E1 X% e5 F& Y/ N( F
sel = new Selector(obj.getClass(), method, false);
4 {% o6 h; ]: y+ h% a& R2 F } catch (Exception e) {
' O2 Y7 b3 R: S. W% V+ s7 S4 f System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
/ r( P3 ]" ~. x + (obj.getClass()).getName() + ".");6 H5 a" d+ _% B0 @7 w4 w
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
+ g( [2 F$ s7 g1 f$ Q System.err.println("The process will be terminated.");7 [1 z# z; B- j1 ^7 N
System.exit(1);- w+ C: x( l0 |# P& p! g; E& V
return null;3 R8 o3 z; g) l) t
}
: a" J0 e+ H: T) A, m4 i+ d5 x return sel;7 M) a5 h; h" f+ ?' N. v
}7 h/ v. V6 Q) j4 f
} |