import swarm.Selector;
) N K7 [7 c" T+ w
& r4 z. }& W6 U, ^8 }6 s# e3 A; n) opublic class SwarmUtils {
- |+ A$ e! I+ o% g9 X1 \6 y/ H public static Selector getSelector(String name, String method) {: O+ b$ i2 K6 ^# c# d
Selector sel;
6 E: H9 _0 l$ J0 ^$ ] try {
1 ?& @& D- U6 }# B4 ]9 K( Q7 C sel = new Selector(Class.forName(name), method, false);+ y2 c) b& G g
} catch (Exception e) {& X' s* X) }* n. r% S
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");# X4 I8 l# M5 I8 F2 _' [5 R( Q/ W
System.err.println(name + "." + method + " returns " + e.getMessage());
" Z+ j# r9 l, F# I# M) | System.err.println("The process will be terminated.");$ x1 K1 r: v* b' I7 m
System.exit(1);( C+ T5 m6 l# W' P! ^( p
return null;
2 n( x; @1 R$ I6 M1 ^* }3 p& G! Y }0 F, b, \2 S: D( ], V# `: j/ u
return sel;1 \1 n0 U7 n) c* E! P
}
8 R. O) @( z: ~! `6 a( W9 Q% a
% p4 U8 }$ c, T* P; D+ B public static Selector getSelector(Object obj, String method) { L9 U5 _" s- G! I: m+ x6 o
Selector sel;
" F' u7 u5 G- B. s3 b' z try {4 b, D+ J. D6 A
sel = new Selector(obj.getClass(), method, false);
( V" F) W! F6 E- [$ e } catch (Exception e) {
& Q0 O9 a9 H3 H. K System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "3 ]' I, n8 q1 V. ~3 @
+ (obj.getClass()).getName() + ".");
7 K7 z$ `- o7 Z3 @ System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());' o+ \ V' ~2 y
System.err.println("The process will be terminated.");. F+ x' n# k, v- \% m
System.exit(1);: Z) v* R( p9 L+ w/ o1 n( ]. M1 s
return null;
9 s9 ~( k8 k, u( g- w' s, P }' D4 \) t4 a3 S
return sel;. t7 C. B) X1 b$ V6 G/ |1 q
}: v8 ]$ c( K& H* o) t7 p; ~
} |