import swarm.Selector;: F" y8 x! f3 m g/ t; Q
8 i8 R. _+ B1 `/ a6 A1 v' [1 Epublic class SwarmUtils {
/ V \0 D/ d, ]: ~' B# o2 U7 n; o public static Selector getSelector(String name, String method) {* t1 j3 e: B( R) H
Selector sel;2 R4 m$ R1 v! w1 B% z
try {
4 f1 ]" V1 j Q" V+ z# G) Q- O sel = new Selector(Class.forName(name), method, false);% Q7 [. p$ C4 p* ]
} catch (Exception e) {: f, v( W, \/ s9 H' V# w7 U
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");9 D/ [& w) F8 @4 S- _) w4 _
System.err.println(name + "." + method + " returns " + e.getMessage());
0 E t& |8 v$ `0 ]9 }: K4 p; ^' | System.err.println("The process will be terminated.");
7 Q# t4 o N+ O5 L System.exit(1);6 r6 W( o6 D* T
return null;
; i, f: h; H( _- h* l }
5 Q! e. i; f- m( P) I! ?8 ?* V return sel;# m9 b: E% r4 n8 z9 e: W
}4 Q0 w; i; T9 K; o- w
; J8 L' k. I; l; ~ public static Selector getSelector(Object obj, String method) {
7 J. v6 j$ p b/ {3 U8 | Selector sel;
7 B' k9 k2 \2 h) ]3 }9 _ try {) ^2 ^! a% Z$ m+ P+ a/ g' s3 V
sel = new Selector(obj.getClass(), method, false);
5 y! b5 J" h) X6 l% j2 o } catch (Exception e) {5 a( M5 V/ j8 Z* r; q1 `9 t; T2 I
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
2 M8 s. d' v8 Q0 j# p + (obj.getClass()).getName() + ".");& y' P# q4 d$ ~ W0 V9 _& o
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
2 L I! }0 U0 U& s9 C) s System.err.println("The process will be terminated.");, G# c4 _3 _4 h+ b1 ~
System.exit(1);& g/ G; q- R, T
return null;" \; H& c8 z$ [" Z
}: {" K. D5 z0 C! V A! T% G
return sel;
) e, D; e, v1 Q+ L/ A, F }
( x) M* z; U, o! c6 X& [# ]} |