import swarm.Selector;
; k: c7 y, j4 C2 K- P* z
$ `9 N% p: Q3 {public class SwarmUtils {0 c7 v6 ?/ a4 S, f/ l5 [% `
public static Selector getSelector(String name, String method) {
* f/ l8 l5 M y7 a0 G$ d6 r8 Y Selector sel;
' L7 U* l) l1 h try {
F; F" `" m8 Q sel = new Selector(Class.forName(name), method, false);9 Y" d6 b' j7 w7 V
} catch (Exception e) {7 c; ~6 R$ d7 j4 o6 T n
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
1 [7 X6 ~! Y1 N System.err.println(name + "." + method + " returns " + e.getMessage());
8 V2 B# ]. m! V System.err.println("The process will be terminated.");( N( @8 n9 j1 ^8 x: r! a
System.exit(1);* H% U- `5 T" p I9 f# C
return null;
2 P) G6 {- U, ~3 X/ @$ N }
8 C9 |8 O" |/ k0 z$ f0 v$ u return sel;
% w; C+ T p! I }/ ~' E* x' \+ E% q( l/ C
3 b- R6 E0 J! w8 m3 M! \4 g+ T/ F
public static Selector getSelector(Object obj, String method) {
! o- G6 S. r7 X# L* O' s Selector sel;+ d( j% W4 e3 T8 h" H* {( A
try { \' ?8 I; D: O+ h! V' I8 y
sel = new Selector(obj.getClass(), method, false);$ ~* e% U( K% u7 v0 Q+ }, s6 e( J: N
} catch (Exception e) {
# j6 \, L2 m e System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "; V' `. m1 d" [4 Z5 m9 T% E
+ (obj.getClass()).getName() + ".");! r1 z) E1 c6 L$ w9 V
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());4 y4 l( @" X, z, s# F y( D/ Q3 X. i7 x
System.err.println("The process will be terminated.");
6 f( `2 |" y3 o3 F# m" H: R: E- B' \! Z System.exit(1);8 R# ?; e; ]" ~5 J2 f( x# J
return null;# t4 M5 P% P; C8 z1 n+ ?
}
! t' m2 |, c; B. |3 j return sel;
" s, M% [+ w! w" T- z }
* b6 l3 ? |. Z' N/ B} |