import swarm.Selector;
) D3 _2 o1 E+ H& ^, Z: }
8 N B4 ^, B0 E0 ~ apublic class SwarmUtils {% R* n$ L" S6 @5 l# Y! {
public static Selector getSelector(String name, String method) {6 j) l: n9 F3 s- q4 y: k
Selector sel;
4 |; ]/ y- x* V7 o5 A$ G try {
- d+ a1 c7 p1 `$ ]. @; h% D4 m$ o' z sel = new Selector(Class.forName(name), method, false);
$ F; A1 P- Z/ ?$ K/ G$ U. s } catch (Exception e) {' F* Q4 t8 S+ a/ J7 a' ~
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
. d' L7 r/ b) A2 a" c* q1 ? System.err.println(name + "." + method + " returns " + e.getMessage());2 N: @9 q/ u4 P! p" [5 U6 u
System.err.println("The process will be terminated.");
" b' Z' {" e4 q& R! s System.exit(1);% Q7 Q1 b; M1 H3 N5 f- l3 E! {
return null;
1 f J) [/ S* X# ~, J* d% j8 V }/ S; J% s K/ M0 p
return sel;, N* C* _8 q1 M5 j3 [' I
}! ~- D7 u( n# y& t& h w
) N/ P5 W- i3 G. _8 D( u
public static Selector getSelector(Object obj, String method) {5 x/ u; j7 d' e# \; @
Selector sel;
! W/ E7 I1 L/ ] try {9 @: P' t# v7 [8 {# H
sel = new Selector(obj.getClass(), method, false);7 B8 H1 \" w) _- g
} catch (Exception e) {
1 w" @* J' f" Q0 A' ~. U4 p System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "; J. n8 Q2 F: b, S, r
+ (obj.getClass()).getName() + ".");
2 L7 b {/ ?* u System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
1 Z. K; ?# t3 p System.err.println("The process will be terminated.");
% Z' n, I: j8 W4 x0 j* {5 U System.exit(1);
9 p% U8 @* M1 C0 n& ]% m! n1 p, @ return null;
7 M8 q. a. V0 B A9 D @" w8 l6 w; h }
% j0 ?, l& P r0 T return sel;) Z0 u# w* ?. I/ M
}6 k7 b8 x) z- k% ~: Z
} |