import swarm.Selector;
, I% @" Y% `8 r: Z% w
" ] j0 r( W4 ~. npublic class SwarmUtils {
/ S8 E/ Y4 q( T7 R. }, Q3 ? public static Selector getSelector(String name, String method) {
! o3 V# u& d/ R; Q5 C% ?9 A/ u Selector sel;
* T6 U3 x2 T4 B: |- Q4 F. u try {
! z# _5 F* D3 Y; q# l sel = new Selector(Class.forName(name), method, false);
+ ?2 a: Y+ @& h, i: Z } catch (Exception e) {) h; O4 [# e/ |) j4 L* ?6 I7 X- y
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");( v& C# u2 T% T
System.err.println(name + "." + method + " returns " + e.getMessage());
0 k4 H t/ `8 ^2 K System.err.println("The process will be terminated.");
' j3 D/ P3 C: L O6 G& _* T System.exit(1);
* Q; H0 d* u& B5 f return null;+ G( ~, B2 G1 y6 ?# K
}
; G% l# h0 F% j5 b return sel;* m1 D$ n3 K3 F9 K; {6 S+ Y
}
6 l9 t" D( E! B$ w0 B: k; ?. }' q% B4 ]3 U1 d
public static Selector getSelector(Object obj, String method) {8 R# U" ]; v6 J5 l9 a9 D
Selector sel;* U$ Q+ X# d$ L& L7 f$ |
try {
/ c# h3 y: p7 `" D sel = new Selector(obj.getClass(), method, false);
+ c+ m( ?/ B& `2 o% a } catch (Exception e) {
+ i2 A. j; U8 D! v/ Z4 S System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
% O8 G- u. b* [5 i% | + (obj.getClass()).getName() + ".");8 Y. V& V4 M! @6 M$ L( L0 x+ i
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
, G4 `8 S9 j8 U- r8 q System.err.println("The process will be terminated.");% \6 L- O! b: @' j: v$ j% y
System.exit(1);7 q5 f: m0 z6 P$ E- f$ V! ^
return null;/ X( r! s( N2 I, f7 \6 F; D% P5 X
}
" n) ^2 W: ^% F7 L! }. q return sel;# D& L& J; F. o. X
}, {- q; U8 n- J: H i C$ q
} |