import swarm.Selector; ]0 O' [: G L% O, o
: s/ ^5 k$ _2 V8 wpublic class SwarmUtils { h2 Y7 E+ v& t- N4 }+ J1 O
public static Selector getSelector(String name, String method) {
k3 c, N1 n# A Selector sel;% H4 S0 x- |7 M" b' ]7 h( t
try {
! @1 ^5 {2 U. [( v" e. j3 | sel = new Selector(Class.forName(name), method, false);
5 X' e/ J1 ` l& N, [% c } catch (Exception e) {, s0 o4 \) I8 |3 L
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");; g$ d7 F. h; K/ [. Q# P9 D
System.err.println(name + "." + method + " returns " + e.getMessage());
% b; X8 a2 b" O8 M+ { t& g System.err.println("The process will be terminated.");2 K- a" D0 \1 z1 |' p
System.exit(1);
/ L7 A1 J+ V& l8 f return null;( p1 z: K" v/ K6 g7 j! n/ D
}* n9 A& O9 @* k0 C
return sel;6 ^1 B6 p6 @) W# f# }1 z
}" L& ~2 |3 |4 u( f; o
" ?& Q3 Q1 x6 B0 P4 Q/ `' H/ r public static Selector getSelector(Object obj, String method) {, s2 I( R% |$ g" V$ k
Selector sel;, R- ?& E. P3 p: h( e4 J. q6 {
try {! x8 w9 T0 P7 m7 U+ L
sel = new Selector(obj.getClass(), method, false);: o. \* H, A$ l9 m/ s0 v. A J
} catch (Exception e) {8 Y% t% I7 s1 m5 F! S, X
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class ", k* \! K8 |6 B8 T, z, |
+ (obj.getClass()).getName() + ".");2 r, R( [5 J* {8 Z; ^4 v( ?
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());( b3 V7 B4 L2 r! h* M
System.err.println("The process will be terminated.");* K5 e7 n, v) _/ O2 b& C* z# u9 T
System.exit(1);) S& x) {# ^% H
return null;
/ B6 s2 m0 F' ?* g }: v( a6 q* i% e/ C: R( \" U
return sel;6 `2 V$ P. Y2 [4 x6 D* [/ U7 c
}
- j/ X' t% t* a2 F9 z} |