blob: 2b57d5ad429cc45ad8838de0fd2b314d083b4a00 (
plain)
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
103
104
105
106
107
108
109
110
111
112
113
|
package JACE.tests.ServiceConfigurator;
import java.io.*;
import java.util.*;
import JACE.OS.*;
import JACE.ServiceConfigurator.*;
/**
* Runs the service configurator, allowing the user to interact with it.
*/
public class Main
{
public static void main (String args[])
throws FileNotFoundException, IOException, ClassNotFoundException,
IllegalAccessException, InstantiationException
{
ACE.enableDebugging ();
if (ServiceConfig.open (args) < 0) {
System.err.println ("Error opening ServiceConfig");
return;
}
processCommands (args);
// close everything down
ServiceConfig.close ();
}
public static void report(String s) {
System.out.println(s);
}
static InputStreamReader stdin = new InputStreamReader (System.in);
public static void showMenu ()
{
report ("\n[C]lose all");
report ("[S]uspend all");
report ("[R]esume all");
report ("[Re[l]oad all");
report ("List [n]ames");
report ("\n[Q]uit");
System.out.print ("\nOption (CSRLNQ): ");
}
public static void processCommands (String [] args)
throws FileNotFoundException, IOException, ClassNotFoundException,
IllegalAccessException, InstantiationException
{
int ch = 0;
Enumeration svcs;
showMenu ();
do {
ch = stdin.read ();
switch (ch)
{
case 'c':
case 'C':
ServiceConfig.close ();
break;
case 's':
case 'S':
svcs = ServiceConfig.serviceNames ();
while (svcs.hasMoreElements ())
ServiceConfig.suspend ((String)svcs.nextElement ());
break;
case 'r':
case 'R':
svcs = ServiceConfig.serviceNames ();
while (svcs.hasMoreElements ())
ServiceConfig.resume ((String)svcs.nextElement ());
break;
case 'l':
case 'L':
ServiceConfig.close ();
svcs = ServiceConfig.serviceNames ();
while (svcs.hasMoreElements ())
ServiceConfig.remove ((String)svcs.nextElement ());
ServiceConfig.open (args);
break;
case 'n':
case 'N':
report ("\nService names:\n");
svcs = ServiceConfig.services ();
while (svcs.hasMoreElements ()) {
Service sv = (Service)svcs.nextElement ();
report (sv.name () + " : " + sv.info ());
}
break;
case 'q':
case 'Q':
report ("\nExiting...");
return;
case -1:
case 10:
case 13:
continue;
default:
break;
}
showMenu ();
} while (true);
}
}
|