import swarm.Selector;, i2 i5 p8 |. j5 b0 O1 ^5 l
( q5 O z# D; x! v' S, {public class SwarmUtils {, K0 D$ i- h& e( W8 [
public static Selector getSelector(String name, String method) {/ ?* U1 P* j b
Selector sel;
V: t+ ?' R8 _! h5 R$ ^3 I% P try {
: j5 n* s& \! q. a f3 c, u0 a sel = new Selector(Class.forName(name), method, false);
' g* D2 d8 _0 J } catch (Exception e) {
3 S" A/ c) }9 z: `# r System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");5 J% Q/ _2 L. c9 T3 J1 W
System.err.println(name + "." + method + " returns " + e.getMessage());
6 s7 A& e- @5 k. T9 Q4 t; ` System.err.println("The process will be terminated.");
9 I; x$ L/ d0 _' L: k" ~9 E7 D( I System.exit(1);
$ O- @% D6 p0 v5 b2 y& i7 D return null;* k8 u9 t) y7 i) [! s8 b0 |
}, {, W8 k$ h) s; j- n& n I# D
return sel;
+ g5 L! Y6 ~9 J/ }0 u4 r }' Q F7 \/ h6 B) L9 C$ W( q! k
# L" O. j$ @/ R' @9 i- c public static Selector getSelector(Object obj, String method) {
5 f& {4 Z7 S3 C; T! M. ^ Selector sel;9 b. |( V( Y/ t% t7 c4 d' V
try {- o5 h3 v4 c9 a& Z2 Z% d
sel = new Selector(obj.getClass(), method, false);' G8 L/ P" \ I5 p% A+ o) [, f
} catch (Exception e) {5 u y) Q7 l( a
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
8 ?- A6 s4 z$ S9 _ + (obj.getClass()).getName() + ".");% m0 ?% i, u+ [! r6 v1 L
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
* f) ^0 n- r$ ?; r+ }- X System.err.println("The process will be terminated.");" S4 z6 i; g- u) R1 H, a2 _( T
System.exit(1);
4 p1 Q3 a, s2 p7 l4 [5 F return null;
9 O2 Q* S) u; R7 x# s: D5 P# ` }& |; m: t% l& k- [" g% k
return sel;
- @' }' m* y0 B' m2 f6 Z) i: y }3 X( c$ Q* d$ Z# }
} |