-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHabitat.java
102 lines (81 loc) · 2.76 KB
/
Habitat.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package psl.habitats;
import java.io.*;
import java.util.*;
import psl.habitats.portal.HabitatPortal;
public class Habitat {
String roleName, category;
Hashtable serviceObjects;
HabitatPortal hp = null;
public final GateKeeper gk;
public Habitat(String name, String c, String file, String sienaMaster) {
roleName = name;
category = c;
serviceObjects = new Hashtable();
FileIO fileRW = new FileIO();
Hashtable serviceList;
/*
FrontEnd fe = new FrontEnd();
Console ad = new Console();
ad.cf_show("Admin Frame");
ad.cf_show("Admin Console");
*/
// read the services
if (file == null) file = ".serviceList";
serviceList = fileRW.readFile(file, ",");
// set the sienaMaster
if (sienaMaster == null)
sienaMaster = "senp://canal.psl.cs.columbia.edu:31331";
gk = new GateKeeper(this, sienaMaster);
// initialize the services
for (Enumeration e = serviceList.elements() ; e.hasMoreElements() ;) {
try {
Class t = Class.forName((String) e.nextElement());
ServiceInterface s = (ServiceInterface) t.newInstance();
serviceObjects.put(s.getDescription(), s);
s.initialize(this);
// ad.cf_add("Started sevice " + s.getDescription()+ "\n");
System.out.println("Started sevice " + s.getDescription()+ "\n");
// s.startDisplay();
} catch (Exception ex) {
ex.printStackTrace();
}
}
hp = new HabitatPortal(name, serviceObjects.elements());
}
public String getName() {
return roleName;
}
public String getCategory() {
return category;
}
public ServiceInterface getService(String _svdes) {
return((ServiceInterface)serviceObjects.get(_svdes));
}
static public boolean localService(String servDes) {
return false;
}
public void log(String msg) {
hp.log(msg);
}
private static void usage() {
System.out.println("java psl.habitats.Habitat <habName> <habCategory> [-sl <file>] [-sm <uri>]");
System.out.println(" <habName> : habitat name");
System.out.println(" <habCategory> : habitat category");
System.out.println(" [-sl <file>] : initial serviceList file [default: .serviceList]");
System.out.println(" [-sm <uri>] : siena master [default: senp://canal:31331/");
System.exit(0);
}
public static void main(String args[]) {
if (args.length < 2) usage();
String habName = args[0];
String habCategory = args[1];
String file = null, sm = null;
int i = 2;
while (i<args.length) {
if (args[i].equals("-sl")) file = args[++i];
else if (args[i].equals("-sm")) sm = args[++i];
i++;
}
new Habitat(habName, habCategory, file, sm);
}
}