import swarm.Selector;6 f6 K% H/ M& ^! f+ x8 N( [0 G) k
% I1 ] f3 h$ _
public class SwarmUtils {9 v! J/ A+ B! l2 Q
public static Selector getSelector(String name, String method) {
8 `& p/ Z9 k. e# v+ h Selector sel;- `- S/ s2 [$ J' J l: C
try {* N# T8 X% M6 o% Z
sel = new Selector(Class.forName(name), method, false);3 z. N0 f k2 s# ?
} catch (Exception e) {, ^1 S: y- }+ ~; B9 |
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
: P, Q7 L5 k% A( K$ K System.err.println(name + "." + method + " returns " + e.getMessage());
G# g9 V. t d' e. B0 W, ^+ T System.err.println("The process will be terminated.");
, ^) v* j5 D( F: |$ T System.exit(1);
4 c; J' _: V. h; m: b return null;5 ~8 i( b: t J2 [
}2 m; c! A& b! W) Z+ z
return sel;
$ ~3 x" @' G' ]; g+ ^ }
. {, {$ l) X4 g, V" T, E$ Z, C8 l r/ N* G8 K" R/ b; M! D- x1 P
public static Selector getSelector(Object obj, String method) {; }, R( v8 l" q9 [/ F" T; b" G
Selector sel;2 ?6 i0 p6 G; C* V' B' I# J
try {2 B! ~& o# i$ C" g" b- R& g% |
sel = new Selector(obj.getClass(), method, false);; a( v) e( i* N& }5 {9 _7 x
} catch (Exception e) {' D9 j" n. ]) p, [+ k
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
* p' \( i3 R( [& ~0 G6 g + (obj.getClass()).getName() + ".");- Y! \8 [4 n( j+ c( x
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());- r/ Z2 K1 \8 C+ Q+ X' s1 T
System.err.println("The process will be terminated.");. m$ a4 P# `- O$ Z2 ^" N0 P: a
System.exit(1);1 ~* q y$ Y) M
return null;
* a# A, z3 L5 K5 C }3 H$ n3 S; d; L
return sel;
9 l* K* _5 S- C' Z+ Y% ~; D }" p, N9 H, _4 o
} |