import swarm.Selector;
4 u2 {' K! |3 ^/ d" l
+ |% q0 G+ S/ Spublic class SwarmUtils {4 S$ V' l& A4 e" h7 J6 e# a3 j
public static Selector getSelector(String name, String method) {
v. r# \% `7 Z. @/ i* o$ V+ W) } Selector sel;" p6 H! O( q; p8 P' U* f3 M
try {4 ?- p5 f* p* Z
sel = new Selector(Class.forName(name), method, false);
* V3 z: y$ f. O& B } catch (Exception e) {) m! |* a* T, Z
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
4 T0 Z# _' V3 t l System.err.println(name + "." + method + " returns " + e.getMessage());
1 ]9 e1 b) d7 d System.err.println("The process will be terminated.");
- y9 B" N5 @2 _' V0 o System.exit(1);* e0 |* Q N$ X
return null;! Y! W: U( L* m% v6 w4 T" n, m
}
: `3 u" Q1 P0 X1 p9 M& S! ` return sel;
. \- I( x2 w x* N' N) ?4 l7 s; Z4 z }# s9 m. v" z0 S6 n7 I) @* @
9 n1 I& U- L$ ]3 o, n" d7 U
public static Selector getSelector(Object obj, String method) {
+ ]3 G& E- r% c9 k. h# _ Selector sel;) D& l' ?* F v6 T% T# P
try {
! l' T* i% {* v# B4 n sel = new Selector(obj.getClass(), method, false);
5 d+ s8 q. ?# @$ i- v% i } catch (Exception e) {( B% X+ [: @6 ~8 `5 ^( ~3 [% o6 `
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "+ O7 x E7 I S: ?9 x0 M( l# v8 r" n4 L; |
+ (obj.getClass()).getName() + ".");- e( G: V# q V' w
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());3 s) v1 }$ s! x' Q' }
System.err.println("The process will be terminated.");' S2 T' v/ E; a( r% A( z
System.exit(1);
7 c) _: q$ M6 p return null;
5 r$ y5 D9 y5 u$ z }3 n, c4 E9 V H) r: ]7 ~ ^
return sel;4 r# o9 z; a; K" J* y# t5 H w
}* W* J% m; m" M4 S5 {( [% B: S+ I
} |