import swarm.Selector; b4 ~" Q0 i0 p8 z
$ Q/ {& y) c8 _! v7 J7 [
public class SwarmUtils {) |: B( I1 S8 [
public static Selector getSelector(String name, String method) {0 h1 t9 B ~2 \; F7 n
Selector sel;
4 j: z2 g4 K# k7 T1 s try {4 H# {) n$ q& E* h6 H- r
sel = new Selector(Class.forName(name), method, false);% L+ s' \! d/ C2 t; g
} catch (Exception e) {! k; i+ I! ~# a3 e u9 V- o
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
3 M6 {) j, x: ^7 w System.err.println(name + "." + method + " returns " + e.getMessage());. x" m+ n! O4 {4 q
System.err.println("The process will be terminated.");
& m# Z3 q# i9 X: v7 g System.exit(1);
& d, e# _9 B Q# G5 W return null;% b2 T7 m1 m' |5 J! d3 I
}# b! u. i/ d/ O
return sel;
( l/ I) s p P% Y5 V+ e }
6 [3 `5 R% y. v9 D& G! h# c9 z. i, V* e" g$ _- [% m8 ]& _
public static Selector getSelector(Object obj, String method) {% W+ }6 T/ v5 ?. z
Selector sel;
4 i# b3 D( T7 `( @3 A- N# m2 Y- X try {
' S' f6 ~" P8 Z* b2 }! S3 N sel = new Selector(obj.getClass(), method, false);
8 v0 D$ R+ R8 V' e! F1 \ } catch (Exception e) {
( h r( H A o& h1 }; n, z System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "* U9 d1 l) P) q" z. ^$ a* T( F
+ (obj.getClass()).getName() + ".");1 E9 B7 ~1 @/ S3 B
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());, e4 _8 k+ {& ^3 V% G
System.err.println("The process will be terminated.");
6 o# i0 S4 M+ G System.exit(1);
/ V3 C5 c9 I) J2 s3 C9 Z; z% u! {1 X return null;
) h1 ~9 {/ ]& i' m3 q8 \ } Q- R* j+ D& }) e
return sel;' d6 }9 E4 p! `' n9 w
}! q! h; e4 _3 F6 X1 |" |- k
} |