import swarm.Selector;
+ \* x5 Z. @* N+ H
; \( A& h8 P9 @' ^" I; Tpublic class SwarmUtils {
5 E+ _0 X; ~0 g+ B g public static Selector getSelector(String name, String method) {" o' K# O$ E& `2 ]$ |: r7 o
Selector sel;4 O$ @& Y, O' Y: {& t# Q* @& K
try {
# F6 C7 N3 q$ A. V+ O sel = new Selector(Class.forName(name), method, false);7 }) u! w, V8 ?8 a
} catch (Exception e) {
\/ w0 q3 J6 t( r9 e System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");1 F% O# |& K, h! T7 i6 c
System.err.println(name + "." + method + " returns " + e.getMessage());
4 E9 M( d7 ~$ Z, R, J2 p% C System.err.println("The process will be terminated.");
, @5 e- z) _& l System.exit(1);
: v+ x- @- D" F- _, v return null;1 @8 h y- T# {/ X# W3 k- n
}
" S: f. w: }! f7 g return sel;
) u- K4 O4 w* T3 I }
5 h. E; }. m9 M8 d9 P
" H! z6 M1 d" g3 N2 C# m# N9 l3 }" w public static Selector getSelector(Object obj, String method) {2 m+ s( v. K6 U. }, h% o3 }$ `
Selector sel;
/ T! E$ t. X1 q5 p0 Z try {8 i* u7 F/ d a: F
sel = new Selector(obj.getClass(), method, false);
. A. A0 P" z# G/ J } catch (Exception e) {$ }% f+ W' N, B- U, r. ^9 a
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "- Z/ x: M' U& s+ Z7 w
+ (obj.getClass()).getName() + ".");
% D* ^& ` f# ^) x% b3 V System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());* Z; N; H, ?9 s) ^5 q4 W# P( U! C
System.err.println("The process will be terminated.");
0 [! _3 H0 S c System.exit(1);! s+ ~( n, Y; H l. S
return null;, b% t! e1 h9 Y- t L
}# t' Y, x% d0 A. d, i
return sel;* [6 Z0 V9 L& g+ e; \2 K
}
4 p! i7 S7 L! ~' p} |