import swarm.Selector;) Y' U3 B6 C& J9 u
: l9 X# f! p# U( C. c% d$ u
public class SwarmUtils {
0 X" o! ~( Y2 M4 I- g public static Selector getSelector(String name, String method) {
- L" C* F; y/ ?: V! Q2 h% Y Selector sel;( ~. W4 I6 p" s7 {7 \
try {( P" b& Y, C5 P
sel = new Selector(Class.forName(name), method, false);
8 y N9 y$ I/ Q$ ]5 I9 l } catch (Exception e) {
" m: K3 E# m4 C8 \6 n' C, @( ]% H System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");) p% V' A e' |- E
System.err.println(name + "." + method + " returns " + e.getMessage());
4 g1 C0 F9 |/ w5 z: L( b; |0 Q7 b System.err.println("The process will be terminated.");' l# b9 T7 Z* [0 e( K! R
System.exit(1);
7 E. O, r& b1 P. [0 k) W+ X! n5 V return null;. W" }5 E% b. L% a6 m/ E
}
' w! L. r; o2 J4 { return sel;
5 n' R9 W6 |# S5 D( k7 G }
. I% t y+ M8 t' V* r. [$ P9 I) \2 ~( C2 s/ O3 ?" q
public static Selector getSelector(Object obj, String method) {2 j4 ?8 a, ]& e# C ?2 O4 W$ B
Selector sel;, K1 e9 N# X4 G. C- R9 F$ G
try {& N7 F( |2 Q# ^; v. W" A6 |
sel = new Selector(obj.getClass(), method, false);, h/ t1 y2 l& E5 S( ^6 S
} catch (Exception e) {- J! L6 m, l! b( _; f" Y
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
0 [+ M$ _& b6 U) S$ o6 |+ u + (obj.getClass()).getName() + ".");
+ U. e- {' C" b" ?. A System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());! Z3 n; `8 M8 @" O8 ?: I& Z
System.err.println("The process will be terminated.");% ]$ t, d; A. j0 d- J5 v. R
System.exit(1);
3 W4 I7 w8 R& N! T: r; m. v return null;
: s. q! j$ \% o; D! `- N }1 e" b# d3 ?) Z6 ` v
return sel;
& b2 o# {' \5 `. L }2 r0 x2 z8 F; B2 d
} |