import swarm.Selector;3 u+ a2 J, j! K$ n, b, r
7 A. R) P! k5 l$ s( {" opublic class SwarmUtils {( {& l2 m& L/ [7 z/ |( i0 L# y4 ?
public static Selector getSelector(String name, String method) {0 P6 i! M M) j0 ]& `2 W, {
Selector sel;7 n2 N- d9 a' _% [8 ]* L, l
try {
3 ^- l9 H" J$ Y& }4 i9 g# r sel = new Selector(Class.forName(name), method, false);
- |# s7 t u) O1 D* M } catch (Exception e) {6 Z/ o; R8 K0 z9 T2 z* G
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");6 w8 D5 U+ I5 @( {0 n7 X
System.err.println(name + "." + method + " returns " + e.getMessage());+ {4 H% C$ u! G
System.err.println("The process will be terminated."); x" C8 n! u4 F
System.exit(1);
* F; l3 y7 n6 F1 _9 n& D; q return null;
/ e! T: K y& {) ~& B, b }
6 i+ D) C: W1 }6 O return sel; v/ U+ m. G) f. |2 v4 E; |
}3 h" P) A% w/ O( v! \
6 `; j) v3 k8 A1 D5 F: y& H
public static Selector getSelector(Object obj, String method) {: b* ]; g; ?. F# b$ d
Selector sel;: {% a9 w- A+ L r+ w
try {
& F0 ?& T' N( c/ L sel = new Selector(obj.getClass(), method, false);( ~3 a& k9 c- H- H
} catch (Exception e) {
) S; ~+ b; X% I$ [* Y2 o) e9 X1 Y System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
& f v6 F; q8 A+ N + (obj.getClass()).getName() + ".");: _! f) K0 U+ }- }7 l- L
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
! P/ M$ d% y: u4 e& b6 V: {2 U$ ~; L System.err.println("The process will be terminated.");% A* B3 p. q% y4 M4 m d0 Y. d
System.exit(1);
: M& N/ J& b( F" O+ ]- l return null;1 }2 S8 G/ E( x) S; `/ y
}+ G; d+ ^9 a, O2 k
return sel;2 h/ k T; s \4 C5 x) E
}7 [- m3 H* p5 c
} |