import swarm.Selector;4 @+ @# z) d- `2 i1 `& o4 U0 T
9 w7 H* Z2 {" b* E! Apublic class SwarmUtils {
7 ]. t& q8 ]9 ]1 I5 _1 W6 _ public static Selector getSelector(String name, String method) {
9 A* H5 G- ^4 Z) g Selector sel;1 ]- T$ L! Z6 w# g7 o: U7 B6 r: I1 A) i
try {
/ Z* S! c9 Z) ]8 t* l sel = new Selector(Class.forName(name), method, false);
0 Q% ^) l R% j C8 [, m; w8 x. U/ c. H- X } catch (Exception e) {" x. S/ ]* m7 K: ?
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");* U* e- y9 m" l6 d/ Y) ^
System.err.println(name + "." + method + " returns " + e.getMessage());
, _" \ x {0 W6 o- P8 |1 v; G9 `- }7 z System.err.println("The process will be terminated.");2 M6 g D; r, g& ^6 K
System.exit(1);( l: w% b" k+ c5 O3 R
return null;6 P0 u7 W" M" G/ r
}
7 m0 G: Y* h0 d! ^1 d' ] return sel;
; v& z( C A9 v: \4 `; ]. `, t }
" @$ f0 f+ h" w% B! N' I8 A1 p, \; G1 B8 C* C
public static Selector getSelector(Object obj, String method) {
! [4 H. c0 P: ] s E9 ]/ T Selector sel;
( ~4 ~' P Y& W: q5 U/ y try {
( D1 W4 z4 H$ B2 h sel = new Selector(obj.getClass(), method, false);
8 k$ N; S5 f2 q1 N+ i6 a } catch (Exception e) {: h, t" `0 Y3 i* t
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
4 ?; Q" S, S5 h( U( g. `3 } + (obj.getClass()).getName() + ".");6 O1 q# N1 y: a4 m8 o
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());3 E5 r+ w1 l) |4 a- t4 f
System.err.println("The process will be terminated.");+ X- G0 T% _) A C0 o7 r
System.exit(1);+ b# ^+ t7 m9 r3 J9 i I$ y# g' D# F3 E
return null;' P3 h3 g4 T, u
}. ?; s0 G. V, C2 I( E/ Y3 M
return sel;! o) _0 _' ^' o9 ]6 H! d
}
# b+ T# e2 b3 @# s5 F4 A7 I9 m} |