import swarm.Selector;7 L! s7 i2 g8 @$ ^+ ^/ h
, e% w9 V( S& Lpublic class SwarmUtils {3 G9 c5 O$ D9 [ `
public static Selector getSelector(String name, String method) {
u4 u( r6 r; d/ V4 ^7 H7 S: K3 Z Selector sel;3 L7 X: L; h7 p# H
try {
8 K d( j) v' I% @6 V sel = new Selector(Class.forName(name), method, false);
( ~8 W& @3 v8 i5 \$ x } catch (Exception e) {1 z4 x& k: g! e$ t
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");9 g% b( I( }3 R! b- k5 c* u8 [
System.err.println(name + "." + method + " returns " + e.getMessage()); ?! d! y! m4 f* z0 t. D
System.err.println("The process will be terminated.");
' c, p( F) S1 N System.exit(1);0 I6 j$ \( S, _& F1 v
return null;& G2 e; J/ O! q: O) r5 M) T
}% ^# T; N' }( V0 m& P% Q% `, L! e
return sel;& P# _% R" \. u1 {' v9 Q5 e
}' P2 O7 i T, R+ t: }
" I% a9 M; K# \& H7 a5 h5 ` public static Selector getSelector(Object obj, String method) {) T7 s7 Q r' S
Selector sel;
: K( T" h: N4 h9 H try {! h: ?5 t: l' @2 A, h5 W3 J
sel = new Selector(obj.getClass(), method, false);" I$ j* i: |0 D" c' T3 C6 q
} catch (Exception e) {% r v* B4 O: T8 m5 D8 j
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
4 c" e W0 I& ~) D; V Y + (obj.getClass()).getName() + ".");+ P* n" B9 a" Y+ `$ y c
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());9 z7 E% J& S1 n
System.err.println("The process will be terminated.");
) Q8 t, P$ ]2 i- y4 o& T( z System.exit(1);
1 J7 d i( G1 E. ^& |7 D return null; s& T, M/ q" A4 O3 A
}; B% M6 c% g/ F' z2 G* N$ f4 A
return sel;* j3 q+ R. t8 H; I
}
" J5 ]6 p0 }* Z: A} |