import swarm.Selector;' ^8 B6 |9 c1 ?9 g* [1 M
- P! b ~. i9 p& v: \public class SwarmUtils {) J6 ^$ W* C, k
public static Selector getSelector(String name, String method) {
u/ C3 P2 ~* o" c Selector sel;# Z4 ~5 T2 V7 ~8 m; t9 T
try {
4 F: O1 d# l/ u' T$ R _* y sel = new Selector(Class.forName(name), method, false);
7 B2 W8 c3 o8 M1 w } catch (Exception e) {; a; G/ v. W1 i/ C, O3 n7 h2 m
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
( x% ?& N K0 J6 k1 B- k. w/ `. W System.err.println(name + "." + method + " returns " + e.getMessage());2 R. Y8 A2 Z5 P: R
System.err.println("The process will be terminated.");3 z# V5 }, m. R0 S' ^# r, j- n
System.exit(1);( |% h% D1 u1 X- w$ S
return null;
2 C! K1 z3 U/ c$ K3 N T }1 I8 a: t' i! g9 T6 y1 r4 i. b
return sel;
7 u! @4 `* _0 f( d }2 u! E. O) a. s. y, R7 s" N
: V; K8 B5 j- c" H, A% }! z
public static Selector getSelector(Object obj, String method) {: x- p& b3 ?% ^, W4 t3 D
Selector sel;% t% p9 E) M6 ?0 [3 v; Y$ u5 d
try {
- h V8 F4 \0 r' O( c sel = new Selector(obj.getClass(), method, false);
( v, C1 D2 f* n1 ^/ M } catch (Exception e) {. ^; H7 F* F3 n% z9 R5 K
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
" j+ J2 `5 Q' D5 z6 N# d + (obj.getClass()).getName() + ".");
8 }5 c" Z7 @: Z3 I1 l y System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());& M( q" {' k- I. A' m! l0 _- J- _( Q
System.err.println("The process will be terminated.");
% K4 ?; L8 k% Z) x2 o8 Y( h System.exit(1);$ R/ \" z" s3 T& @/ G8 x% n
return null;8 m3 X: f6 N( t
}
+ B! q8 N O8 k7 i3 I0 ] return sel;" y$ O3 _9 {' J# G4 D( m
}) U+ ]9 K! B: F
} |