import swarm.Selector; S8 t+ V, V4 ?
0 |8 y: X [3 u- p+ i$ P
public class SwarmUtils {) v. R0 l( g1 m% D; a) W0 r
public static Selector getSelector(String name, String method) {
! q- k/ Q/ R9 M Selector sel; U1 l8 Q5 G! q
try {
4 G1 |' n& z. l3 U# ]& {1 q sel = new Selector(Class.forName(name), method, false);& O/ r. m2 z0 W& H) D
} catch (Exception e) {) k! R# X8 y/ J. }" N a+ ]
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");, a( f, @) j4 l8 y8 ?- y
System.err.println(name + "." + method + " returns " + e.getMessage());
& q L8 ]& L f. ?9 e3 S: Q System.err.println("The process will be terminated.");
0 q! W$ |2 F6 x2 N System.exit(1);2 R- d) R! J" E$ i; d, w& i
return null;
+ [0 L {: i% T1 |7 E# y8 c7 @$ D }
, F% m3 p: C# v2 s' E& | return sel;( V/ F$ {& j( e( t" E. x/ \6 H# [
}# [+ L+ n# x. }% k/ v% p+ x$ [
- t' s3 J7 ?8 ^* i
public static Selector getSelector(Object obj, String method) {9 ^5 n$ E$ l9 ]' g" |0 y6 T
Selector sel;
) B' Y; v. w2 b% I( ^ d% p try {
1 B# s9 ^) D+ [: E& z sel = new Selector(obj.getClass(), method, false);
% H5 k. a3 I2 F4 U! o6 H } catch (Exception e) {
/ S3 g8 g) ]' i5 m9 G% B System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "; Q- g% l! p- K; y; h/ W
+ (obj.getClass()).getName() + ".");
9 f' t: |" V4 q6 H3 H$ s System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());" m B7 v/ M6 e( Z- Q* @% y! m
System.err.println("The process will be terminated."); ~3 B ]( D. e- Q5 `
System.exit(1);
3 @' I* G9 F' ]7 ^1 t7 t* c( J return null;
, w( i8 k# R7 ?+ v }6 n3 E6 |' g, X) V0 X
return sel;
7 C1 e5 A6 Y; \4 {5 v }
- K! M. Q; [1 k8 S} |