import swarm.Selector;5 t0 F! x; a* I# \0 {4 r
) a+ `: w) ? p; {
public class SwarmUtils {
, [, d, b3 R% R0 I% C- D public static Selector getSelector(String name, String method) {
; |0 [' M* A' T8 Y) b! t4 f5 C Selector sel;% V( t4 `! Y1 T3 V0 M
try {: d! k# s- O% I3 S) M0 R
sel = new Selector(Class.forName(name), method, false);
9 h* ~ k; r2 _ } catch (Exception e) {
( D* P6 c7 w7 E @& Q3 g" m System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
$ v7 J r" ~0 n: v) H System.err.println(name + "." + method + " returns " + e.getMessage());
8 T7 b$ Q- d V: K System.err.println("The process will be terminated.");
' A* E7 I7 i8 k4 |- |+ ], A System.exit(1);
( p- Y! d( G7 I3 ?3 h- H return null;
1 X: P4 ^! {* C" m( d$ B3 } }
. a- Q+ w" h5 Y return sel;
$ N. L6 w+ l- H2 A7 u* p }
0 q0 ?4 U! v) k: c6 W8 W; n9 Q K" a! o2 C5 u7 A- K6 S
public static Selector getSelector(Object obj, String method) {
: O) S+ D1 G! F- Y9 \ Selector sel;; x2 C+ ]; L$ j+ R$ _% A' a" H
try {- u' G$ z1 K. `9 M2 k" ?' s- z7 Q. B
sel = new Selector(obj.getClass(), method, false);
3 U D( x" I8 G, R } catch (Exception e) {1 } W$ V( a; |
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "0 s" Q1 k2 R/ ~: c/ F l
+ (obj.getClass()).getName() + ".");
! Q) m- J& @1 L& l! V* ]! R System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
4 F! Q, _" P# b5 b7 F( D m System.err.println("The process will be terminated.");
6 z4 R: C7 n- H" w) }2 [) v# H System.exit(1);1 r0 r* Y7 B$ O1 F! y: K1 ]2 u
return null;
/ b4 F9 P" e" S' e. p }
2 O: `. r, R S, ?+ ?( r. E return sel;- C a7 L6 w( O2 B
}, w- l) D/ E5 Q: _
} |