import swarm.Selector;' X$ P: }( S+ k T1 I9 y8 v
, q; ?3 O6 ~( | l' {public class SwarmUtils {
?- [8 S t! h public static Selector getSelector(String name, String method) {$ x" P: x$ G" I4 b) b
Selector sel;4 x9 T: M. T8 K; l0 \# T
try {5 |2 [+ @. n" X
sel = new Selector(Class.forName(name), method, false);
4 N$ N9 g, z/ j5 p2 ~" k( U* ^ } catch (Exception e) {5 K) r; n1 H1 Z& \ l
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
D. v/ n$ a( N% [ System.err.println(name + "." + method + " returns " + e.getMessage());
2 @% u4 R, |2 _1 i% P0 t$ ? J System.err.println("The process will be terminated.");4 o2 p- ^9 I, z
System.exit(1);
, I' I1 t; P4 {# B return null;' h: u$ o1 N* e- U) R" W
}
3 h( O+ \! }/ e5 V$ D return sel;
/ _6 c" M/ o+ j* d }
) i( o; b8 e$ T' t- \/ Y; Q2 ~8 K5 W' F% U4 g
public static Selector getSelector(Object obj, String method) {
5 X) p7 N4 r( z8 z2 I Selector sel;7 D: q$ S# i. S8 {6 R, m8 W
try {0 T" H6 L5 m6 X {. _# j% O* ^* X
sel = new Selector(obj.getClass(), method, false);
! V F) j e: l; e, r) k, f# E3 m } catch (Exception e) {
2 X; k6 R4 |; r, \5 M System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "7 n1 t" L$ Y& O: F+ d& l! T
+ (obj.getClass()).getName() + ".");& i3 `, ~( X+ O% |
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());6 b* W0 U. j# }3 a1 d
System.err.println("The process will be terminated.");* }, A8 D3 n( j8 D
System.exit(1);; ~/ f1 z) `. o2 _; M8 I5 O
return null;& A4 Q/ s% o2 K% J& h
}
2 O! v+ w! X5 P5 Z return sel;* Q9 `% a+ e% y8 `+ V$ l
}
; N8 X9 _0 n& w* p1 \4 q} |