import swarm.Selector;
6 a3 ? T% a% o2 x" X
2 j) k( Y% ^1 ^# Kpublic class SwarmUtils {
$ F/ I5 R) u" e1 W7 s; \4 B public static Selector getSelector(String name, String method) {
& ^) N$ ]) |, X1 A/ I2 j$ D Selector sel;' o+ m9 R! J7 F+ C* ?. e
try {
% D, w* a3 h& ?9 c) F# h9 L sel = new Selector(Class.forName(name), method, false);
5 b5 \: `1 z/ E$ b$ l } catch (Exception e) {
. U6 A% G+ }2 z System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");& B: g- ^& b( }2 K5 d8 ~
System.err.println(name + "." + method + " returns " + e.getMessage());
7 c+ Z' b5 L3 R4 q S. o# D; S System.err.println("The process will be terminated.");: b3 ^7 @1 d6 y% W. j( ]3 A
System.exit(1);' g( ]9 h+ y$ s6 ~3 c8 E8 ?
return null;- w* l* N* U! s) _. Z& T3 h
}
8 M% i1 m6 v9 {$ a: r. Z return sel;& S) Q9 E6 [+ V" {# H9 B& c
}
5 a8 Q- E5 }! _* t9 a
) Z# d; ^1 P. l- k% P public static Selector getSelector(Object obj, String method) {" U6 d! ?8 T0 ] j! L* F
Selector sel;1 }) c0 {; n5 D6 F; X0 ^, g
try {
4 T( M3 E: r, P4 c6 H5 i" p( b sel = new Selector(obj.getClass(), method, false);
* c7 T, z: W' E& V6 [8 [# i } catch (Exception e) {
; O7 W& M# s( {* P+ Q System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
$ v3 p+ f* s2 w0 I; k + (obj.getClass()).getName() + ".");. ]6 N7 }& T7 y% a- E! M
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());. Y! S. I+ f- j k
System.err.println("The process will be terminated.");
$ ?/ M, w0 U' p( h4 g3 m System.exit(1);' P! O0 P3 \( v1 u# g9 r3 ~0 s
return null;5 @! G8 L" K0 h
}( X6 h& [( z- r0 X8 c
return sel;* P, o% ~+ d5 H
}: D" C- D9 v$ I. C1 c5 s
} |