import swarm.Selector;9 J- X) c. v7 E% v" x. @" k; n) A
. v2 A; F2 g; x+ {public class SwarmUtils {
* O, M2 S2 C9 M public static Selector getSelector(String name, String method) {
% k& x4 i5 H$ P Selector sel;
8 Z' N! T$ L) ]1 i! n try {" [" A2 {2 [" Y" }
sel = new Selector(Class.forName(name), method, false);6 \% ~& C p6 [. k+ z c
} catch (Exception e) {
s7 q4 |4 u; C$ Z, o System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
) l* C9 N8 z3 O5 u( Y System.err.println(name + "." + method + " returns " + e.getMessage());: b. I8 u5 L8 K3 X
System.err.println("The process will be terminated."); c6 B+ M/ G, [0 j
System.exit(1);. P* R5 F6 l- i( d
return null;
d4 w8 X: _0 L9 Q- t' {) I } ~' ~) u9 \4 u q0 w
return sel;& \) A+ w7 O5 r- K+ H) J1 W
}
/ y- K3 h) z4 }6 y' p$ f- z( s7 ~8 a) T* {0 u" N) _
public static Selector getSelector(Object obj, String method) {" M& ]) P4 d0 ^$ l- w
Selector sel;: ^! @) N' s7 T- q
try {
" g1 C" v* `4 p! R: l- H! Q6 o sel = new Selector(obj.getClass(), method, false);
O; V9 _. I+ _9 |$ }, l/ Z0 l/ r } catch (Exception e) {7 C$ \0 f- u& z
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "0 A" K( P2 }9 D% `
+ (obj.getClass()).getName() + ".");
- [/ K& H3 v# S5 l0 W System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
: q$ A; f1 }$ O* @. g* f# x- N3 f System.err.println("The process will be terminated.");# j/ c* @* F, _) j0 q
System.exit(1);0 K3 D- L. U+ C
return null;4 \/ _! J# x- Q
}
/ Q n! B8 k3 ^+ J7 `1 o return sel;& K& K8 @! N. ^
}
" \9 j! F$ ^: _} |