KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > monitor > registry > spi > DottedNameFactory


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * DottedNameFactory.java
26  * $Id: DottedNameFactory.java,v 1.3 2005/12/25 03:43:32 tcfujii Exp $
27  * $Revision: 1.3 $
28  * $Date: 2005/12/25 03:43:32 $
29  * Indentation Information:
30  * 0. Please (try to) preserve these settings.
31  * 1. Tabs are preferred over spaces.
32  * 2. In vi/vim -
33  * :set tabstop=4 :set shiftwidth=4 :set softtabstop=4
34  * 3. In S1 Studio -
35  * 1. Tools->Options->Editor Settings->Java Editor->Tab Size = 4
36  * 2. Tools->Options->Indentation Engines->Java Indentation Engine->Expand Tabs to Spaces = False.
37  * 3. Tools->Options->Indentation Engines->Java Indentation Engine->Number of Spaces per Tab = 4.
38  *
39  * Created on September 4, 2003, 10:25 AM
40  */

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; // for logger name
49
import com.sun.enterprise.util.i18n.StringManager;
50 import com.sun.enterprise.admin.dottedname.DottedName;
51
52 /**
53  * Provides methods to get DottedNames pertaining to various
54  * components in the monitoring tree hierarchy
55  * @author Shreedhar Ganapathy<mailto:shreedhar.ganapathy@sun.com>
56  * @revision $Revision: 1.3 $
57  */

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 JavaDoc instanceName =null;
62     private static final String JavaDoc DELIMITER = ".";
63     
64     private static String JavaDoc getInstanceName(){
65         if(instanceName == null){
66             try{
67                 instanceName = (ApplicationServer.getServerContext()).getInstanceName();
68                 if(instanceName==null) {
69                     final String JavaDoc msg = sm.getString("instance_name_not_found");
70                     throw new NullPointerException JavaDoc(msg);
71                 }
72             }
73             catch(Exception JavaDoc e){
74                 logger.fine("DottedNameFactory:"+e.getClass().getName());
75                 throw new RuntimeException JavaDoc(e);
76             }
77         }
78         return instanceName;
79     }
80
81     static String JavaDoc getRootDottedName(){
82         return getInstanceName();
83     }
84     
85     static String JavaDoc getApplicationsDottedName(){
86         return getInstanceName() + DELIMITER + MonitoredObjectType.APPLICATIONS;
87     }
88     
89     static String JavaDoc getResourcesDottedName(){
90         return getInstanceName() + DELIMITER + MonitoredObjectType.RESOURCES;
91     }
92     
93     static String JavaDoc getOrbDottedName(){
94         return getInstanceName() + DELIMITER + MonitoredObjectType.ORB;
95     }
96     
97     static String JavaDoc getTransactionServiceDottedName(){
98         return getInstanceName() + DELIMITER + MonitoredObjectType.TRANSACTION_SERVICE;
99     }
100     
101     static String JavaDoc getThreadPoolsDottedName(){
102         return getInstanceName() + DELIMITER + MonitoredObjectType.THREAD_POOLS;
103     }
104     
105     static String JavaDoc getThreadPoolDottedName(String JavaDoc name){
106         name = DottedName.escapePart(name);
107         return getThreadPoolsDottedName() + DELIMITER + name;
108     }
109     
110     static String JavaDoc getHttpServiceDottedName(){
111         return getInstanceName() + DELIMITER + MonitoredObjectType.HTTP_SERVICE;
112     }
113     
114     static String JavaDoc getJVMDottedName(){
115         return getInstanceName() + DELIMITER + MonitoredObjectType.JVM;
116     }
117     
118     static String JavaDoc getHttpSvcVirtualServerDottedName(String JavaDoc vs){
119         vs = DottedName.escapePart(vs);
120         return getHttpServiceDottedName() + DELIMITER + vs;
121     }
122     
123     static String JavaDoc getHttpListenerDottedName(String JavaDoc listenerName, String JavaDoc vs){
124         listenerName = DottedName.escapePart(listenerName);
125         return getHttpSvcVirtualServerDottedName(vs) + DELIMITER + listenerName;
126     }
127         
128     static String JavaDoc getConnectionManagersDottedName(){
129         return getOrbDottedName() + DELIMITER + MonitoredObjectType.CONNECTION_MANAGERS;
130     }
131
132     static String JavaDoc getOrbConnectionManagerDottedName(String JavaDoc name){
133         name = DottedName.escapePart(name);
134         return getConnectionManagersDottedName() + DELIMITER + name;
135     }
136     
137     static String JavaDoc getConnectionPoolDottedName(String JavaDoc poolName, String JavaDoc type){
138         poolName = DottedName.escapePart(poolName);
139         return getResourcesDottedName() + DELIMITER + poolName;
140     }
141
142     static String JavaDoc getStandAloneEJBModuleDottedName(String JavaDoc module){
143         module = DottedName.escapePart(module);
144         return getApplicationsDottedName() + DELIMITER + module;
145     }
146     
147     static String JavaDoc getStandAloneWebModuleDottedName(String JavaDoc module){
148         module = DottedName.escapePart(module);
149         return getApplicationsDottedName() + DELIMITER + module;
150     }
151
152     static String JavaDoc getAppDottedName(String JavaDoc app){
153         app = DottedName.escapePart(app);
154         return getApplicationsDottedName() + DELIMITER + app;
155     }
156     
157     static String JavaDoc getAppModuleDottedName(String JavaDoc app, String JavaDoc module){
158         module = DottedName.escapePart(module);
159         return getAppDottedName(app) + DELIMITER + module;
160     }
161     
162     static String JavaDoc getWebAppsVirtualServerDottedName(String JavaDoc app, String JavaDoc module,
163     String JavaDoc 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 JavaDoc getServletDottedName(String JavaDoc app, String JavaDoc module,
172         String JavaDoc vs, String JavaDoc servlet){
173         servlet = DottedName.escapePart(servlet);
174         return getWebAppsVirtualServerDottedName(app, module, vs) + DELIMITER + servlet;
175     }
176     
177     static String JavaDoc getEJBDottedName(String JavaDoc app, String JavaDoc module, String JavaDoc 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 JavaDoc getEJBDottedNameWithType(String JavaDoc app, String JavaDoc module, String JavaDoc ejb,
186         String JavaDoc 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 JavaDoc getEJBCacheDottedName(String JavaDoc app, String JavaDoc module, String JavaDoc ejb){
195         return getEJBDottedName(app, module, ejb) + DELIMITER + MonitoredObjectType.BEAN_CACHE;
196     }
197     
198     static String JavaDoc getEJBPoolDottedName(String JavaDoc app, String JavaDoc module, String JavaDoc ejb){
199         return getEJBDottedName(app, module, ejb) + DELIMITER + MonitoredObjectType.BEAN_POOL;
200     }
201
202     static String JavaDoc getEJBMethodsDottedName(String JavaDoc app, String JavaDoc module, String JavaDoc ejb){
203         return getEJBDottedName(app, module, ejb) + DELIMITER + MonitoredObjectType.BEAN_METHODS;
204     }
205     
206     static String JavaDoc getEJBMethodDottedName(String JavaDoc app, String JavaDoc module, String JavaDoc ejb, String JavaDoc method){
207         return getEJBMethodsDottedName(app,module,ejb) + DELIMITER + DottedName.escapePart(method);
208     }
209        
210     // connector & jms service, related changes
211
static String JavaDoc getConnectorServiceDottedName() {
212         return getInstanceName() + DELIMITER + MonitoredObjectType.CONNECTOR_SERVICE;
213     }
214     
215     static String JavaDoc getJmsServiceDottedName() {
216         return getInstanceName() + DELIMITER + MonitoredObjectType.JMS_SERVICE;
217     }
218     
219     static String JavaDoc getConnectorModuleDottedName(String JavaDoc j2eeAppName, String JavaDoc 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 JavaDoc getConnectorWorkMgmtDottedName(String JavaDoc j2eeAppName, String JavaDoc moduleName, boolean isJms) {
229         
230         String JavaDoc 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 JavaDoc getConnectionFactoriesDottedName() {
242         return getJmsServiceDottedName() + DELIMITER + MonitoredObjectType.CONNECTION_FACTORIES;
243     }
244     
245     static String JavaDoc getConnectionFactoryDottedName(String JavaDoc factoryName) {
246         return getConnectionFactoriesDottedName() + DELIMITER + DottedName.escapePart(factoryName);
247     }
248     
249     static String JavaDoc getConnectionPoolsDottedName(String JavaDoc j2eeAppName, String JavaDoc moduleName) {
250         return getConnectorModuleDottedName(j2eeAppName, moduleName) + DELIMITER + MonitoredObjectType.CONNECTION_POOLS;
251     }
252     
253     static String JavaDoc getConnectionPoolDottedName(String JavaDoc poolName, String JavaDoc j2eeAppName, String JavaDoc moduleName){
254         return getConnectionPoolsDottedName(j2eeAppName, moduleName) + DELIMITER + DottedName.escapePart(poolName);
255     }
256     
257     // PWC integration, related changes
258
static String JavaDoc getConnectionQueueDottedName() {
259         return getHttpServiceDottedName() + DELIMITER + MonitoredObjectType.CONNECTION_QUEUE;
260     }
261     
262     static String JavaDoc getDnsDottedName() {
263         return getHttpServiceDottedName() + DELIMITER + MonitoredObjectType.DNS;
264     }
265     
266     static String JavaDoc getKeepAliveDottedName() {
267         return getHttpServiceDottedName() + DELIMITER + MonitoredObjectType.KEEP_ALIVE;
268     }
269     
270     static String JavaDoc getPWCThreadPoolDottedName() {
271         return getHttpServiceDottedName() + DELIMITER + MonitoredObjectType.PWC_THREAD_POOL;
272     }
273     
274     static String JavaDoc getFileCacheDottedName() {
275         return getHttpServiceDottedName() + DELIMITER + MonitoredObjectType.FILE_CACHE;
276     }
277     
278     static String JavaDoc getRequestDottedName(String JavaDoc vsId) {
279         return getHttpSvcVirtualServerDottedName(vsId) + DELIMITER + MonitoredObjectType.REQUEST;
280     }
281     
282     // SessionStore Monitoring related changes
283
static String JavaDoc getStatefulSessionStoreDottedName(String JavaDoc ejbName, String JavaDoc moduleName, String JavaDoc j2eeAppName) {
284         return getEJBDottedName(j2eeAppName, moduleName, ejbName) + DELIMITER + MonitoredObjectType.SESSION_STORE;
285     }
286     
287     // Timer monitoring related changes
288
static String JavaDoc getTimerDottedName(String JavaDoc ejbName, String JavaDoc moduleName, String JavaDoc j2eeAppName) {
289         return getEJBDottedName(j2eeAppName, moduleName, ejbName) + DELIMITER + MonitoredObjectType.TIMERS;
290     }
291     
292     // Web Services monitoring related changes
293
static String JavaDoc getWebServiceAggregateStatsInEjbDottedName(
294         String JavaDoc endpointName, String JavaDoc moduleName, String JavaDoc j2eeAppName) {
295
296         return getWebServiceInEjbDottedName(j2eeAppName,moduleName,
297             endpointName) + DELIMITER + MonitoredObjectType.WEBSERVICE_ENDPOINT;
298
299     }
300
301     static String JavaDoc getWebServiceAggregateStatsInWebDottedName(
302         String JavaDoc endpointName, String JavaDoc moduleName, String JavaDoc j2eeAppName) {
303
304         return getWebServiceInWebDottedName(j2eeAppName,moduleName,
305             endpointName) + DELIMITER + MonitoredObjectType.WEBSERVICE_ENDPOINT;
306
307     }
308
309     static String JavaDoc getWebServiceInWebDottedName(String JavaDoc app,String JavaDoc module, String JavaDoc
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 JavaDoc getWebServiceInEjbDottedName(String JavaDoc app,String JavaDoc module, String JavaDoc
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     // JVM1.5 related changes - BEGIN
332
static String JavaDoc getJVMCompilationDottedName() {
333         return getJVMDottedName() + DELIMITER + MonitoredObjectType.JVM_COMPILATION;
334     }
335     
336     static String JavaDoc getJVMClassLoadingDottedName() {
337         return getJVMDottedName() + DELIMITER + MonitoredObjectType.JVM_CLASSLOADING;
338     }
339     
340     static String JavaDoc getJVMRuntimeDottedName() {
341         return getJVMDottedName() + DELIMITER + MonitoredObjectType.JVM_RUNTIME;
342     }
343     
344     static String JavaDoc getJVMOSDottedName() {
345         return getJVMDottedName() + DELIMITER + MonitoredObjectType.JVM_OS;
346     }
347     
348     static String JavaDoc getJVMGCSDottedName() {
349         return getJVMDottedName() + DELIMITER + MonitoredObjectType.JVM_GCS;
350     }
351     
352     static String JavaDoc getJVMGCDottedName(String JavaDoc gcName) {
353         return getJVMGCSDottedName() + DELIMITER + DottedName.escapePart(gcName);
354     }
355     
356     static String JavaDoc getJVMMemoryDottedName() {
357         return getJVMDottedName() + DELIMITER + MonitoredObjectType.JVM_MEMORY;
358     }
359         
360     static String JavaDoc getJVMThreadDottedName() {
361         return getJVMDottedName() + DELIMITER + MonitoredObjectType.JVM_THREAD;
362     }
363     
364     static String JavaDoc getJVMThreadInfoDottedName(String JavaDoc threadName) {
365         return getJVMThreadDottedName() + DELIMITER + DottedName.escapePart(threadName);
366     }
367
368     // JVM1.5 related changes - END
369
}
370
Popular Tags