1 23 24 41 42 package com.sun.enterprise.admin.monitor.registry.spi; 43 44 import com.sun.enterprise.admin.monitor.registry.*; 45 import com.sun.enterprise.server.ApplicationServer; 46 import com.sun.enterprise.config.ConfigException; 47 import java.util.logging.*; 48 import com.sun.enterprise.admin.common.constant.AdminConstants; import com.sun.enterprise.util.i18n.StringManager; 50 import com.sun.enterprise.admin.dottedname.DottedName; 51 52 58 class DottedNameFactory { 59 private static final Logger logger = Logger.getLogger(AdminConstants.kLoggerName); 60 private static final StringManager sm = StringManager.getManager(DottedNameFactory.class); 61 private static String instanceName =null; 62 private static final String DELIMITER = "."; 63 64 private static String getInstanceName(){ 65 if(instanceName == null){ 66 try{ 67 instanceName = (ApplicationServer.getServerContext()).getInstanceName(); 68 if(instanceName==null) { 69 final String msg = sm.getString("instance_name_not_found"); 70 throw new NullPointerException (msg); 71 } 72 } 73 catch(Exception e){ 74 logger.fine("DottedNameFactory:"+e.getClass().getName()); 75 throw new RuntimeException (e); 76 } 77 } 78 return instanceName; 79 } 80 81 static String getRootDottedName(){ 82 return getInstanceName(); 83 } 84 85 static String getApplicationsDottedName(){ 86 return getInstanceName() + DELIMITER + MonitoredObjectType.APPLICATIONS; 87 } 88 89 static String getResourcesDottedName(){ 90 return getInstanceName() + DELIMITER + MonitoredObjectType.RESOURCES; 91 } 92 93 static String getOrbDottedName(){ 94 return getInstanceName() + DELIMITER + MonitoredObjectType.ORB; 95 } 96 97 static String getTransactionServiceDottedName(){ 98 return getInstanceName() + DELIMITER + MonitoredObjectType.TRANSACTION_SERVICE; 99 } 100 101 static String getThreadPoolsDottedName(){ 102 return getInstanceName() + DELIMITER + MonitoredObjectType.THREAD_POOLS; 103 } 104 105 static String getThreadPoolDottedName(String name){ 106 name = DottedName.escapePart(name); 107 return getThreadPoolsDottedName() + DELIMITER + name; 108 } 109 110 static String getHttpServiceDottedName(){ 111 return getInstanceName() + DELIMITER + MonitoredObjectType.HTTP_SERVICE; 112 } 113 114 static String getJVMDottedName(){ 115 return getInstanceName() + DELIMITER + MonitoredObjectType.JVM; 116 } 117 118 static String getHttpSvcVirtualServerDottedName(String vs){ 119 vs = DottedName.escapePart(vs); 120 return getHttpServiceDottedName() + DELIMITER + vs; 121 } 122 123 static String getHttpListenerDottedName(String listenerName, String vs){ 124 listenerName = DottedName.escapePart(listenerName); 125 return getHttpSvcVirtualServerDottedName(vs) + DELIMITER + listenerName; 126 } 127 128 static String getConnectionManagersDottedName(){ 129 return getOrbDottedName() + DELIMITER + MonitoredObjectType.CONNECTION_MANAGERS; 130 } 131 132 static String getOrbConnectionManagerDottedName(String name){ 133 name = DottedName.escapePart(name); 134 return getConnectionManagersDottedName() + DELIMITER + name; 135 } 136 137 static String getConnectionPoolDottedName(String poolName, String type){ 138 poolName = DottedName.escapePart(poolName); 139 return getResourcesDottedName() + DELIMITER + poolName; 140 } 141 142 static String getStandAloneEJBModuleDottedName(String module){ 143 module = DottedName.escapePart(module); 144 return getApplicationsDottedName() + DELIMITER + module; 145 } 146 147 static String getStandAloneWebModuleDottedName(String module){ 148 module = DottedName.escapePart(module); 149 return getApplicationsDottedName() + DELIMITER + module; 150 } 151 152 static String getAppDottedName(String app){ 153 app = DottedName.escapePart(app); 154 return getApplicationsDottedName() + DELIMITER + app; 155 } 156 157 static String getAppModuleDottedName(String app, String module){ 158 module = DottedName.escapePart(module); 159 return getAppDottedName(app) + DELIMITER + module; 160 } 161 162 static String getWebAppsVirtualServerDottedName(String app, String module, 163 String vs){ 164 vs = DottedName.escapePart(vs); 165 if(app == null){ 166 return getStandAloneWebModuleDottedName(module) + DELIMITER + vs; 167 } 168 return getAppModuleDottedName(app, module) + DELIMITER + vs; 169 } 170 171 static String getServletDottedName(String app, String module, 172 String vs, String servlet){ 173 servlet = DottedName.escapePart(servlet); 174 return getWebAppsVirtualServerDottedName(app, module, vs) + DELIMITER + servlet; 175 } 176 177 static String getEJBDottedName(String app, String module, String ejb){ 178 ejb = DottedName.escapePart(ejb); 179 if(app == null){ 180 return getStandAloneEJBModuleDottedName(module) + DELIMITER + ejb; 181 } 182 return getAppModuleDottedName(app, module) + DELIMITER + ejb; 183 } 184 185 static String getEJBDottedNameWithType(String app, String module, String ejb, 186 String ejbType){ 187 ejb = DottedName.escapePart(ejb); 188 if(app == null){ 189 return getStandAloneEJBModuleDottedName(module) + DELIMITER + ejbType + DELIMITER + ejb; 190 } 191 return getAppModuleDottedName(app, module) + DELIMITER + ejbType + DELIMITER + ejb; 192 } 193 194 static String getEJBCacheDottedName(String app, String module, String ejb){ 195 return getEJBDottedName(app, module, ejb) + DELIMITER + MonitoredObjectType.BEAN_CACHE; 196 } 197 198 static String getEJBPoolDottedName(String app, String module, String ejb){ 199 return getEJBDottedName(app, module, ejb) + DELIMITER + MonitoredObjectType.BEAN_POOL; 200 } 201 202 static String getEJBMethodsDottedName(String app, String module, String ejb){ 203 return getEJBDottedName(app, module, ejb) + DELIMITER + MonitoredObjectType.BEAN_METHODS; 204 } 205 206 static String getEJBMethodDottedName(String app, String module, String ejb, String method){ 207 return getEJBMethodsDottedName(app,module,ejb) + DELIMITER + DottedName.escapePart(method); 208 } 209 210 static String getConnectorServiceDottedName() { 212 return getInstanceName() + DELIMITER + MonitoredObjectType.CONNECTOR_SERVICE; 213 } 214 215 static String getJmsServiceDottedName() { 216 return getInstanceName() + DELIMITER + MonitoredObjectType.JMS_SERVICE; 217 } 218 219 static String getConnectorModuleDottedName(String j2eeAppName, String moduleName) { 220 if(j2eeAppName != null) { 221 moduleName = DottedName.escapePart(j2eeAppName) + "#" + DottedName.escapePart(moduleName); 222 } 223 else 224 moduleName = DottedName.escapePart(moduleName); 225 return getConnectorServiceDottedName() + DELIMITER + moduleName; 226 } 227 228 static String getConnectorWorkMgmtDottedName(String j2eeAppName, String moduleName, boolean isJms) { 229 230 String dottedName = null; 231 232 if(isJms) { 233 dottedName = getJmsServiceDottedName() + DELIMITER + MonitoredObjectType.CONNECTOR_WORKMGMT; 234 } 235 else { 236 dottedName = getConnectorModuleDottedName(j2eeAppName, moduleName) + DELIMITER + MonitoredObjectType.CONNECTOR_WORKMGMT; 237 } 238 return dottedName; 239 } 240 241 static String getConnectionFactoriesDottedName() { 242 return getJmsServiceDottedName() + DELIMITER + MonitoredObjectType.CONNECTION_FACTORIES; 243 } 244 245 static String getConnectionFactoryDottedName(String factoryName) { 246 return getConnectionFactoriesDottedName() + DELIMITER + DottedName.escapePart(factoryName); 247 } 248 249 static String getConnectionPoolsDottedName(String j2eeAppName, String moduleName) { 250 return getConnectorModuleDottedName(j2eeAppName, moduleName) + DELIMITER + MonitoredObjectType.CONNECTION_POOLS; 251 } 252 253 static String getConnectionPoolDottedName(String poolName, String j2eeAppName, String moduleName){ 254 return getConnectionPoolsDottedName(j2eeAppName, moduleName) + DELIMITER + DottedName.escapePart(poolName); 255 } 256 257 static String getConnectionQueueDottedName() { 259 return getHttpServiceDottedName() + DELIMITER + MonitoredObjectType.CONNECTION_QUEUE; 260 } 261 262 static String getDnsDottedName() { 263 return getHttpServiceDottedName() + DELIMITER + MonitoredObjectType.DNS; 264 } 265 266 static String getKeepAliveDottedName() { 267 return getHttpServiceDottedName() + DELIMITER + MonitoredObjectType.KEEP_ALIVE; 268 } 269 270 static String getPWCThreadPoolDottedName() { 271 return getHttpServiceDottedName() + DELIMITER + MonitoredObjectType.PWC_THREAD_POOL; 272 } 273 274 static String getFileCacheDottedName() { 275 return getHttpServiceDottedName() + DELIMITER + MonitoredObjectType.FILE_CACHE; 276 } 277 278 static String getRequestDottedName(String vsId) { 279 return getHttpSvcVirtualServerDottedName(vsId) + DELIMITER + MonitoredObjectType.REQUEST; 280 } 281 282 static String getStatefulSessionStoreDottedName(String ejbName, String moduleName, String j2eeAppName) { 284 return getEJBDottedName(j2eeAppName, moduleName, ejbName) + DELIMITER + MonitoredObjectType.SESSION_STORE; 285 } 286 287 static String getTimerDottedName(String ejbName, String moduleName, String j2eeAppName) { 289 return getEJBDottedName(j2eeAppName, moduleName, ejbName) + DELIMITER + MonitoredObjectType.TIMERS; 290 } 291 292 static String getWebServiceAggregateStatsInEjbDottedName( 294 String endpointName, String moduleName, String j2eeAppName) { 295 296 return getWebServiceInEjbDottedName(j2eeAppName,moduleName, 297 endpointName) + DELIMITER + MonitoredObjectType.WEBSERVICE_ENDPOINT; 298 299 } 300 301 static String getWebServiceAggregateStatsInWebDottedName( 302 String endpointName, String moduleName, String j2eeAppName) { 303 304 return getWebServiceInWebDottedName(j2eeAppName,moduleName, 305 endpointName) + DELIMITER + MonitoredObjectType.WEBSERVICE_ENDPOINT; 306 307 } 308 309 static String getWebServiceInWebDottedName(String app,String module, String 310 endpoint){ 311 312 endpoint = DottedName.escapePart(endpoint); 313 if(app == null){ 314 return getStandAloneWebModuleDottedName(module) + DELIMITER + 315 endpoint; 316 } 317 return getAppModuleDottedName(app, module) + DELIMITER + endpoint; 318 } 319 320 static String getWebServiceInEjbDottedName(String app,String module, String 321 endpoint){ 322 323 endpoint = DottedName.escapePart(endpoint); 324 if(app == null){ 325 return getStandAloneEJBModuleDottedName(module) + DELIMITER + 326 endpoint; 327 } 328 return getAppModuleDottedName(app, module) + DELIMITER + endpoint; 329 } 330 331 static String getJVMCompilationDottedName() { 333 return getJVMDottedName() + DELIMITER + MonitoredObjectType.JVM_COMPILATION; 334 } 335 336 static String getJVMClassLoadingDottedName() { 337 return getJVMDottedName() + DELIMITER + MonitoredObjectType.JVM_CLASSLOADING; 338 } 339 340 static String getJVMRuntimeDottedName() { 341 return getJVMDottedName() + DELIMITER + MonitoredObjectType.JVM_RUNTIME; 342 } 343 344 static String getJVMOSDottedName() { 345 return getJVMDottedName() + DELIMITER + MonitoredObjectType.JVM_OS; 346 } 347 348 static String getJVMGCSDottedName() { 349 return getJVMDottedName() + DELIMITER + MonitoredObjectType.JVM_GCS; 350 } 351 352 static String getJVMGCDottedName(String gcName) { 353 return getJVMGCSDottedName() + DELIMITER + DottedName.escapePart(gcName); 354 } 355 356 static String getJVMMemoryDottedName() { 357 return getJVMDottedName() + DELIMITER + MonitoredObjectType.JVM_MEMORY; 358 } 359 360 static String getJVMThreadDottedName() { 361 return getJVMDottedName() + DELIMITER + MonitoredObjectType.JVM_THREAD; 362 } 363 364 static String getJVMThreadInfoDottedName(String threadName) { 365 return getJVMThreadDottedName() + DELIMITER + DottedName.escapePart(threadName); 366 } 367 368 } 370 | Popular Tags |