import swarm.Selector;$ U3 g3 p& {) b5 }- }
6 x/ L" ~4 T4 A7 Q$ j g- Zpublic class SwarmUtils {
1 f' l$ a9 v2 q0 B4 v& t4 x9 A8 ^/ v public static Selector getSelector(String name, String method) {; f( e* r ?& g# B F2 ^6 ?( e
Selector sel;: O* X! x1 t5 b+ M
try {$ t5 a% A/ _8 D! j* B
sel = new Selector(Class.forName(name), method, false);( j! {4 @/ }$ i3 q+ e+ P3 H" A
} catch (Exception e) {; j5 Z) }/ A7 v2 Q# t# B
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");+ Y. `* D% z2 Z9 T7 U% z
System.err.println(name + "." + method + " returns " + e.getMessage());! C' M; p% q& Z1 z# y( h
System.err.println("The process will be terminated.");
* c; a# K d& U; N8 R/ Z6 ~+ M System.exit(1);" m5 @) R9 k% y U! q
return null;% `. a+ K ?$ A k( ^/ H5 Y/ N
}
$ z! C0 j9 Z& v2 g7 U return sel;
/ E& L8 O9 O+ z7 ^" j }4 H! E' N1 d+ E+ d5 u7 A4 k& N
/ {, A* S! M9 n/ t' [! R
public static Selector getSelector(Object obj, String method) {# a! M% l3 |8 S1 M* M+ V
Selector sel; P7 l" K. b* t( o
try {
9 V+ n& R( b }- M, ~# \1 w sel = new Selector(obj.getClass(), method, false);: h1 j8 D! \* H h8 O
} catch (Exception e) {% n' J s( _9 F- w& E9 S q
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
) }& \" H/ q' d. j; H0 j# |: M# r + (obj.getClass()).getName() + ".");
+ b. R/ _2 |, f# A System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
`3 G, v }- Q$ T- y System.err.println("The process will be terminated.");9 i9 Y H. j* ]- W% b8 M
System.exit(1);9 T+ Z* i9 z2 W
return null;
. ~: t) t/ |5 g, w) a- M8 C }
5 N7 Z7 `4 P: g& j* U# A% c% c" q return sel;' ]5 U, b8 }4 O' y0 k# v
}4 O' H5 ~ j5 c( U5 ?7 C
} |