import swarm.Selector;
7 F0 b! X, i; k4 Q, V+ x* b0 q
0 c: z1 `: R. i4 q8 I9 wpublic class SwarmUtils {$ g1 s: g: _. e8 [& Z8 h% G
public static Selector getSelector(String name, String method) {
! `/ f9 D8 h! Z' o$ H+ f2 U Selector sel;% s8 q( o9 R9 f9 P! C
try {
: R. I- _. U& b/ o1 ^2 t sel = new Selector(Class.forName(name), method, false);* U3 D2 b& a: i! C
} catch (Exception e) {6 `1 g' d9 K- e5 `
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
+ l% { @) E, j0 d System.err.println(name + "." + method + " returns " + e.getMessage());# c% C" G; S. T$ c/ z: i
System.err.println("The process will be terminated.");5 k& ~$ C$ ?. r5 Y+ P
System.exit(1);7 }" g* I+ `0 J1 b
return null;
4 }8 C$ a1 d9 _, z }
3 w" r0 p+ R" |: E& G1 t! N return sel;
4 b6 ~7 |+ _" u7 B; d$ o$ W }
5 [% |4 u# e: j3 x6 U/ j! H+ w. ^2 M0 P' F4 J& z( Q
public static Selector getSelector(Object obj, String method) {9 v* K) U/ M, g% J
Selector sel;
/ ]$ r$ ?1 f6 ^/ l try {6 n+ b; W+ j0 f0 u
sel = new Selector(obj.getClass(), method, false);& b+ Q& p3 H" Q7 v' H: l8 U
} catch (Exception e) {
9 s) Y, }1 c2 F+ Z! L/ ? System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
2 i$ @ l. e: x- D6 y4 ?& M5 l + (obj.getClass()).getName() + ".");' ~) Y" x9 J( [0 @
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());$ P; m+ o& N4 m, q& [5 i9 b* y
System.err.println("The process will be terminated.");' v2 F) x9 ~5 i8 Z8 u, X+ E
System.exit(1);. u9 T) Y4 v4 X
return null;, Y* M# s3 J, V4 H5 U {) `
}
" R$ `5 w; J- l. o* v return sel;% J, |0 |+ F% p/ z7 o* W+ d
}
8 P, g- X, S& u ^, `} |