import swarm.Selector;
3 u5 `- }# ?- o+ \
4 k$ e: u6 R( l/ J4 Z2 U- Ypublic class SwarmUtils {
! z/ i3 P# I0 O+ D public static Selector getSelector(String name, String method) {
! h# S( `8 y& F Selector sel;7 W2 {0 e4 W$ ]% {) t$ @
try {9 w# y/ h w! K+ s8 c S
sel = new Selector(Class.forName(name), method, false);
2 ]6 l& f- X1 H2 U/ X } catch (Exception e) {9 K, F1 v# O6 F" h* ^/ }
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");3 a! X, V5 a6 B$ q& x
System.err.println(name + "." + method + " returns " + e.getMessage());: I; ]& X0 }2 o0 F+ V
System.err.println("The process will be terminated.");6 b( ~- u1 v0 n6 N5 B5 s1 G
System.exit(1);* ^6 K. w2 z8 y p4 J+ Q/ w) h
return null;/ K& E# W9 D z! i( b7 P
}0 U) J+ A7 N$ G1 ^$ d9 [6 h' L
return sel;% y' t% P1 q& a9 N; n8 ]
}) U0 r/ f4 o1 j% i6 I: e' O( _
* Y! {9 ` y' v2 k1 ~
public static Selector getSelector(Object obj, String method) {
. _1 f; P. _9 ?; {$ a Selector sel;6 \( i( J! T9 z% E0 J, R0 m
try {
; ?% n G; H: Y( W5 ~' X sel = new Selector(obj.getClass(), method, false);
! q, B# d6 j- `$ F8 L } catch (Exception e) {
# N Z9 k( S0 P$ Q$ Z; v System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
" p; ^, c1 @: T + (obj.getClass()).getName() + ".");9 E3 s) T; l; p
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
! `! v1 l9 [+ y) M! [: |8 m System.err.println("The process will be terminated.");
% V6 B- s4 I$ ^9 E3 r* o6 A& B System.exit(1);
- Q# H, I+ q6 U, q8 q return null;
8 ^$ P' H2 i% _& S- W }+ J4 x- w0 |, E( b# a
return sel;" Z4 e! c* e; M- [1 S A1 c
}
/ }% y0 U" V- k7 p" R} |