import swarm.Selector;
+ ^+ k( E0 {0 e. d# P! F5 d3 F" x7 ]8 Z X5 G& n9 B7 U+ V% Y
public class SwarmUtils {
9 a) a7 V) T1 l5 ?+ H# _0 w public static Selector getSelector(String name, String method) {# T7 W) I y5 {: B5 K6 R: o3 ^
Selector sel;7 M' E4 J7 i6 a3 M6 l
try {
" o. Q* u/ F. y! F4 I' R sel = new Selector(Class.forName(name), method, false);' F$ Z( i( L8 O" }
} catch (Exception e) {! \. L; _& k! i/ k
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");3 ~# A( M. k. e$ G1 t
System.err.println(name + "." + method + " returns " + e.getMessage());+ E: O; B% n- d
System.err.println("The process will be terminated.");* a( B. l5 b8 W7 u* V4 v5 z& h
System.exit(1);
3 ^/ {3 ]' a: f9 J return null;
! M3 k+ k% ^! m- [( C) w }
7 G1 @$ \; V" n5 a/ l* m% y return sel;& d& R7 S! p- M0 n/ e) a1 \
}, r' D0 S4 ^0 h
0 \2 {2 s0 g; N* S n6 C% I6 k
public static Selector getSelector(Object obj, String method) {4 y/ `8 V/ x N8 B# S3 @8 ]4 p
Selector sel;. Q9 Z% K4 R: f4 A- y
try {
! s, G' P. p" ~# v* }+ F/ S sel = new Selector(obj.getClass(), method, false);
( t# h( w( x0 z8 [ } catch (Exception e) {: P! c" B; D7 D- C- s9 K
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class ", d8 ?# Q3 Q+ X
+ (obj.getClass()).getName() + ".");6 v2 u. f( A7 a9 p" T
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());+ s+ c7 X0 k8 x- L- L; Z
System.err.println("The process will be terminated.");
1 Q4 ~0 Y( d# ]* S% a6 F. {! [ System.exit(1);5 n4 `& i% a2 v! M) ?0 p
return null;
( v. d6 u: _9 R; ^ }
) n J% l- `5 G/ c+ b ` return sel;
3 N' T1 a$ u1 B }
9 l! p# |4 Z) S9 U} |