import swarm.Selector;2 K5 @: T7 `0 X8 ?3 G; y
7 t, h% `, P. v: C
public class SwarmUtils {
) R2 u& y) V8 B$ L% Z5 \1 o public static Selector getSelector(String name, String method) {
: M1 \1 U+ e: x6 M: D0 d Selector sel; z* m* s! _( {; e* R
try {/ }6 C( ?+ g+ c/ L# {' b- i; t
sel = new Selector(Class.forName(name), method, false);
7 v- W+ s3 R# [% q# b } catch (Exception e) {, u. _3 k% _' T3 U( g
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");3 c4 ^5 r% e7 K
System.err.println(name + "." + method + " returns " + e.getMessage());9 X, m9 O2 B; r
System.err.println("The process will be terminated.");
2 w; _8 r ~+ F5 n System.exit(1);
7 q4 A! H# l) s return null;5 I3 m" L' R* X$ T8 Z" s
}' z% F& U. r3 o- n/ i9 V/ Q) y& l
return sel;" ~+ s4 X5 b* E6 Z6 M
}+ `- X6 k7 f- v/ p
. [/ O- g! C! _3 M q6 f, U) Z
public static Selector getSelector(Object obj, String method) {! v W! b2 y8 a/ H) O
Selector sel;
. w7 g& J" C$ P4 Z: Z1 [ try {
" G# P% r( n9 V" C, u sel = new Selector(obj.getClass(), method, false);
# h& }) ^4 a4 i' E( @ } catch (Exception e) {# C% P" A2 v, X$ j- d
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
& X) c* F3 z. I: t# D; ^ + (obj.getClass()).getName() + ".");
* S( p0 c# l5 N9 x+ ~ v System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
! R0 {; Y8 \3 Q& W System.err.println("The process will be terminated.");* o6 x$ R) ^& j4 K7 n+ l6 p) T
System.exit(1);+ X* |1 o" |2 P7 I* z: l# I7 c: |
return null;0 |* G" r' Q* h; q% j; o3 ]5 q
}
" x! z: H, R2 [3 s9 ` return sel;5 G; w# w2 }1 q' I6 X* @: F7 l
}
( `' z, ?" q% T! `2 T% }} |