Debian Codegraph @

netx/javax/jnlp/ServiceManager.java

raw
1 package javax.jnlp;
2
3 import java.util.*;
4
5 public final class ServiceManager {
6
7 private static ServiceManagerStub stub = null;
8
9 private static Map<String, Object> lookupTable = new HashMap<String, Object>(); // ensure lookup is idempotent
10
11 private ServiceManager() {
12 // says it can't be instantiated
13 }
14
15 public static java.lang.Object lookup(java.lang.String name) throws UnavailableServiceException {
16 if (stub == null)
17 throw new UnavailableServiceException("service stub not set.");
18
19 synchronized (lookupTable) {
20 Object result = lookupTable.get(name);
21
22 if (result == null) {
23 result = stub.lookup(name);
24 if (result != null)
25 lookupTable.put(name, result);
26 }
27
28 if (result == null)
29 throw new UnavailableServiceException("service not available (stub returned null).");
30
31 return result;
32 }
33 }
34
35 public static java.lang.String[] getServiceNames() {
36 // should this return the required ones even though no stub??
37 if (stub == null)
38 return new String[0];
39
40 return stub.getServiceNames();
41 }
42
43 public static void setServiceManagerStub(ServiceManagerStub stub) {
44 if (ServiceManager.stub == null)
45 ServiceManager.stub = stub;
46 }
47
48 }