1 23 24 29 30 package com.sun.enterprise.config.serverbeans; 31 32 import com.sun.enterprise.util.RelativePathResolver; 33 34 import com.sun.enterprise.config.serverbeans.Domain; 35 import com.sun.enterprise.config.serverbeans.Server; 36 import com.sun.enterprise.config.serverbeans.Cluster; 37 import com.sun.enterprise.config.serverbeans.Config; 38 39 import com.sun.enterprise.config.ConfigException; 40 import com.sun.enterprise.config.ConfigContext; 41 42 46 public class PropertyResolver extends RelativePathResolver { 47 48 private Domain _domain = null; 49 private Cluster _cluster = null; 50 private Server _server = null; 51 private Config _config = null; 52 53 54 public PropertyResolver(ConfigContext configContext, String instanceName) 55 throws ConfigException 56 { 57 _domain = ServerHelper.getDomainConfigBean(configContext); 58 _config = ServerHelper.getConfigForServer(configContext, instanceName); 59 _server = ServerHelper.getServerByName(configContext, instanceName); 60 if (ServerHelper.isServerClustered(configContext, _server)) { 61 _cluster = ClusterHelper.getClusterForInstance(configContext, instanceName); 62 } 63 } 64 65 69 private String getPropertyValue(String propName, SystemProperty[] props) 70 { 71 String propVal = null; 72 for (int i = 0; i < props.length; i++) { 73 if (props[i].getName().equals(propName)) { 74 return props[i].getValue(); 75 } 76 } 77 return propVal; 78 } 79 80 86 public String getPropertyValue(String propName, boolean bIncludingEnvironmentVariables) 87 { 88 String propVal = null; 89 if (_server != null) { 91 propVal = getPropertyValue(propName, _server.getSystemProperty()); 92 } 93 if (propVal == null) { 94 if (_cluster != null) { 95 propVal = getPropertyValue(propName, _cluster.getSystemProperty()); 98 } 99 if (propVal == null) { 100 if (_config != null) { 101 propVal = getPropertyValue(propName, _config.getSystemProperty()); 104 if (propVal == null) { 105 if (_domain != null) { 106 propVal = getPropertyValue(propName, _domain.getSystemProperty()); 109 } 110 } 111 } 112 } 113 } 114 if (propVal == null) { 115 propVal = super.getPropertyValue(propName, bIncludingEnvironmentVariables); 116 } 117 return propVal; 118 } 119 120 public String getPropertyValue(String propName) 121 { 122 return getPropertyValue(propName, true); 123 } 124 } 125 | Popular Tags |