import swarm.Selector;1 @4 `3 ^3 E: l9 K. Q
' `6 H6 j& x9 ]* J8 R4 Ipublic class SwarmUtils {3 c8 F1 U4 K! U( P
public static Selector getSelector(String name, String method) {
$ G) t: M: v( `+ j5 x: e Selector sel;
: R) ?* }( G3 u& s1 ]: m try {. y1 B1 m/ k* h5 c
sel = new Selector(Class.forName(name), method, false);
; R' v* p% {# m( f% A4 S8 F } catch (Exception e) {
9 d$ x' n: w0 Y2 P1 ~" Y9 _ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
# }" C v) x( o4 r( x2 z System.err.println(name + "." + method + " returns " + e.getMessage());3 _$ f2 W% i: a# A2 V: v6 [
System.err.println("The process will be terminated.");
. N4 p9 v8 `) G$ y/ l3 D System.exit(1);. d: n# {' M- G2 T! O! b9 c9 N
return null;9 K" x. \& I# s" @$ |
}
2 \5 `. T5 G" z1 x4 T return sel;
4 w- M! `+ P. o3 x0 j }
7 ]# A0 P# C! s
5 k9 B/ `$ t- L8 m+ z* A public static Selector getSelector(Object obj, String method) {! m8 ?+ [& X/ N
Selector sel;9 }( ?" G4 j& R/ o2 s. ^
try {( z4 e2 P F6 p2 ]* [
sel = new Selector(obj.getClass(), method, false);1 N* n5 I% o2 ~. [5 p
} catch (Exception e) {
( ]5 V$ q; _# _) L System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "+ ]/ S/ ?$ Q/ n9 ?' r& _
+ (obj.getClass()).getName() + ".");
$ ~, W3 a: h# E0 A3 g% U System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
( |4 h! L! j; f0 T1 s System.err.println("The process will be terminated.");
7 [8 e# S! z6 V& _1 [ g System.exit(1);
3 j( |% |( _+ | return null;
8 R' e2 _/ i$ w# ^6 l }
4 s6 U u) k, G8 p" p. S return sel;/ ]! \ k+ o' N. X1 h
}" U) C9 b$ I) ]2 w" t( S
} |