import swarm.Selector;
$ S! G6 ?9 ~4 h. X* x$ {
$ Q, N( r( l) L5 lpublic class SwarmUtils {0 l, }2 p3 W3 B X2 M
public static Selector getSelector(String name, String method) {
# V% y' M7 n: M& d8 C `4 p Selector sel; F8 L# J+ r' u/ T& o% O+ h( m
try {
' l/ c m" w5 @. T0 F$ N! J9 U sel = new Selector(Class.forName(name), method, false);; u8 c5 b: j8 D4 t& d2 i* o
} catch (Exception e) {: {7 Y5 B5 X$ [. Q
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");( W+ p+ S8 a4 F" _
System.err.println(name + "." + method + " returns " + e.getMessage());
, e8 [% H5 W. @. w" F, N$ { System.err.println("The process will be terminated.");) c% m& I+ f' g9 e# \9 X
System.exit(1);
+ c/ l( Y9 z* M9 |) d return null;
5 y+ c X. h, y3 V( D }
/ h- r( L0 @/ ]1 o, O; J2 P+ N/ y return sel;, _& [$ ?6 h* \" \8 M0 T" P
}
9 t+ L" I' @9 y
0 D7 C; {6 _8 a% m d public static Selector getSelector(Object obj, String method) {
% g5 ` K* X3 d# a1 ]4 W Selector sel;
9 E: p. u, } X* D' r" J* [) t) _8 H try {6 v, c g# Q7 U
sel = new Selector(obj.getClass(), method, false);: @- B/ }! S6 b4 q2 N, F6 |$ |
} catch (Exception e) {9 i$ M. V6 b z3 t
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "1 b" d0 i# K8 w& z; D4 _7 L
+ (obj.getClass()).getName() + ".");5 J0 d' U/ b3 ^
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());3 k& Z0 B, b- A3 Z( [; L
System.err.println("The process will be terminated.");
4 ~! v6 t- p6 i5 z System.exit(1);. }. Y$ \; H. K9 ~4 `9 |
return null;
' W; |# ]9 l! ] }
' n: n! }8 C9 \. ~ return sel;' {% b2 f3 }6 F: h6 N8 [5 I: g
}
5 a" O: t, E* ^} |