import swarm.Selector;1 t; c7 F7 D2 Y# s9 m
7 V& y9 }, z/ Xpublic class SwarmUtils {7 D8 _/ u4 p" k# U5 ]: \
public static Selector getSelector(String name, String method) {
3 J- H5 n! f @ Selector sel;
6 H) M) \0 H2 B, o" c# i) \( t- ]: n7 t try {
0 v2 s! r" S4 S3 k- i sel = new Selector(Class.forName(name), method, false);
8 r4 j% t' l* k+ o7 u$ p# x } catch (Exception e) {
; W" C; R0 X9 Y V1 K System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
5 v8 I/ o; @# j( y6 g1 W. {4 K, J System.err.println(name + "." + method + " returns " + e.getMessage());' k% X5 F% N8 K) w* u0 a
System.err.println("The process will be terminated.");
3 Y/ v/ n8 U+ E- z; _/ z System.exit(1);4 u4 z3 S* R* K
return null;
: s. ~- _( E* X( d }3 K* g4 C1 P8 w; o( @
return sel;5 P/ p- R: \4 n4 I' f
}
8 N* R ^' A5 K2 G* `
) o1 E4 I% [* R5 v% s1 @ public static Selector getSelector(Object obj, String method) {
2 X' d& @$ A! |- H$ K6 M* P! O) ^ Selector sel;
" h) u _$ Q$ n& L, Y9 A try {- T; S3 [' y! P' X( e. `- i4 W O8 A( W
sel = new Selector(obj.getClass(), method, false);
9 w3 d* a4 ?% t7 Q; H7 E } catch (Exception e) {& F' x( R" P1 ]* M& x& v
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
# y$ ^# g- S9 Y3 J + (obj.getClass()).getName() + ".");
1 K0 ?* R) P: u$ S System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
7 A- N2 R- x( ] System.err.println("The process will be terminated.");7 t; P9 t4 B ]& M( P
System.exit(1);7 |7 j1 a* _% L) k6 ?# R
return null;
$ d: E6 {% O" [' q) B# ` }
. u. ?$ U" X1 u$ r2 `, f% M return sel;
2 a9 m3 D8 q1 \) c, M: @ }# _( @$ G! Y$ _; }
} |