import swarm.Selector;: V2 x+ e6 ?6 x) O
1 E: `- Y. u5 d% u7 Npublic class SwarmUtils {: I' w& ?1 O y! J: v; V7 Y. h
public static Selector getSelector(String name, String method) {8 n. P8 r' ^$ \* H1 q5 z
Selector sel;
* v$ |7 V: e9 M% [4 u' M5 {& ?% h try {9 ^. A: e) Z5 J; ~8 Y0 ^
sel = new Selector(Class.forName(name), method, false);+ v! E1 M2 n8 N* q" u5 J
} catch (Exception e) {
$ P3 T h B( ?9 ]3 R System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");4 ]+ r9 q* G) r. N8 p& O8 i2 h
System.err.println(name + "." + method + " returns " + e.getMessage());$ d5 {0 Z4 |8 R' ], x
System.err.println("The process will be terminated.");
% D. l+ r2 G: I A4 l System.exit(1);( r" }* P. F; E) z( t2 w
return null;
) a5 D' t( T/ o }
N- E- l% j2 G+ l( B return sel;
5 d2 U) e4 [" A! m }# h& U, L1 J8 ^
: M7 z. U F7 z: m9 S public static Selector getSelector(Object obj, String method) {
# W; Y: h( c2 z Selector sel;
. K* N7 z) r3 c- z try {* x: }: e+ i! W' r, H
sel = new Selector(obj.getClass(), method, false);, J& W2 a7 y$ r* D* {6 Q
} catch (Exception e) {7 D" g. ^+ Z) L
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
2 u3 U4 I) F+ L2 R. Y% b& A + (obj.getClass()).getName() + ".");/ q+ G* v+ Z: Z8 {( b" x# c+ R0 M
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());! _( W9 z: P$ k5 Y6 t1 g
System.err.println("The process will be terminated."); x) R. e0 z6 V) X/ n: {# c
System.exit(1);
; R7 w+ |6 o! l; s8 c return null;: T) u% ^0 X# G$ K$ C' f# v6 ^0 {
}# }: B$ c: N# T
return sel; B, N& s8 ~8 d$ y
}
: H) g% j/ d- R} |