import swarm.Selector;; _: }$ r3 L! W; T& R( H d' s
5 q% L3 j% G B3 N. J
public class SwarmUtils {
6 N: b1 m1 ^8 z O! f public static Selector getSelector(String name, String method) {
T) a. z, z \ Selector sel;
* t2 i+ x: @7 x% e try {
2 [3 o9 u; j' G1 w* O sel = new Selector(Class.forName(name), method, false);) \+ r# M. L7 D J4 q
} catch (Exception e) {
: K; y5 n$ R0 T" c5 h System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");. {8 e* A, O" r' X: H
System.err.println(name + "." + method + " returns " + e.getMessage());& P6 k6 g6 k$ h _% V: }
System.err.println("The process will be terminated.");. @9 w1 } `) m1 P* n
System.exit(1);
6 O. e9 u- d7 H# z/ ` return null;8 ]* R) ^! H) F, p% k, h
}6 i5 V# p% H+ C0 [! X! M
return sel;: s" q7 t0 v5 R* D" r- Q# ]+ b6 f
}$ |; j8 Y3 g q
, ]3 `( Z. a f7 V2 ?: L public static Selector getSelector(Object obj, String method) {, V9 c4 v) k0 s8 g5 W
Selector sel;) c( t9 B* `. U. Y2 v, H
try {
$ B1 z1 k/ Z: ]8 P5 | sel = new Selector(obj.getClass(), method, false);
1 V$ d) s- H9 ?0 T, z W9 \ } catch (Exception e) {* \( h4 S4 J# y8 |! S \
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "4 W6 b- h6 x( D! N, p0 M: x! C
+ (obj.getClass()).getName() + ".");. T# r" E ~* ?' @, N
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());0 L( x1 H1 X! b8 B: s# z7 H6 l
System.err.println("The process will be terminated.");
% C/ R7 V, O7 W1 ^- k5 } System.exit(1);
% [/ d# P. r& u$ R% ?. Z4 @ return null;
|2 h8 a5 Y& ~1 O, b5 E+ \7 y5 p }! V, w1 r' |- v, Y# P9 c
return sel;3 x' ]( C/ F3 Q; O% d# L1 K, g! H4 Y
}
7 W# P K0 o( d2 R} |