import swarm.Selector;2 H( H! N4 S% f
! T) r* M4 |7 P1 x' ^1 i
public class SwarmUtils {
h3 l2 Y3 m# \$ h4 M( P3 Q public static Selector getSelector(String name, String method) {
4 h2 N6 M. J: S" @, g+ L# |6 o9 {+ C Selector sel;) ?" k( z, s' r# l6 C
try {
8 m7 f+ N# v8 H6 e Y# Z' q! Y j: } sel = new Selector(Class.forName(name), method, false);
" N9 d; N2 C* q& f9 \& B5 u! s& z5 T } catch (Exception e) { x; A# S, ?; Y% t# A7 |, [, Y
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
' ^. L! x9 J3 F1 {8 d2 {0 | H System.err.println(name + "." + method + " returns " + e.getMessage());0 e( L Y7 d" p8 a: e; T$ s# R5 y3 ?
System.err.println("The process will be terminated.");
: X* |1 E7 e( @6 |0 r System.exit(1);; Q- D6 h( l* I2 @+ G0 A4 u' J+ G1 ^ k
return null;$ z, V# b+ ?2 s8 E7 W! Y P: { C7 z
}
; D/ s O. T _3 P+ x return sel;
" I- I9 L2 T$ ]: ] }
: r7 P9 i( I( E% K" Y4 }" P, a$ P. c
public static Selector getSelector(Object obj, String method) {
: X s; R b' I( a* L5 v4 d) U( P Selector sel;/ |6 U3 P: \3 T$ w# T
try {' A0 t5 p: H, I+ [8 G' C/ E1 w; f
sel = new Selector(obj.getClass(), method, false);5 x; w& c$ j: Z3 \) u; u9 S
} catch (Exception e) {. r! d9 G/ q T( x( M% u
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "" a) g2 s- Y. d8 j" [2 i. I
+ (obj.getClass()).getName() + ".");
+ U+ c8 M8 P7 e# V, ?$ ]5 M System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
2 z/ [, ~# H' U: y' a; n. S/ ` n8 A System.err.println("The process will be terminated.");- P0 T* \9 \% E' |( o# ~- ^! T
System.exit(1);
$ p/ C0 `! W& m return null;: M' F! Q' a1 y& R" h( B: O( X
}. `0 a5 w: ~3 m# Z) e
return sel;: s# ?: |6 l- E) X9 _' @6 i( D
}: ^! K; k! D) c8 R
} |