import swarm.Selector;
; ?! B7 _$ E2 e# s
6 ]4 P/ c( |6 _4 tpublic class SwarmUtils {
' o: J/ ^+ W1 e" h( L8 t public static Selector getSelector(String name, String method) {
( C+ z4 i8 ~8 Q+ q+ ~! t Selector sel;& X, l8 a% f* q+ J. t4 y% w
try {
& M, m5 D; K' W Y4 j/ T( g! G+ X, O sel = new Selector(Class.forName(name), method, false);
2 ~# ~! p8 L. @% y; \$ s0 M; `( f6 ~ } catch (Exception e) {
, N& S9 l/ m# o' Z) {# D System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
; `6 I. U$ C( I/ _4 ~ System.err.println(name + "." + method + " returns " + e.getMessage());- R: u7 v/ P. Q) t/ d i, y+ |6 K
System.err.println("The process will be terminated.");4 ?$ a- H+ j: V0 Z% w6 L
System.exit(1);
# X& c7 c$ B+ r# F( q n return null;2 t) y, ~* h, m. @
}
. |% Z6 w/ f6 q return sel;2 T ~! e9 b1 |) R8 f% ?
}
% z% B' k/ \3 o9 m4 n% D2 |
! T" J( H2 y1 [" a6 F public static Selector getSelector(Object obj, String method) {) D' K+ |9 c7 ?+ L
Selector sel;
5 X5 s! ?$ z+ h# P5 M: K3 l0 v try {8 @, H% ?" f" \7 i
sel = new Selector(obj.getClass(), method, false);
0 L7 ^$ f6 L7 ` } catch (Exception e) {
9 M% W4 f! g& o6 e X% P System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "! Y3 @4 @) A8 ^! L" Y# B4 V
+ (obj.getClass()).getName() + ".");6 @% C$ _& q& h& F+ f' g) E
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());1 z6 m4 f+ @' B+ Z& @
System.err.println("The process will be terminated.");3 ]( f) U% L1 U
System.exit(1);
8 F) b6 A/ P" f! Y return null;0 H6 F' ~0 }' O$ F; F
}7 ~$ q$ f+ ~' T
return sel;
3 H4 T8 X3 e( |/ X# B }
; p+ P7 o2 O2 M8 S} |