import swarm.Selector;
- e9 e1 N' ]6 u6 G/ v
# s$ Z9 V; H- f; ipublic class SwarmUtils {/ V% Z! Y3 M: c6 J' ]9 X" s9 s' t5 O
public static Selector getSelector(String name, String method) {; i! F% {3 o; b( \& g
Selector sel;, ?. }8 K: Y" U! _
try {
- S2 D- i2 Z$ {8 a. c( c' P- o sel = new Selector(Class.forName(name), method, false);
8 a( ^$ ^9 I: Q. E8 D* h0 q |' X } catch (Exception e) {
1 P$ G& `$ e' E* Z I( i System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
% ?2 X# x& v, @) X! H) Z4 X2 x System.err.println(name + "." + method + " returns " + e.getMessage());7 m8 d1 X- b) B
System.err.println("The process will be terminated.");
9 H& M2 Z% y3 W1 o9 `4 A System.exit(1);; J$ `, g! w8 M
return null;
5 d$ m, |: B/ |" o( e& w& A }# g, F* H& b7 w: c0 s- g
return sel;
9 q2 `( q2 ~* h, ~ }, v( f, {, E, ~4 ?8 h. r& t
% E- Z2 |. R& d public static Selector getSelector(Object obj, String method) {, p+ {: q0 R x; M4 ]* K' @* B8 X9 Y
Selector sel;: q; y/ `1 Q! r) }9 B
try {
% J2 Q) Z, { k4 C sel = new Selector(obj.getClass(), method, false);
, V# s2 ~" D, i } catch (Exception e) {
, K, a+ x% |, `5 m8 o- g: ^1 I4 j System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
/ X- o2 a( O' I3 ^+ p6 [/ ~. J + (obj.getClass()).getName() + ".");7 o+ i' o. y* v' L# d$ \
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
' d# F) m9 F2 ?) `. |# l System.err.println("The process will be terminated.");% @7 ?8 b! J, K
System.exit(1);
9 H" O7 t$ a4 ~ return null;9 h5 G6 v- C8 A$ R+ O; L% J* o
}
2 y& p5 P7 C$ J9 O return sel;
2 x6 `$ _6 o; e# u) q }
; A; {1 y5 r9 b$ ^% R% Z} |