import swarm.Selector;" _' E& Z. B( y4 @( z$ P* n/ r
9 P& ?7 u; n% j2 z0 c8 ^/ y
public class SwarmUtils {, B, O9 W( w# c. r3 n4 \
public static Selector getSelector(String name, String method) {
7 k3 t0 d$ U( `, U Selector sel;
3 E& N5 S- L! b# A try {6 p, r! L+ }/ x9 ]
sel = new Selector(Class.forName(name), method, false);3 w7 A4 n( ^6 Z" N/ x$ d. X1 J& C$ a
} catch (Exception e) {0 c; G( U8 _; ` } r( t
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
2 }1 \' x0 K z, t! L System.err.println(name + "." + method + " returns " + e.getMessage());& @; [1 g' E2 b1 B
System.err.println("The process will be terminated.");
?, n H9 n" F6 O7 o$ R System.exit(1);
. q" p8 C2 s( P, Q, U' { return null;- O3 Y, h3 \ b7 g
}8 U% T! c' f3 x- l% U. g! A, ]
return sel;
. g9 D& {( X( F }
6 t- K/ P) Q6 N K! y
4 u( f! q* v# I- k$ g, e: B6 S public static Selector getSelector(Object obj, String method) {/ |6 g& w) A, u! W. |
Selector sel;
S2 U+ J! j1 Q* r try {
?1 y# [; v8 s* c5 G0 g) b i sel = new Selector(obj.getClass(), method, false);: |6 D5 g/ H1 a* Z; L" H
} catch (Exception e) {' k. r9 E8 U1 }0 ` ]. c
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
0 i5 N" q# B) }. z, _; w' }! \ + (obj.getClass()).getName() + ".");
' s3 z) \* n$ C! m: W3 I System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
3 v% h+ A" c% @6 [0 s System.err.println("The process will be terminated.");
% f* W0 c# j; ?" A7 h% j+ Y6 |# I System.exit(1);2 n/ H) D) M( J
return null;
9 U; z& d+ m% h3 p) I }+ g8 U: R1 h9 w2 p" j7 |
return sel;- Y7 n/ l5 R' L$ `# ]
}8 p% M0 F% g6 V/ p+ B
} |