import swarm.Selector;
" {# y5 {/ F& r* f$ J% M, n) A' ?7 `2 l5 S! |
public class SwarmUtils {
0 W. d7 U, M/ F4 U( E public static Selector getSelector(String name, String method) {
% ~' D& I) N% ?6 D" z Selector sel;
. o6 F: @. p) j% D% e3 B try {9 J; E% D- x# k) [2 `
sel = new Selector(Class.forName(name), method, false);
& Z, i- N2 _$ C3 P2 q+ I) Y } catch (Exception e) {
% N- P. h# a9 ?6 M+ U System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
8 p# a# Y/ Z, T System.err.println(name + "." + method + " returns " + e.getMessage());2 j. u1 A, J: c( d& X
System.err.println("The process will be terminated.");
, ?% |8 |7 _, W( s( v8 W System.exit(1);/ Z5 n3 ^- w' }3 d* p
return null;7 X7 A7 @+ a& `6 r" N
}
1 W( w5 i$ M8 _: U5 m return sel;
5 A) w+ w- E2 F }: T/ \( E4 E: v* _7 |
9 ?2 F' O0 t$ Y9 I8 Y2 H7 E6 g
public static Selector getSelector(Object obj, String method) {- ~& c6 p$ {0 ]: j5 Q
Selector sel;
* f U& O; Z1 d: c try {+ n, ]# L' @ h8 W8 e- K" B
sel = new Selector(obj.getClass(), method, false);
; g3 w( Q0 o- R. }5 g6 z% N } catch (Exception e) {
1 H" l0 U: p- m7 c- P6 t System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " D) u) g2 o+ N4 _, Z
+ (obj.getClass()).getName() + ".");/ q8 b4 r( _, F: E9 A
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());$ {& x# O/ ]! ]- B4 p) y
System.err.println("The process will be terminated.");* j; N6 q8 X. J- G, f( p1 L T3 e* |
System.exit(1);
, _# W$ g% C# z# r* r u+ J- H3 t return null;
. p* u! _6 n" f+ S' c }
: k! A" j6 N; w return sel;
% E* A, u* G5 @3 w }/ M* N7 g0 t6 j/ L( Z
} |