import swarm.Selector;
+ p3 a9 M3 `) Q5 R4 Y) ~8 r( f0 O) v. E9 M2 Q( d
public class SwarmUtils {
3 W4 \* L( ^: ^9 T1 A public static Selector getSelector(String name, String method) {, S s8 n6 F4 m/ u( E
Selector sel;! e5 C( P) Y# u3 f) y4 Q* Y3 _
try {
" e+ O8 @6 \$ x sel = new Selector(Class.forName(name), method, false);
# }* h# ^! _( H$ y8 l } catch (Exception e) {* F" S& e5 J2 H) G! Y. _
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
9 G) T: _9 H8 U0 y( S( W7 O System.err.println(name + "." + method + " returns " + e.getMessage());" G8 g/ E) {7 q- w q4 J
System.err.println("The process will be terminated.");
, s- G4 i$ M- Q% [6 {0 a! w# O System.exit(1);
+ m1 M8 G$ ?/ O( t return null;2 \- g: o. f) j; M
}/ Y# ]4 F( U2 C j+ x8 M% F
return sel;3 ^2 T# \, F! L% G. \
}
, t0 h0 l; ~* E+ s7 n: Z9 `* Q, d) ^3 F' j+ \
public static Selector getSelector(Object obj, String method) {/ Q2 ^9 M* g* b& }7 x: ]
Selector sel;+ R- a+ E/ Y& d$ O% x1 P9 p9 ^ U9 F
try {
4 F3 a6 Q2 P% |8 ] sel = new Selector(obj.getClass(), method, false);2 ?* x) Q( F, g1 j, M- d h; U0 {
} catch (Exception e) {" p! C, K+ S# N' h6 Y" n
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
% J! B+ l1 Z! b8 u" [: B& f+ C + (obj.getClass()).getName() + ".");
1 S2 r2 h; i6 R8 I System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
9 K+ L% {, O* t k8 @ Z System.err.println("The process will be terminated.");3 j3 v* H! @' d6 Y; [% n( O/ H
System.exit(1);
9 I/ w6 k T. g$ u return null;
$ d, } W) O* ^% p" T }9 v6 j$ C, W1 u& M V
return sel;
8 P+ [1 w1 f) O/ D }7 J4 ^5 W. @1 {+ a& W, j
} |