import swarm.Selector;
9 O7 F/ K- ^' M$ \
; D, J% p0 w) n0 |$ apublic class SwarmUtils {3 z: V' q j- G/ u4 u8 U: c
public static Selector getSelector(String name, String method) {/ e+ O, C: ?4 H% P- U) L
Selector sel;9 j, y( U) H8 x4 j
try {/ |. J9 V8 p- a
sel = new Selector(Class.forName(name), method, false);
" Z& \& \ R; T) ^6 ~2 T" p6 B } catch (Exception e) {
' n7 N( h0 l( ? J System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");; {( v/ L8 g* q# l# k
System.err.println(name + "." + method + " returns " + e.getMessage());
5 v6 V$ R6 V7 M- e0 f+ m System.err.println("The process will be terminated."); C; P1 v+ c; a4 S
System.exit(1);! b, Z/ K: I% g ~4 b$ U% L
return null;3 s+ y4 c. w/ u- r/ y& R
}% a; u4 E4 I3 K G/ Z: U8 B6 w
return sel;
" @" M6 X! }( O( y5 Q4 D# o/ C }5 T6 e y; b( y
# F! P& `5 o' h/ }
public static Selector getSelector(Object obj, String method) {
* ?* f6 A% t7 s1 h/ \# D+ X Selector sel;' a* Q( T' J) _* k' W
try {
i1 x6 o& C* b' v4 r) I, m5 ?* _ sel = new Selector(obj.getClass(), method, false);
- e! y- R! T5 S* [' z, L& p0 t } catch (Exception e) {
: V$ O( e- `2 j System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
% l/ B! j9 q2 D9 w: G3 R- B8 x + (obj.getClass()).getName() + ".");
2 Y+ b) [( J7 }5 F& d" Q System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
# Z. C/ u7 r5 L( y+ j0 n System.err.println("The process will be terminated.");
0 }+ M% i: x) w$ u9 W W System.exit(1); {% |) }/ ]; w+ r$ {# I
return null;
% h, l" \5 W2 W }( E5 X. s; {3 m1 [; Y
return sel;
$ M" y, f' p5 s1 m5 J @6 r- s0 S }
% Z& w, B* B; u} |