import swarm.Selector;
+ S0 U s r: B$ }) N0 o/ J/ g
7 w# F$ M5 t1 D! g( O1 f) D1 Dpublic class SwarmUtils {
- H8 k- U4 `7 U5 A N public static Selector getSelector(String name, String method) {
7 J+ k& l9 A& K& `( ? Selector sel;
; H% {- Z0 J o" |$ R( B/ | try {
2 \ ]0 e+ e5 U. e# g6 i. O, n# q sel = new Selector(Class.forName(name), method, false); R/ I4 Q) p$ `' n0 W
} catch (Exception e) {0 u. Y3 m3 H. _+ }
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
: P) A6 F! E/ [% V System.err.println(name + "." + method + " returns " + e.getMessage());& T$ [3 W4 f \1 N# O8 K6 F
System.err.println("The process will be terminated.");
! y% d3 f: D4 Y2 [/ i System.exit(1);/ O8 U$ G1 J) ^( B7 ]. O
return null;
$ I4 S+ G& F* K& x: x# k& k0 R3 ~ }8 ?4 B9 j4 y1 ]( q' z
return sel;3 P; R2 H1 `8 W9 A
}
' \+ O( y3 h, F R- Z2 S7 W+ m
E, W7 b& c2 H3 a; M public static Selector getSelector(Object obj, String method) {
* i3 m' f+ T$ t% H/ x Selector sel;
5 H8 e2 r+ K) I: J( U try {
; K( h; d# H! y9 V7 \ sel = new Selector(obj.getClass(), method, false);
3 [8 ~! G5 b' I } catch (Exception e) {
& w- v/ v% D+ {% o System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "2 G) z: @2 W6 h$ P$ ^ k1 A4 C
+ (obj.getClass()).getName() + ".");
( i8 T6 J9 a+ U, n% V7 q. D$ I- l$ D System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());) z4 h) ~' J+ V
System.err.println("The process will be terminated.");
% G! K% S% _2 W; N4 w' F System.exit(1);" h6 k1 w7 F7 D# L. b
return null;
6 z* I, O) [' f6 ]9 k5 @, b }, A. Z5 }4 d) V5 Q$ @
return sel;
, M3 k; _( V( X9 d }
1 [1 T* q3 y3 s- F( d, {, u4 m} |