import swarm.Selector;
& j+ }2 K/ g7 Y7 k7 l) K& m& e" {3 v0 j2 r% B! S
public class SwarmUtils {
: r$ \$ K, |( |' U6 @ A public static Selector getSelector(String name, String method) {
- Z2 l, G" A+ E7 r0 t8 C5 e9 D Selector sel;
. a' c8 ^7 Q4 y; }( r try {5 `9 c( d! Q; @9 z
sel = new Selector(Class.forName(name), method, false);
- {5 R, `* ^/ c; i* ?3 i } catch (Exception e) {' _# G% l0 y( E q" \
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
. Q' x# ?' k; e: c! ` System.err.println(name + "." + method + " returns " + e.getMessage());
1 ?3 F* R6 I" f System.err.println("The process will be terminated.");
' W+ c. A7 u2 }0 Z/ j% O System.exit(1);6 |: z+ k' q* j7 }% z
return null;4 |0 n$ G! q! R* Q2 j
}
9 Q' C3 N: i" I4 e6 ~' f# | return sel;% u* _% f5 d* [) n% z
}# x3 ^5 e' u, G: s+ e B6 P
6 f# w- O; k, `( N
public static Selector getSelector(Object obj, String method) {" n0 P8 H! g- \$ B5 r) e/ i- g
Selector sel;7 @2 p1 p3 ^1 t8 ]: b3 N, k8 i
try {
3 L8 c! ]$ R: G7 W. S3 A4 ` j& L2 V sel = new Selector(obj.getClass(), method, false);
/ p/ \: v' E3 `% J& M0 y" I } catch (Exception e) {5 o9 ?: H) w8 q5 r( C: m' U
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "2 f1 d: t8 Z2 G/ t& i
+ (obj.getClass()).getName() + ".");
% b6 M9 Z Y% ^( I" A System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
' V7 G$ a& n3 X9 p System.err.println("The process will be terminated.");
; ]; d+ V5 B' U0 g [2 M System.exit(1);
2 D; l9 S2 O3 n1 H return null;
8 s; r; ]8 u b8 I/ _% | }! G3 ]0 U ~: a1 n1 d
return sel;
( D+ o0 z6 ?, U- T) I* f }
& v3 H& `9 k5 e} |