import swarm.Selector;
( R% {6 E' t4 P, g/ }- m) e
6 y1 F1 }# I( I Z: K$ X/ Ipublic class SwarmUtils {
. v/ r. {% o* |/ g public static Selector getSelector(String name, String method) {0 `( L/ @0 s$ x: t! z/ Z
Selector sel;
& H' I8 Y1 R2 Q8 K* f! O/ z t- V- U try {$ l% p: U3 F* ^' Z" N
sel = new Selector(Class.forName(name), method, false);' J, N) v. f2 ^2 |" x5 `1 o
} catch (Exception e) {8 h5 L3 {" w# O
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");$ a; O& e, k; ~( j9 z) H1 e
System.err.println(name + "." + method + " returns " + e.getMessage());3 m0 G% F0 s6 }
System.err.println("The process will be terminated.");$ k) Z# t1 r8 z2 i
System.exit(1);
. G0 O1 i% k" @0 @9 v return null;
8 m; w2 J. ]$ I3 M- e ?( Y }1 {$ I! [2 T K5 ]9 P
return sel;& g1 U9 L1 V/ ?) q' Q
}
$ G- w+ b# W! Z7 K7 d0 G2 x# c2 V+ D5 q& D$ ^
public static Selector getSelector(Object obj, String method) {
$ f% |9 J7 F; M2 Z Selector sel;$ Z0 N+ s0 }2 x4 a& x" F0 s
try { K; U4 `! x0 i3 C7 Z* r
sel = new Selector(obj.getClass(), method, false);; C1 k9 T. r& @/ k! C
} catch (Exception e) {- L. w6 M9 d- a {! F8 f
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "9 _7 g* L. A! B! ^9 {/ F9 t
+ (obj.getClass()).getName() + ".");6 o7 {- P5 U& s; l4 n4 E! o
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());: s2 k8 t% E6 b7 w1 i
System.err.println("The process will be terminated.");
4 o! O5 q% O8 _+ y& \! A System.exit(1);
' Y/ @/ @: `& O7 O$ b3 @' s return null;
f$ O3 U& l, N: u7 | }0 c/ C' v W6 r
return sel;
5 l! b/ ?& @ t& @0 g) Y6 F3 q }
- G& T( P! F V& O% B! p} |