import swarm.Selector;; g0 [! ?8 @& j, ]/ `( ^$ X; h
. G3 c( b) ~; i* E/ z! w7 o9 Bpublic class SwarmUtils {
% v# O8 k. d% O0 L: Q7 m public static Selector getSelector(String name, String method) {' V/ W% t5 v# Y6 ?
Selector sel;" ^$ {$ {0 f* f
try {7 }/ ]9 }; F; @9 Z/ @% o& p+ \
sel = new Selector(Class.forName(name), method, false);% O7 y: d3 U) x! k
} catch (Exception e) {
- h3 x' W0 ~" `+ n1 i! t# {9 a System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");* T4 a. l, ^0 Z M* o' s
System.err.println(name + "." + method + " returns " + e.getMessage());
& G6 E5 p& {# [ System.err.println("The process will be terminated.");
$ M. h7 `$ i. ~; }5 N5 R% {9 {( o, y System.exit(1);
- T/ l5 z! ^& A3 Q4 K return null;, V% E: w2 z* a/ w: x5 W
}
4 l4 Y' T! v8 \: k9 U! ^% W return sel;" ]# m% z( N& `/ B/ C8 x' x
}% r$ Z7 B7 [& c! W) B2 a7 z
. @1 V! Z# g2 y/ p! [7 p
public static Selector getSelector(Object obj, String method) {! u: I; S" E3 k. o
Selector sel;$ o& N0 t' v- W w0 B5 f$ _% _5 `
try {: m6 T9 |% q$ F: N1 B6 z, ^9 y N" ~
sel = new Selector(obj.getClass(), method, false);
6 R$ O, H7 q) q } catch (Exception e) {
- a9 {" L, Z" U5 ` System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "' Y9 \- U$ |; u- {( y1 v
+ (obj.getClass()).getName() + ".");
) l7 J' _ u& P+ P% O- [, g% ] System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());! r/ w0 |; N0 w! L1 w, u$ [& J
System.err.println("The process will be terminated.");) G* S" B2 u! ^( r7 Z7 P
System.exit(1);
! X0 S+ [! ^$ X! t$ V return null;
8 M4 i z& Z# u! x( p% Y% F) } }
8 g3 m/ e" R' b1 Y( d return sel;) r3 T1 f" e, r4 D2 F6 ]- O+ j
}
' \0 R- N1 k, Q+ [: {; t/ O1 B} |