import swarm.Selector;
; t0 U$ f0 f( ]* g
9 J( I# J1 `, ^3 w3 T: ppublic class SwarmUtils {; y5 s3 E* N0 `' X$ E0 t" k/ {
public static Selector getSelector(String name, String method) {/ G1 Y/ r" d! o2 v( C
Selector sel;( [. U# u% m6 X4 U4 I; ]1 C
try { v0 g( g, m, {' H. C
sel = new Selector(Class.forName(name), method, false);
1 a$ f3 g, ], W" t } catch (Exception e) {$ Q2 F. b: X8 Z2 }& y v
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
5 a# `! Q& j: M! y p! _ System.err.println(name + "." + method + " returns " + e.getMessage());
# l( s. N& T; x1 v$ d System.err.println("The process will be terminated.");
@9 _8 q7 G; }. A System.exit(1);
0 F; P& E. K4 w& ~1 C r return null;' k0 l' @# g' H4 W0 c
}2 ~& b6 |6 A" b8 x0 L' T6 K" S+ e! O! X
return sel;
& z0 ]- F2 D0 W: `1 Z% k+ A }' F5 t! R% w* o% K. P" ^
) {! B* ?# a. D. r. B8 J+ t public static Selector getSelector(Object obj, String method) {
* n- v1 i( \% c" B4 } Selector sel;. b/ U3 U3 l3 e! t: c: t* ?5 j. s
try {
, r% `- t n/ t8 k sel = new Selector(obj.getClass(), method, false);
+ }7 i! l$ w8 v$ Q- o$ v } catch (Exception e) {
7 @$ [, T1 V& F* q. T System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
0 \" U9 C, \! m. x) r, m9 L + (obj.getClass()).getName() + ".");
0 U1 r6 A3 @3 ~; T System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());0 G+ b6 Q2 C5 B8 X' L' w+ Z4 X
System.err.println("The process will be terminated.");9 v5 m& r) z( c* p* m3 F
System.exit(1);* |9 M- ~/ V" C' e) [
return null;" l6 b$ e: t6 \7 X4 `3 j
}1 ^5 V" u) d# }- e# y7 K3 t
return sel;
- @: m. \# e5 C }
J4 w% d. h% K5 {6 F" G% w" c( k} |