import swarm.Selector;, Q( W0 C( p; v1 T- R- O% U1 f
2 }& ]( }8 H s- P. C' |9 Cpublic class SwarmUtils {
+ ^( H' Q6 l% ?0 R. C public static Selector getSelector(String name, String method) {* e- G$ E2 O- K. v" E1 `
Selector sel; B# s, C/ [2 `6 ]3 S! d
try {
: _ C3 v* ~2 J7 @ sel = new Selector(Class.forName(name), method, false);
. R& _, _, |. K: \& R/ T% j } catch (Exception e) {
: O! B2 m+ n7 E) R* M1 ~$ u$ e4 Z System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
5 p* ]; `2 L2 H1 ~6 E& `2 S System.err.println(name + "." + method + " returns " + e.getMessage());7 k+ S+ ?. L; H4 e6 t
System.err.println("The process will be terminated.");' U+ d, N: r" M2 s8 l' ]- F" G# N
System.exit(1);
, j7 ^6 ^! z0 N4 [1 l. d" r7 E v return null;0 T1 R# u3 Y# ]8 S( V9 }; c
}# b5 O5 ~6 w1 r2 e, |
return sel;
7 S4 Z2 @0 w& {6 K }; N1 M# _& V0 O7 i
. h1 V' U8 K- ]- i8 O2 M: W) J8 v public static Selector getSelector(Object obj, String method) {* K; D9 K6 X0 n5 R
Selector sel;! j4 [1 @3 {. i. Q$ Y, N. E
try {; P! a0 |6 y) @' e. V; t
sel = new Selector(obj.getClass(), method, false);
, k: `! N& v# X2 e } catch (Exception e) {
( F) Y5 `* c7 F/ d3 j/ k( q7 I& Y System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " m! m. S% S2 z' W
+ (obj.getClass()).getName() + ".");6 v: a% O/ J$ [) D' G* `
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
+ h" D! C9 c+ D* B) Y System.err.println("The process will be terminated.");: ^- ]$ {5 P1 O; ^/ N: M, G+ \ e
System.exit(1);* D' z! m" G9 ?. j
return null;
# c7 Q9 ?( ^& i$ ]$ P5 f }' t5 K5 C: t$ \3 E
return sel;
, B- m. E: N( _0 z0 v+ q }
# S& X2 e& r2 X4 k} |