blob: 3488b3cbc7ad4b562a7da0cf62c092bbc7ee4761 (
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
|
package javax.jnlp;
import java.util.*;
public final class ServiceManager {
private static ServiceManagerStub stub = null;
private static Map lookupTable = new HashMap(); // ensure lookup is idempotent
private ServiceManager() {
// says it can't be instantiated
}
public static java.lang.Object lookup(java.lang.String name) throws UnavailableServiceException {
if (stub == null)
throw new UnavailableServiceException("service stub not set.");
synchronized(lookupTable) {
Object result = lookupTable.get(name);
if (result == null) {
result = stub.lookup(name);
if (result != null)
lookupTable.put(name, result);
}
if (result == null)
throw new UnavailableServiceException("service not available (stub returned null).");
return result;
}
}
public static java.lang.String[] getServiceNames() {
// should this return the required ones even though no stub??
if (stub == null)
return new String[0];
return stub.getServiceNames();
}
public static void setServiceManagerStub(ServiceManagerStub stub) {
if (ServiceManager.stub == null)
ServiceManager.stub = stub;
}
}
|