import swarm.Selector;
7 A* _( `2 m) N! b8 r5 H+ o1 L
. b& w9 h; ?3 i2 L" Y/ ^7 N, r4 W" dpublic class SwarmUtils {4 F9 U- m2 `& }1 P' R5 Z% F
public static Selector getSelector(String name, String method) {
: C' F) h8 m0 g( q P* a. s* {: O Selector sel;& k6 P6 z7 i+ \
try {
" L2 a) d: o; F5 s, e1 _% X sel = new Selector(Class.forName(name), method, false);5 I7 s; F |1 h& B7 Y7 T% x: G
} catch (Exception e) {" R& V; Z! i- v, p% l9 I. h
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");. }3 F2 W1 Y! b+ z6 y/ {5 v
System.err.println(name + "." + method + " returns " + e.getMessage());8 n* Q: o/ P- j
System.err.println("The process will be terminated.");
( ^3 ]! s, ^7 \/ R: Y System.exit(1);
$ x* U8 i! |% T ?0 E return null;9 P. Y# j3 Z, C; ?& @8 R
}
: u9 r, B1 t5 x4 T return sel;
- h- N1 F( f) ?0 d }
7 o( W5 \* K' [1 D9 `$ I# v; C9 ^& t& I6 S
public static Selector getSelector(Object obj, String method) {0 H+ x5 i/ J3 j3 b, M7 |2 `) r3 Q
Selector sel;0 r( x1 `- R: Q! P
try {8 s/ }* }! V& i/ C! C2 N T
sel = new Selector(obj.getClass(), method, false);
0 T, J+ U/ \! R% y+ `; _$ a. B } catch (Exception e) {
) `* t. Z) @1 ?6 r2 A. r5 C& E9 r System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "! y- X$ W9 A6 A" l( t
+ (obj.getClass()).getName() + ".");
- T. M4 Y6 `( F* ?3 C System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());* c1 P) t1 c2 X9 u' {
System.err.println("The process will be terminated.");
7 R, w ]6 u2 M$ u9 H System.exit(1);
' \& K) m) h2 b return null;9 R% r2 U1 ^* b9 @- Q- q' J8 |
}
; \ ^& N9 B8 V: } return sel;6 D H' N: }9 e) @$ A
}
$ W5 V/ K5 \" k# t} |