1 23 24 package com.sun.enterprise.config.serverbeans; 25 26 import org.w3c.dom.*; 27 import org.xml.sax.*; 28 29 import java.util.logging.Logger ; 30 import java.util.logging.Level ; 31 33 import com.sun.enterprise.config.util.ConfigXPathHelper; 34 35 36 40 public final class ServerXPathHelper { 41 42 public static final String DEFAULT_CONFIG_MODEL_NAME = "server-config"; 45 public static final String REGEX_DEFAULT_CONFIG_MODEL_NAME = "server\\-config"; 46 public static final String DEFAULT_HOST_MODEL_NAME = "host1"; 48 49 50 public static final String REGEX_ONE_PLUS = "{1,}"; 51 52 public static final String XPATH_SEPARATOR = "/"; 53 54 public static final String XPATH_DOMAIN = XPATH_SEPARATOR + ServerTags.DOMAIN; 55 public static final String REGEX_XPATH_DOMAIN = XPATH_SEPARATOR 56 + REGEX_ONE_PLUS + ServerTags.DOMAIN; 57 58 63 public static final String XPATH_CONFIG = XPATH_DOMAIN + XPATH_SEPARATOR + 64 ServerTags.CONFIGS + XPATH_SEPARATOR + 65 ServerTags.CONFIG + 66 "[@" + ServerTags.NAME + "='" + DEFAULT_CONFIG_MODEL_NAME + "']"; 67 68 public static final String REGEX_XPATH_CONFIG = REGEX_XPATH_DOMAIN 69 + XPATH_SEPARATOR + REGEX_ONE_PLUS + ServerTags.CONFIGS 70 + XPATH_SEPARATOR + REGEX_ONE_PLUS + ServerTags.CONFIG 71 + "[@" + ServerTags.NAME + "='" + REGEX_DEFAULT_CONFIG_MODEL_NAME 72 + "']"; 73 74 public static final String XPATH_APPLICATIONS = XPATH_DOMAIN + XPATH_SEPARATOR + 75 ServerTags.APPLICATIONS; 76 77 public static final String XPATH_J2EE_APPLICATION = XPATH_APPLICATIONS + XPATH_SEPARATOR + 78 ServerTags.J2EE_APPLICATION; 79 80 public static final String XPATH_EJB_MODULE = XPATH_APPLICATIONS + XPATH_SEPARATOR + 81 ServerTags.EJB_MODULE; 82 83 public static final String XPATH_WEB_MODULE = XPATH_APPLICATIONS + XPATH_SEPARATOR + 84 ServerTags.WEB_MODULE; 85 86 public static final String XPATH_CONNECTOR_MODULE = XPATH_APPLICATIONS + XPATH_SEPARATOR + 87 ServerTags.CONNECTOR_MODULE; 88 89 public static final String XPATH_APPCLIENT_MODULE = XPATH_APPLICATIONS + XPATH_SEPARATOR + 90 ServerTags.APPCLIENT_MODULE; 91 92 public static final String XPATH_LIFECYCLE_MODULE = XPATH_APPLICATIONS + XPATH_SEPARATOR + 93 ServerTags.LIFECYCLE_MODULE; 94 95 101 public static final String XPATH_LOG_SERVICE = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.LOG_SERVICE; 102 public static final String XPATH_SECURITY_SERVICE = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.SECURITY_SERVICE; 103 public static final String XPATH_SECURITY_AUTH_REALM = XPATH_SECURITY_SERVICE + XPATH_SEPARATOR + ServerTags.AUTH_REALM; 104 105 public static final String XPATH_RESOURCES = XPATH_DOMAIN + XPATH_SEPARATOR + ServerTags.RESOURCES; 107 public static final String XPATH_JDBC_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.JDBC_RESOURCE; 108 public static final String XPATH_JNDI_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.EXTERNAL_JNDI_RESOURCE; 110 public static final String XPATH_CUSTOM_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.CUSTOM_RESOURCE; 111 public static final String XPATH_JDBC_CONNECTION_POOL = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.JDBC_CONNECTION_POOL; 112 public static final String XPATH_PM_FACTORY_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.PERSISTENCE_MANAGER_FACTORY_RESOURCE; 113 public static final String XPATH_MAIL_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.MAIL_RESOURCE; 114 public static final String XPATH_ADMIN_OBJECT_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.ADMIN_OBJECT_RESOURCE; 115 public static final String XPATH_CONNECTOR_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.CONNECTOR_RESOURCE; 116 public static final String XPATH_CONNECTOR_CONNECTION_POOL = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.CONNECTOR_CONNECTION_POOL; 117 public static final String XPATH_RESOURCE_ADAPTER_CONFIG = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.RESOURCE_ADAPTER_CONFIG; 118 119 120 public static final String XPATH_HTTP_SERVICE = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.HTTP_SERVICE; 122 public static final String XPATH_HTTP_LISTENER = XPATH_HTTP_SERVICE + XPATH_SEPARATOR + ServerTags.HTTP_LISTENER; 123 126 public static final String XPATH_TRANSACTION_SERVICE = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.TRANSACTION_SERVICE; 128 129 public static final String XPATH_JMS_SERVICE = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.JMS_SERVICE; 131 132 public static final String XPATH_IIOP_SERVICE = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.IIOP_SERVICE; 136 public static final String XPATH_ORB = XPATH_IIOP_SERVICE + XPATH_SEPARATOR + ServerTags.ORB; 137 public static final String XPATH_IIOP_LISTENER = XPATH_IIOP_SERVICE + XPATH_SEPARATOR + ServerTags.IIOP_LISTENER; 138 139 public static final String XPATH_MDB_CONTAINER = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.MDB_CONTAINER; 141 public static final String XPATH_WEB_CONTAINER = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.WEB_CONTAINER; 142 public static final String XPATH_EJB_CONTAINER = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.EJB_CONTAINER; 143 144 public static final String XPATH_JAVACONFIG = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.JAVA_CONFIG; 145 public static final String XPATH_PROFILER = XPATH_JAVACONFIG + XPATH_SEPARATOR + ServerTags.PROFILER; 146 147 149 150 public static String getServerIdXpath(String serverId) { 151 return XPATH_DOMAIN + XPATH_SEPARATOR + 152 ServerTags.SERVERS + XPATH_SEPARATOR + 153 ServerTags.SERVER + 154 "[@" + ServerTags.NAME + "='" + serverId + "']"; 155 } 156 157 public static String getConfigIdXpath(String configId) { 158 return XPATH_DOMAIN + XPATH_SEPARATOR + 159 ServerTags.CONFIGS + XPATH_SEPARATOR + 160 ServerTags.CONFIG + 161 "[@" + ServerTags.NAME + "='" + configId + "']"; 162 } 163 164 167 public static String getAppIdXpathExpression(String appId) { 168 return XPATH_J2EE_APPLICATION +"[@" + ServerTags.NAME + "='" + appId + "']"; 169 } 170 171 public static String getEjbModuleIdXpathExpression(String moduleId) { 172 return getAbsoluteIdXpathExpression(XPATH_EJB_MODULE, 173 ServerTags.NAME, 174 moduleId); 175 } 176 177 public static String getWebModuleIdXpathExpression(String moduleId) { 178 return getAbsoluteIdXpathExpression(XPATH_WEB_MODULE, 179 ServerTags.NAME, 180 moduleId); 181 } 182 183 public static String getConnectorModuleIdXpathExpression(String moduleId) { 184 189 return XPATH_CONNECTOR_MODULE + "[@" + ServerTags.NAME + "='" + moduleId + "']"; 191 } 193 194 public static String getAppClientModuleIdXpathExpression(String moduleId) { 195 return getAbsoluteIdXpathExpression(XPATH_APPCLIENT_MODULE, 196 ServerTags.NAME, 197 moduleId); 198 } 199 200 public static String getLifecycleModuleIdXpath(String moduleId) { 201 return getAbsoluteIdXpathExpression(XPATH_LIFECYCLE_MODULE, 202 ServerTags.NAME, 203 moduleId); 204 } 205 public static String getJDBCResourceIdXpath(String jndiId) { 207 return getAbsoluteIdXpathExpression(XPATH_JDBC_RESOURCE, ServerTags.JNDI_NAME, jndiId); 208 } 209 213 public static String getJNDIResourceIdXpath(String jndiId) { 214 return getAbsoluteIdXpathExpression(XPATH_JNDI_RESOURCE, ServerTags.JNDI_NAME, jndiId); 215 } 216 public static String getMailResourceIdXpath(String jndiId) { 217 return getAbsoluteIdXpathExpression(XPATH_MAIL_RESOURCE, ServerTags.JNDI_NAME, jndiId); 218 } 219 public static String getCustomResourceIdXpath(String jndiId) { 220 return getAbsoluteIdXpathExpression(XPATH_CUSTOM_RESOURCE, ServerTags.JNDI_NAME, jndiId); 221 } 222 public static String getJDBCConnectionPoolIdXpath(String poolId) { 223 return getAbsoluteIdXpathExpression(XPATH_JDBC_CONNECTION_POOL, ServerTags.NAME, poolId); 224 } 225 public static String getPMFactoryResourceIdXpath(String jndiId) { 226 return getAbsoluteIdXpathExpression(XPATH_PM_FACTORY_RESOURCE, ServerTags.JNDI_NAME, jndiId); 227 } 228 229 public static String getMDBContainerXpath() 231 { 232 return XPATH_MDB_CONTAINER; 233 } 234 public static String getWEBContainerXpath() 235 { 236 return XPATH_WEB_CONTAINER; 237 } 238 public static String getEJBContainerXpath() 239 { 240 return XPATH_EJB_CONTAINER; 241 } 242 243 public static String getTransactionServiceXpath() { 245 return XPATH_TRANSACTION_SERVICE; 246 } 247 248 public static String getJmsServiceXpath() { 250 return XPATH_JMS_SERVICE; 251 } 252 253 public static String getHTTPServiceXpath() { 255 return XPATH_HTTP_SERVICE; 256 } 257 public static String getHTTPListenerIdXpath(String id) { 258 return getAbsoluteIdXpathExpression(XPATH_HTTP_LISTENER, ServerTags.ID, id); 259 } 260 268 276 277 282 public static String getVirtualServerIdXpath(String classId, String id) { 283 return getAbsoluteIdXpathExpression( 284 XPATH_HTTP_SERVICE + XPATH_SEPARATOR + ServerTags.VIRTUAL_SERVER, 285 ServerTags.ID, id); 286 } 287 288 295 296 public static String getIIOPServiceXpath() { 298 return XPATH_IIOP_SERVICE; 299 } 300 public static String getOrbXpath() { 301 return XPATH_ORB; 302 } 303 public static String getIIOPListenerIdXpath(String id) { 304 return getAbsoluteIdXpathExpression(XPATH_IIOP_LISTENER, ServerTags.ID, id); 305 } 306 307 public static String getLogServiceXpath() { 309 return XPATH_LOG_SERVICE; 310 } 311 312 public static String getSecurityServiceXpath() { 314 return XPATH_SECURITY_SERVICE; 315 } 316 public static String getSecurityAuthRealmIdXpath(String name) { 317 return getAbsoluteIdXpathExpression(XPATH_SECURITY_AUTH_REALM, ServerTags.NAME, name); 318 } 319 320 public static String getJavaConfigXpath() { 322 return XPATH_JAVACONFIG; 323 } 324 public static String getProfilerXpath() { 325 return XPATH_PROFILER; 326 } 327 333 public static String getAbsoluteIdXpathExpression( 334 String childTagName, 335 String nameId, 336 String valueId) { 337 338 return ConfigXPathHelper.getAbsoluteIdXpathExpression( 339 childTagName, 340 nameId, 341 valueId); 342 } 343 344 347 public static String getLastNodeName(String xPath) { 348 return ConfigXPathHelper.getLastNodeName(xPath); 349 } 350 351 355 public static String getParentXPath(String xPath) { 356 return ConfigXPathHelper.getParentXPath(xPath); 357 } 358 } 359 | Popular Tags |