import swarm.Selector;. E6 J* t( I' z }4 m2 ~
7 I; }. _ k- p' |5 s, _5 O
public class SwarmUtils {
$ H. a9 Q' o/ W) }: |$ S6 W public static Selector getSelector(String name, String method) {
$ x# @, b' e5 o, Z2 T# }: | Selector sel;% z6 B& n, z) `. \2 b
try {
$ M5 u; n5 V* B8 t sel = new Selector(Class.forName(name), method, false);8 d% l' R' H3 h( n* N$ ^7 r b3 G
} catch (Exception e) {
* H/ o# e; X2 C& C# `( z+ x System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");; H' A9 F+ Z5 F, v# `5 b$ R( a
System.err.println(name + "." + method + " returns " + e.getMessage());. `& V$ Q; ]3 j: v4 X
System.err.println("The process will be terminated.");
; y" b6 F0 j$ y0 l System.exit(1);7 x1 `) w# I9 ^+ v
return null;8 H4 m+ @+ p$ m
}
0 E* O" V0 {. r$ W return sel;
! J7 _, N5 Y- w7 | }
3 m# O# O' t! X( Q6 \! S5 b5 y7 r) h& z6 E7 x( t G
public static Selector getSelector(Object obj, String method) {. p7 q/ p% b& I* K9 r; @3 R; i6 Y
Selector sel;7 D& c3 T7 h" T+ R
try {# g% ~* e6 U4 E4 ~# r
sel = new Selector(obj.getClass(), method, false);+ R+ k/ X) g$ @8 N# K
} catch (Exception e) {
! O* I) ~( [: ^. h/ { System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
" S* r8 T% n# y + (obj.getClass()).getName() + ".");2 ^* V2 E; Y* j. k7 N/ A) H5 M( w
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());1 }$ F" B4 p3 _1 z
System.err.println("The process will be terminated.");
4 R8 n+ \/ L. N' H System.exit(1);
* T, o! z- y8 c6 O8 ?0 R( G1 k return null;
7 g2 k# y1 T* S) j+ U }
4 @! Q2 L9 E& K& d5 X return sel;7 l" y* v1 b! y. I h' N% j
}& ~/ F* M5 z! K9 p
} |