import swarm.Selector;9 f* K9 w9 w% v$ Z/ U
' k6 n& {$ n a+ ~/ R* }" apublic class SwarmUtils {
6 l" `- B' z/ G d2 B R public static Selector getSelector(String name, String method) {
, T& Y* E/ g! f' E+ f! o' C+ G( x Selector sel;
% J ~" G4 i, P/ p5 f8 j try {
9 d7 e" D5 j) J. N sel = new Selector(Class.forName(name), method, false);
; F3 s0 }3 {: }. ?8 t) } } catch (Exception e) {, L* P, P) I* \! T7 c% [+ V" T
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
( c5 F9 G" c& O System.err.println(name + "." + method + " returns " + e.getMessage());8 ^5 ]7 d7 y. x
System.err.println("The process will be terminated.");9 D# I# I- O( c! {. \
System.exit(1);, V4 C+ k. R+ s. s& _
return null;
% w# B! b$ H$ e3 q }
; F8 D4 p& S/ ]2 j+ ? return sel;% a# L2 ], G9 i3 ?3 o& ~4 y% @: h
}2 v# R/ \! g+ Z2 g
- Z5 ]5 h# O9 q8 o9 g
public static Selector getSelector(Object obj, String method) {
' i8 u! v2 ]3 z3 t f" |2 j" R; m' h5 y Selector sel;
2 Y6 `9 @" C6 l+ C& _! i: E, f try {
9 W; B m7 i6 V) O3 q sel = new Selector(obj.getClass(), method, false);
0 ?0 E% u$ u- A1 x } catch (Exception e) {' f w+ {# d, L3 H. K* C1 B
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
- H e% o6 Q( o3 V% N + (obj.getClass()).getName() + ".");) U4 B4 [6 j" j( |8 R) |" S% z
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());9 i$ r) ?; \" |9 c
System.err.println("The process will be terminated.");
' `& q& y! x, O9 o$ o) g System.exit(1);7 O8 m1 d+ ]2 x" z2 {- j4 [: N0 t
return null;3 O' c1 O$ Y# }9 ^) U8 Y+ ^5 U+ t
}
) ]1 C ]$ Y2 w4 k& Z7 {5 R return sel;( s/ w* J2 H. c- f: C% p3 y9 ?: P
}9 v% u$ t7 ?$ e
} |