import swarm.Selector;0 S+ n* ~8 j) n$ ^! L$ |: @3 W
/ m7 x& C/ _7 R/ C. _* lpublic class SwarmUtils {
; a8 d R/ M9 D0 b! f* Q public static Selector getSelector(String name, String method) {
7 E3 {+ d" r3 m Selector sel;
" p1 ?% @, h% w: Q) \ try {
3 v$ J+ {7 x. ` sel = new Selector(Class.forName(name), method, false);! d. F8 v, o6 D
} catch (Exception e) {6 d& L7 h" K9 s& {1 I6 O4 b
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
. C$ C6 p6 Y! q# b System.err.println(name + "." + method + " returns " + e.getMessage());
3 d9 M- b9 H, p! M. z: h; O System.err.println("The process will be terminated.");1 e0 S" i' n/ Y3 S9 f& c' O9 [& _
System.exit(1);
' B6 V9 I, h# }( c) F+ m" \ return null;
G' u/ H1 x8 y3 g/ L }
! c; d5 i/ S2 e0 V' N return sel;; m. U, X4 c8 A+ B9 `- ^. [! G( v
}
& V) c8 @: u+ m0 y% L1 K# S: H% V( ?' [# k" I$ N
public static Selector getSelector(Object obj, String method) {; @- i4 Y' t6 N7 V
Selector sel;
[0 ]0 ^& |% U try {% @3 v% h4 a2 f5 [# K, X. H
sel = new Selector(obj.getClass(), method, false);
' l* m1 w, ]! R9 G } catch (Exception e) {6 s Y# D+ f! @6 P7 v6 n
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " V0 `( S( v$ ?( f2 \' d8 s6 A
+ (obj.getClass()).getName() + ".");. G# v. z* U1 U! _+ A
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());9 c- m& u) D! j, |- U: L
System.err.println("The process will be terminated.");
6 ?& u t* F- ~! W9 o* q0 @ System.exit(1);9 u( G; ]# y/ s7 K" [
return null;: g- z: ]( E/ y% [, r1 S! w
}! r+ q8 Y m/ p' Z
return sel;
* S4 L! m( Y5 r3 T( x9 F8 `8 B }
# E( l% A. s) k} |