import swarm.Selector;+ c1 K* n) G% t" C
& ]" {$ m& W D( H# |
public class SwarmUtils {1 n7 L, R8 E' y, U1 r
public static Selector getSelector(String name, String method) {- y# L: F, ? J5 z7 f
Selector sel;
, \* }' J$ ^# R6 C8 Z' G, d6 g try {0 s0 }7 ]' D8 U9 i H, h
sel = new Selector(Class.forName(name), method, false);
$ I' Y7 @ u. R2 {2 K3 g } catch (Exception e) {
+ S* N$ x$ x) v0 e1 a# R5 R% N System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
- \1 T% T2 X$ f$ n% K9 r System.err.println(name + "." + method + " returns " + e.getMessage());+ y9 E5 s. c% _1 u+ l m
System.err.println("The process will be terminated.");
, @, _. `0 W# {. N System.exit(1);; s" K+ C& {( [8 Q* [: D4 ~ y- E
return null;
/ I/ ^- |, J: s, M' A. w }+ m- Y% V) C& U5 {7 i: {
return sel;, g8 o, _' J- K" R! x1 w) S2 S
}
! B7 a/ ^0 @4 _( ]) g( M: @7 K0 ?% ?7 m* E
public static Selector getSelector(Object obj, String method) {1 O' V' F# a0 ]. _
Selector sel;0 P2 |" M+ k" R0 |5 H) }# ~+ x
try {
- W; w0 D6 T9 p4 P7 b9 U sel = new Selector(obj.getClass(), method, false);1 s* F# [' g& E& |5 N8 f0 D
} catch (Exception e) {
0 I' r2 C; [* E System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "" G% X' Y" S* E i3 X. b+ ?- h2 e
+ (obj.getClass()).getName() + ".");% a. `* V) x3 [: T& _( D
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());' |9 @9 b: A! Q5 d- A9 w
System.err.println("The process will be terminated.");2 B" \# _! s* _2 }) J' U5 G
System.exit(1);, V; c. r0 u' ] r" c
return null;
7 T4 W+ n% D# M7 \8 t# p }5 G5 z! Y" U" {8 }9 g! S
return sel;
( M6 K2 s, W' `+ J }" M: L3 m! p1 B- {* z, ~) q
} |