import swarm.Selector;
; H' p) X# q9 j: D- f; W3 p
+ T! M# [7 d) rpublic class SwarmUtils {: E2 H+ I1 T5 m
public static Selector getSelector(String name, String method) {# E9 `2 a% c' o& |3 b% e, V
Selector sel;
7 y. L7 y8 J" @2 B8 D try {
" J9 l5 l% m5 p! l sel = new Selector(Class.forName(name), method, false);2 Q1 [) e0 {' {" D- s4 I. P; u
} catch (Exception e) {
2 Z1 P$ S: d/ u, Q+ c. Y System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
) x2 n ^& g* _& N- _, o System.err.println(name + "." + method + " returns " + e.getMessage());2 \$ s* X$ m- e8 t3 Q
System.err.println("The process will be terminated.");
* G, L9 H \0 M! ?+ g |# H+ S7 w System.exit(1);
6 J$ S' A1 w3 A$ @- ] return null;
3 Y$ f# s3 W+ [) W }- V! r% k! ]- ~% Y# M3 x! h
return sel;
) w9 o; G/ a: O# j$ j4 w }
0 S* D7 F3 [3 A, i# B6 j1 ]. u' e* M( o' ?! Q- e
public static Selector getSelector(Object obj, String method) {
# n @8 _! b/ J7 m4 O% q Selector sel;
# ]' \! @, a* {2 e8 T: B+ \ try {) _) v3 c/ }- Y( z2 |* I
sel = new Selector(obj.getClass(), method, false);
- i( j# J2 O. ~' q$ {7 h2 o1 w } catch (Exception e) {$ V0 u: O O; y8 T2 j
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
) @/ S; A2 \- [/ q + (obj.getClass()).getName() + ".");
# P- O% ^& }* [0 _ T2 c* }4 \9 b3 ` System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());% |" m2 ?# v' p( y7 v5 E
System.err.println("The process will be terminated.");
, x5 S* S: l _8 Z, S; N System.exit(1);
; \! n3 n0 J5 A& E return null;
# W! {# {) j( M }* ?$ }% O+ C8 p
return sel;- v* H1 ^( {4 w- F# \& f8 ?+ D$ C
}+ u) Z: F! P: i: D1 p5 k3 b, g
} |