import swarm.Selector;+ B$ Q1 x ~, j8 H
6 ? d9 C$ H: C1 ]# Y- f* mpublic class SwarmUtils {
3 |- m* ]" s# ?* i9 g public static Selector getSelector(String name, String method) {
" M, W, p% Y; N1 Q2 s7 K Selector sel;$ T5 i# I T0 b5 [) t
try {9 O. } P9 @1 R# o) X1 b7 F
sel = new Selector(Class.forName(name), method, false);/ L `; ]7 p7 C- l
} catch (Exception e) {
5 f' Y8 g* m3 m& j System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");' j" ^& P6 d8 z' \" x. V$ g" s
System.err.println(name + "." + method + " returns " + e.getMessage());
, K( m9 C4 r. [) `6 x( j System.err.println("The process will be terminated.");
3 E: p5 @( ^" {, E/ K/ {2 y% f System.exit(1);* L# r1 S0 _# o5 r) U
return null;
; s0 J$ M0 f* k. g$ k }/ w3 X/ |. J# d2 I& U4 }- _2 R0 }" ^; I! i0 |
return sel;
5 h1 C5 M2 f+ x$ N! K* C }
. n( Y f+ L2 S( a! S8 s6 N8 M0 j
public static Selector getSelector(Object obj, String method) {
3 e: p# r( Q$ m8 J- }' h9 q7 n2 d8 h Selector sel;
0 H# k, C5 B6 ]/ N( H/ J" s try {; H3 f, ]) q t. v Y
sel = new Selector(obj.getClass(), method, false);
' H7 u( \7 ]# i) e' p } catch (Exception e) {
+ b- p. n6 j' B4 k* f+ h6 H System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "; v0 S: k8 T6 i" v1 p$ |
+ (obj.getClass()).getName() + ".");( e$ O+ t* r' b# {7 I' I d" u9 R4 w9 ^
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
/ V# t* y& d8 X" _ System.err.println("The process will be terminated.");4 Y& J' S' x6 W {. U3 C
System.exit(1);: b/ G0 q N$ ?1 E, R7 l* {" w
return null;
2 _8 m/ T* s( i2 p- M" o" g }" q) g& G) H5 z" y
return sel; q4 m; }% Y9 E0 E
}
( _ B* K( N2 _" R} |