import swarm.Selector;
4 j1 ?5 L# z* I1 }; m& k% C
, a8 N; ~, S- E0 j2 apublic class SwarmUtils { p2 e/ d- o5 l8 X
public static Selector getSelector(String name, String method) {5 W6 S, ?% k5 U6 }6 Z+ |" g: i
Selector sel;
5 M. ]" x/ S& D Q: U. R try {! p$ C1 [# ?2 W8 Q1 }# N% l2 Z
sel = new Selector(Class.forName(name), method, false);) z x5 P/ d2 G$ k0 q. o
} catch (Exception e) {
! A, c. F) l) b2 q ]* f System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
, O# ?, d. A. R" Q System.err.println(name + "." + method + " returns " + e.getMessage());
% K6 x; ]3 B$ a: W System.err.println("The process will be terminated.");
7 v/ d: \, v1 H System.exit(1);. Y( u0 a$ v3 v- }6 V1 F+ i
return null;) p+ C% Y9 w1 r0 i5 F T. c% ~
}
. ~- a4 F" M* y$ k! i" @) V return sel;
) j) A; `1 x: e, s& P } ^# P6 h3 {& Z$ ~
+ g0 a* P6 D& {7 Y public static Selector getSelector(Object obj, String method) {
6 g9 P/ \& Y# U! }% U- u/ \ Selector sel;
% R; }9 l6 t- @2 S3 T, a3 K try {/ a# U7 J3 @% y3 Q: j2 G' r
sel = new Selector(obj.getClass(), method, false);
# D% p- N6 B( `1 h7 p/ r } catch (Exception e) {
4 m0 I: i4 ?: o System.err.println("There was an error in creating a Selector for method " + method + "\nin Class ", `5 E) J9 M! F5 Y% E" f8 k+ B$ S2 } ?
+ (obj.getClass()).getName() + ".");
" v ^$ E* t+ L( g( l! c e System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());; x, p1 i* G* B0 l( l4 r% Z
System.err.println("The process will be terminated.");4 q) H0 ^, X) K& [8 O, b
System.exit(1);
, _+ H- c3 E a. v return null;7 K+ t& }8 v: E7 N# L6 V
}) Q& S+ J: x# l4 J/ Z, l8 M
return sel;
- o, }/ m, Z+ ~- A4 W) n }. B) E _9 v# u3 f+ @
} |