import swarm.Selector;
8 M; p# o- j4 c; A# R
% ]) r4 B0 u, o! kpublic class SwarmUtils {
8 l: q5 _# @7 @/ z' Q public static Selector getSelector(String name, String method) {1 e0 F% I% E# e7 v- |
Selector sel;) \" w& f/ n1 {
try {5 e# I- ]9 e0 [: U, e# x8 D
sel = new Selector(Class.forName(name), method, false);* L. K' _: [5 B/ y' ]* P; |5 h
} catch (Exception e) {
( q- Q g: n8 s System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");) r a8 L; X- t. @+ T8 ?
System.err.println(name + "." + method + " returns " + e.getMessage()); o/ B) `/ n6 |" y
System.err.println("The process will be terminated.");8 |+ K3 S6 k% X* ~* R
System.exit(1);1 q/ s" z$ u2 v8 \$ N: ^* r- F( i# V
return null;
X; [0 W/ D% f S7 o" I }
0 h" g- X+ ~# ^% k/ ~ return sel;
; x& @3 i; c# g5 X }
' S; B. H' C8 a5 E/ `
% U) h& h( Q3 E4 W, u public static Selector getSelector(Object obj, String method) {1 e4 Q( a2 s1 I# n
Selector sel;
) B3 X/ t7 y3 n0 U: @ try {# M+ A4 A4 b: E' L+ a
sel = new Selector(obj.getClass(), method, false);
6 `3 n. l" P/ h" o! B) N- P } catch (Exception e) {) {$ N( o" g/ r
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "4 j) }+ j7 ~8 w% o7 T
+ (obj.getClass()).getName() + ".");
4 j# c7 }5 T$ ^ System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());% h. r) v0 O/ Z* n x& n# A
System.err.println("The process will be terminated.");/ Z8 U* T& c4 [4 ~
System.exit(1);
% G4 a1 e# \5 d# h7 ?7 c return null; u! |# t) l, M7 i' G; E
}# Q: ~ l9 Q" z8 H
return sel;
3 ?! h: V6 T, Y! h6 H, b$ O }7 q2 ]' j" _3 S6 O4 U! ^
} |