import swarm.Selector;6 ^) Y( {* D5 d0 Q- l
# j$ J8 W' F$ u( S! ?public class SwarmUtils {: D& R( }8 n1 ^) m; n
public static Selector getSelector(String name, String method) {
3 |- v. c, x9 P! P Selector sel;3 L' J! i4 d" R2 F' ]
try {- V5 ]9 t" R f$ ^1 w5 V
sel = new Selector(Class.forName(name), method, false);' a. [1 _6 m! z% w7 J
} catch (Exception e) {
! N8 ^+ W: a, Y System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
/ J9 Y& c4 a( b b) N2 Z4 p3 h* g' w System.err.println(name + "." + method + " returns " + e.getMessage());$ S x9 ~; I* |5 W) D# g
System.err.println("The process will be terminated.");* a& _* ]5 z+ x# ^; |3 j% U/ |
System.exit(1);) I' C& t9 `1 B! E1 v* ]' Y2 f
return null;
4 \1 x$ R$ z2 K4 b }
% D+ ^' b- X6 t8 G& B! A) J+ e: t return sel;% i6 `6 \& K/ v% Z% V' k
}6 ~ \1 w1 @& Y
6 Y/ B0 E. E3 A4 A6 H! X8 o
public static Selector getSelector(Object obj, String method) {
+ e" c& V# c& Z* q: [, N7 r Selector sel;0 D" g+ f4 |6 u9 {2 ?; b% G
try {
- f6 A2 u- R+ L+ d% E, ^# z, T sel = new Selector(obj.getClass(), method, false);
+ `, w+ K4 K0 A6 y9 } } catch (Exception e) {& |) p$ U" G- W' W9 t
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " y( `' f* r+ H6 M
+ (obj.getClass()).getName() + ".");
# v1 E" J. n7 |8 o* P* L4 M System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());9 A1 t( c7 k- y% O+ a
System.err.println("The process will be terminated.");/ J) C( w/ v* H1 [. N e I% H
System.exit(1);, t, x. q$ k( g V# m* n* t
return null;
M9 {# u% q( \, D }+ h- n3 a: s2 u1 L1 n l' @+ b
return sel;& R6 K) l7 O) |. ]! q
}# e. R& i" X" P4 K9 ?' v
} |