import swarm.Selector;( t3 G0 y# m6 d2 d
- Z/ I! a n5 R3 q' \public class SwarmUtils {/ ^2 L( }" R. L9 Q
public static Selector getSelector(String name, String method) {# Q. ~2 b7 \$ u% c2 f+ C
Selector sel;
& ?) i; \+ E1 U- k; n" j try {
: B3 {9 `( U2 C sel = new Selector(Class.forName(name), method, false);* Q0 d) K! k+ \4 C7 U; ]/ c. V
} catch (Exception e) {, m% f5 a, f1 M+ C2 k$ h& K$ ]
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
. {' Z' V; V# K; \* q System.err.println(name + "." + method + " returns " + e.getMessage());' p0 ]1 I+ i/ K! ^3 Y& @" N% |, C, E
System.err.println("The process will be terminated.");' G0 n" E/ L& z6 v0 O! a
System.exit(1);! n/ f3 P5 {! [9 R5 g
return null;+ M) G% C% s3 n! Z
}( }3 D0 S# p/ l9 ]! D* N
return sel;1 v6 c& s4 ? I0 e& v. x& _/ \
}
; K, r: f7 K7 N0 x( t
* }" \6 j O2 Y5 u public static Selector getSelector(Object obj, String method) {5 C# }. Y/ e w7 ^6 _) ?
Selector sel;7 S3 {; x$ q* g- K; |
try {* f7 r ?% `. s" Q0 }
sel = new Selector(obj.getClass(), method, false);5 E5 L. C& [' U) x3 J8 t/ @6 H& f# z
} catch (Exception e) {
9 p0 d$ H' v/ n7 U8 H; g$ w System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
4 O1 v" I. H& ~& l/ p, l+ X9 q + (obj.getClass()).getName() + ".");! ?/ }& i0 U0 w+ Z2 k
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());: x2 B L% `1 x5 G# P5 h
System.err.println("The process will be terminated.");
8 B2 ~ a) R: H& K. ~; I+ ~4 L7 L, c# b s System.exit(1);- p+ M1 {" O- K; t3 d
return null;
8 j0 H; f1 ~$ B- v- f }% l" f9 J5 j3 `. O4 N4 {
return sel;
1 @( C1 U% L* q6 W2 X* p5 G }* A; H6 N: |# i2 v# P2 M/ p
} |