import swarm.Selector;
( E/ R6 z7 K @3 v8 g U* v0 O% W7 Q) E( F0 q( S$ I* H
public class SwarmUtils {
x7 Q( {1 `0 @$ K3 ^ public static Selector getSelector(String name, String method) {
! |; R% V! U) J1 B/ [! A Selector sel;
: I& U; x m/ F7 A- d try { @9 c. ?1 T r; H7 r- u0 h
sel = new Selector(Class.forName(name), method, false);" S, z/ r5 H) [* i3 N6 J* W4 j
} catch (Exception e) {* X% T: F. W; M" b
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + "."); G" _' P+ y8 W/ n
System.err.println(name + "." + method + " returns " + e.getMessage());1 e- A* R8 S# e: f8 f8 S# a
System.err.println("The process will be terminated.");( j/ C z- |. J$ M, {/ L1 t
System.exit(1);
4 l3 h6 J% W# q& C return null;
7 }* L5 R' n: g }# ~% A( U: [. L$ z4 l
return sel;7 ]) P( T5 e8 A
}5 j) }* R+ d# m
( O+ q7 t" Z. c4 Z public static Selector getSelector(Object obj, String method) {. |+ T0 J2 o8 G; k
Selector sel; W( K' u; @! ]) V; l& L9 w
try {
$ H" Q6 ]# Q1 k/ A- ~3 B) f4 [( n; P sel = new Selector(obj.getClass(), method, false);- O4 I, l1 I# o/ R7 N+ f
} catch (Exception e) {1 ~, n. ]; o) ` P4 V d/ V# ^' K
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
* u: Z: W+ x! B! s% g) K + (obj.getClass()).getName() + ".");
- c% k% c/ ^; s: |4 a" ? System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());, ]: G1 t8 J) p0 A
System.err.println("The process will be terminated.");
2 P$ A5 Z/ G, N System.exit(1);
. u+ o! F i9 V# e2 V return null;
+ a o. h$ q) @3 i- ?" o" p }
* e7 s# @) _" V return sel;
$ [$ C: \% ^. e6 ?9 N) \( q& y }
) p# R- a. A/ Z) E5 |: H9 r} |