1 package cz.cuni.amis.pogamut.base.utils;
2
3 import cz.cuni.amis.utils.exception.PogamutException;
4
5 import java.util.HashMap;
6 import java.util.Map;
7 import javax.management.MBeanServer;
8 import javax.management.MBeanServerConnection;
9 import javax.management.remote.JMXServiceURL;
10
11
12
13
14
15 public abstract class PogamutPlatformProxy implements PogamutPlatform {
16
17 PogamutPlatform platform;
18 Map<String, String> internalProps = new HashMap<String, String>();
19
20 public PogamutPlatformProxy(PogamutPlatform platform) {
21 this.platform = platform;
22 }
23
24 @Override
25 public MBeanServerConnection getMBeanServerConnection() throws PogamutException {
26 return platform.getMBeanServerConnection();
27 }
28
29 public void setProperty(String key, String value) {
30 internalProps.put(key, value);
31 }
32
33 @Override
34 public String getProperty(String key) {
35 String val = internalProps.get(key);
36 if (val == null) {
37 val = platform.getProperty(key);
38 }
39 return val;
40 }
41
42 @Override
43 public String getProperty(String key, String def) {
44 String val = internalProps.get(key);
45 if (val == null) {
46 val = platform.getProperty(key);
47 }
48 if (val == null) {
49 val = def;
50 }
51
52 return val;
53 }
54
55 @Override
56 public void close() throws PogamutException {
57 platform.close();
58 }
59
60 @Override
61 public MBeanServer getMBeanServer() throws PogamutException {
62 return platform.getMBeanServer();
63 }
64
65 @Override
66 public JMXServiceURL getMBeanServerURL() throws PogamutException {
67 return getMBeanServerURL();
68 }
69 }