import swarm.Selector;
I- M. D" |- ]6 C2 D) G* J
$ L/ p e# o% G. D4 S6 ]public class SwarmUtils {
! C% t! s& e( Y; H public static Selector getSelector(String name, String method) {
% k# F0 V$ ]+ w- i) U: T9 k7 O Selector sel;
. \* A% X* L& d8 ? try {4 p" j. ]) e& \ Z
sel = new Selector(Class.forName(name), method, false);
. \) m$ Z+ M9 f } catch (Exception e) {/ Q$ i% ~ F4 |" \( s t" x
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
8 v6 z, a; B: ?8 Q System.err.println(name + "." + method + " returns " + e.getMessage());
! b: [6 n$ q6 U0 J* Z System.err.println("The process will be terminated.");
. Q# M8 U$ ~5 l" } System.exit(1);: r' G' L$ z# b$ T5 c
return null;4 ^7 P* a3 o' H( L& [
}
" r: E \$ A2 T. K1 x return sel;
2 v, a: M- U- }* r9 ? }
( N) `& F6 @. O! m0 @6 X2 y+ @+ p* y c5 n2 S- M* D+ n2 `2 f' b
public static Selector getSelector(Object obj, String method) {
8 L7 Z9 T* v/ M( j8 O/ p, _" q Selector sel;
4 Q2 M- Y6 R4 S try {
$ V" W# ?& o1 P sel = new Selector(obj.getClass(), method, false);$ X* D5 H- h$ s. P4 z! z- m0 u9 i
} catch (Exception e) {8 Q+ S$ v4 a& _$ h* e3 q
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
7 c- h' @# {9 ]0 }5 @: j$ c. a + (obj.getClass()).getName() + ".");
. b& D( X' f+ D2 f' d$ D& D8 ` System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());$ ]8 s! e9 o' U3 q
System.err.println("The process will be terminated.");
+ j1 c* E9 U* r System.exit(1);
! \4 V; w/ Z& E6 w return null;
M* ]3 o) v# M# H/ w% I4 J- E1 C# z }
+ q; b* l& @2 y! h% B return sel;6 E, S S- B$ }" [& h
}2 p) B; y4 b3 W0 R; b% A, `
} |