import swarm.Selector;. m% C+ F7 l$ w* g' \' ]
2 E/ t# U3 }. Z2 R- T4 I+ hpublic class SwarmUtils {
. J9 E8 J. R* M4 e/ X public static Selector getSelector(String name, String method) {
$ S0 [5 G% w6 K I, i+ I$ B+ r0 j Selector sel;1 E! S) O1 U) r1 ]0 W' z- v
try {
9 j: o! L( _6 C- { sel = new Selector(Class.forName(name), method, false);
, O- }1 E9 a) o& ]; D2 i4 D } catch (Exception e) {
6 d& C+ G7 I4 M% N: l System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");' q7 U+ i z9 z2 r; w' r
System.err.println(name + "." + method + " returns " + e.getMessage());: i6 f& r2 @8 p) @6 B. _& c9 X8 ~
System.err.println("The process will be terminated.");" N! V3 n7 b5 ~/ i5 z
System.exit(1);& h# d; K' h# M+ a% W* e
return null;
) v2 o; M4 L8 N- I$ f+ D. h; _- V }2 e R4 F; B _9 l8 b' T: F+ f
return sel;1 f0 k- G( b( E* u5 R
}/ M/ L, @" t+ v4 @% U6 M
- C- \5 K. }8 Z+ G$ `+ x
public static Selector getSelector(Object obj, String method) {
3 q( m8 J& E6 t# U Selector sel;( \, [0 n" Z5 d* Q+ \! m
try {4 e: P2 P' v7 y9 Z4 \/ T' ~/ H
sel = new Selector(obj.getClass(), method, false);, @% G" A% D, b. v) E
} catch (Exception e) {" y( s- ]; k) [$ o
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
6 L+ r' P: r4 W0 l; W: | + (obj.getClass()).getName() + ".");
3 f! n7 u: L# I8 w- _# ] System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
! M" I# O' D" v System.err.println("The process will be terminated.");
: H6 f; o) X& D6 s5 E System.exit(1);
; C8 ]. {) N' ?) H8 w return null;
; P8 ~; l& z4 o4 l }+ m3 {) r. |. B7 D3 F
return sel;
+ @$ S6 k/ M7 `/ |+ B0 p: M0 @+ E }+ Q4 o1 Z+ w9 G! l
} |