import swarm.Selector;: F( Q0 P5 o3 W2 ]! Z" Y1 A
* g$ G3 q- \$ N' R: B+ H
public class SwarmUtils {' P7 H6 Q5 O( E1 \( X
public static Selector getSelector(String name, String method) {
& r; Q, p1 [) o. o Selector sel;
+ F$ _+ e) S- ^1 a5 s3 p- H try {5 _) c$ z+ ^0 Z! B
sel = new Selector(Class.forName(name), method, false);
" M' X: g9 S: i5 A; x$ H8 ]/ A3 L } catch (Exception e) {
5 O( d9 A* Q" n+ D7 Y6 H System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");, [6 L' ?; G ?' _
System.err.println(name + "." + method + " returns " + e.getMessage());9 w# M4 w7 o# |
System.err.println("The process will be terminated.");
' u* ]9 x) D4 W% } System.exit(1);" x& d' i( l' W2 n; r- o8 L. y
return null;
# g' ?- n2 G: Z/ t& Q7 u- R0 m; y }$ O' w1 | v9 l8 |" |+ f& x; w
return sel;
% }& l. w# ~6 F, I4 ^* t7 `' s }+ Y4 {5 m" T( k5 E9 C
5 u) Y- z9 O! s
public static Selector getSelector(Object obj, String method) {
$ _# S- W. N: p) ^) x Selector sel;
6 t: t- m% x3 @) G try {
$ g) p% [, w% ]! n/ M% l sel = new Selector(obj.getClass(), method, false);' V0 n: Z' L' F. S
} catch (Exception e) {" O! U7 }1 j& A J7 J
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "% }( M9 J+ V1 i- o% K
+ (obj.getClass()).getName() + ".");5 j# q& R8 r4 ]" e. ^
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
2 l, r4 a$ v/ D* z/ q, T System.err.println("The process will be terminated.");
* X; c! v' J) t( k1 p System.exit(1);6 ^% }2 F, V9 c$ y
return null;
! c7 {5 }- ^0 H* O5 b* y }! @% q6 ] ]; v7 }( w2 O: d
return sel;# l7 z/ R3 X- \' F+ j9 {
}
, U/ U" P" s% a- d} |