import swarm.Selector;& p8 ^" {3 k9 m: e1 |9 r3 v! A1 r% v3 {
/ F3 w& `! d" _9 I) gpublic class SwarmUtils {6 {' U, X1 a3 s/ G7 \$ o9 s5 U# g" ^: @
public static Selector getSelector(String name, String method) {
2 J# ?3 A7 H- k Selector sel;
3 `' ^# A& ^# ^: w9 x try {
) V# a& y- T; f sel = new Selector(Class.forName(name), method, false);$ q' n3 N; w. E/ `
} catch (Exception e) {
) L3 H# E. x4 F& ?, C8 t% V System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
5 ~& {8 p9 t' n System.err.println(name + "." + method + " returns " + e.getMessage());
3 t' X' [9 }! b* W System.err.println("The process will be terminated.");
! N( E3 ^+ H8 Y0 `/ Q System.exit(1);
3 m' j9 \$ ~ Z! V return null;
- M- F# c% B7 B; O# n3 ^ }
( l* ^6 b# b6 k( t return sel;( {2 l n( G& E* O0 ~
}" c( ~! z$ a! O% P U+ Q
3 @" ?6 w `- D n8 ^
public static Selector getSelector(Object obj, String method) {
/ j6 f. [7 _+ w2 r% b Selector sel;
, t K8 C! e9 N( x# b* l& W try {
5 S' f- O% z/ N* F8 F$ c sel = new Selector(obj.getClass(), method, false);
4 A& j- X( ~& S } catch (Exception e) {
+ Y" l: v3 r | System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "+ o+ f# n3 S, C# d
+ (obj.getClass()).getName() + ".");
, z* b+ S, f( j2 h! X/ x6 `& B! C, g System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
$ ?7 ?: U+ g) _5 G- a System.err.println("The process will be terminated.");
# u# Q) `7 Y/ f/ `/ ~# E System.exit(1);- F: G% d+ @: }, r
return null;
7 W' `- ~ l+ P) _; t+ d }
& I Z: k6 S$ e" U0 e return sel;9 p0 i: D! r* [, x0 u) \7 Z
}
' U2 i! A2 `2 a: i- X} |