import swarm.Selector;+ q) m1 l+ Z$ a+ i* r5 {
/ L: y5 v, j7 r( j2 `public class SwarmUtils {" _* r' B/ U$ J! N0 U
public static Selector getSelector(String name, String method) {! ?# o8 C, L6 V! K
Selector sel;% r" _- O3 A2 K- h
try {
' f) C9 h8 f8 T2 }7 b( T sel = new Selector(Class.forName(name), method, false);
2 R6 o# N* d1 p; |: j } catch (Exception e) {
; G- S: ]7 \, \' ~; D, w5 ` System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");$ {+ \6 |# C' ~4 d* u5 @, x0 r7 [
System.err.println(name + "." + method + " returns " + e.getMessage());0 b2 W/ Z g" r
System.err.println("The process will be terminated.");- X/ G# V" _: u; ~
System.exit(1);
/ Y4 R1 T ]8 ~' m return null;
/ F F( S0 }5 R' n+ q6 { }
+ G+ m* w* [6 Q: M return sel;# D" E6 N1 I: j) ~1 I
}
2 Z* _7 I' d! W* N1 Y5 }5 G% t3 ^& t7 ?% m* ^- x
public static Selector getSelector(Object obj, String method) {8 h8 K6 j" y8 h, e
Selector sel;
% f6 F3 y& E+ F& b9 o try {
. d! v4 Q. f6 v ^ sel = new Selector(obj.getClass(), method, false);
9 Q* \& \0 `( F6 u5 ^. O+ m } catch (Exception e) {
0 @1 ~ v- b) A& Z4 g System.err.println("There was an error in creating a Selector for method " + method + "\nin Class ". u% m0 A. }7 {- D+ K' V; a
+ (obj.getClass()).getName() + ".");' G: Z& D: t7 g7 ?5 Y
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());% {9 q# T* F/ \, n# r
System.err.println("The process will be terminated.");* e% r2 P! N6 a$ s
System.exit(1);
# y& }2 W A( S; W return null;
6 Y! ?# a- H! K8 c/ Z5 m }0 x, F4 S% {: z/ @
return sel;
8 S! X) r, D) [* [# ~$ H' K }
) k8 l* e6 s* w} |