import swarm.Selector;* L9 i0 m. Y$ W2 K8 }& O
) k- z* B& w# j# U3 z0 M) g+ Zpublic class SwarmUtils {
/ D7 l, C( d) [$ G7 B V public static Selector getSelector(String name, String method) {
2 B) k8 j: T% T8 C Selector sel;
8 N* Y1 [! v z G) `; {: m4 }7 A try {
6 F4 _/ L7 B1 h+ g" Y* y& | sel = new Selector(Class.forName(name), method, false);
9 S, ^; ^( i* V0 z$ j$ @* ] } catch (Exception e) {
* B% H# r8 }9 K" N% s. y- t* A, ? System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
* r7 S0 W+ T j j System.err.println(name + "." + method + " returns " + e.getMessage());% K! h" ?2 G7 g. }9 v- `6 l- k
System.err.println("The process will be terminated.");
/ W8 V) g) V1 G System.exit(1);' V# K7 O) ]6 V$ e
return null;
' K- e# [" D0 K5 O1 t }( y: c4 e3 I* o# @1 V
return sel;! i$ o# K' C) c7 L6 d7 {
}
7 W& h" _! @! M: C* q+ m
5 J& M- f5 N& E: A. N0 _2 C public static Selector getSelector(Object obj, String method) {# e! r* h2 t0 R. l4 r) ^* Y
Selector sel;
) `% ]4 M$ a) M4 b try {7 K6 d+ g9 `( _3 g) R8 d$ O
sel = new Selector(obj.getClass(), method, false);2 u" k/ ~& G9 U# _8 O# x
} catch (Exception e) {
8 g$ S+ }7 y8 l' \- W. D$ T( ] T* \ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
: i7 L$ G( Z: G3 D0 v3 h + (obj.getClass()).getName() + ".");7 c% d+ A5 Q: V$ K
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
/ w4 U$ \; l$ _" k$ G* Q( B System.err.println("The process will be terminated.");
0 L: i P0 W. b0 b; ~+ i% y* T System.exit(1);
; V7 A1 r* ]: ]: @7 q9 E return null;' {! R9 n; n0 ]9 W+ O
}0 Q0 W6 z. g$ F5 ?+ X
return sel; M$ ?6 \% i! _: s W5 c9 k i, }
}1 h+ o$ m8 G+ ?7 R# k; P
} |