KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > server > core > mbean > config > naming > MBeanObjectNameHelper


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     PROPRIETARY/CONFIDENTIAL. Use of this product is subject
26     to license terms. Copyright (c) 2002 Sun Microsystems, Inc.
27         All rights reserved.
28     
29     $Id: MBeanObjectNameHelper.java,v 1.4 2005/12/25 04:14:34 tcfujii Exp $
30  */

31
32 package com.sun.enterprise.admin.server.core.mbean.config.naming;
33
34 //import com.sun.enterprise.admin.util.Debug;
35
import com.sun.enterprise.admin.common.ObjectNames;
36
37
38 //JMX imports
39
import javax.management.ObjectName JavaDoc;
40
41 import java.util.ArrayList JavaDoc;
42 /**
43     Provides help in Config MBean ObjectName manipulation
44 */

45 public class MBeanObjectNameHelper
46 {
47     /**
48      * extract name of component from ObjectName (if exists)
49      */

50 /* static public String getComponentName(ObjectName objectName, int componentType)
51     {
52         return objectName.getKeyProperty(ObjectNames.kLocationNamePrefix + componentType);
53     }
54
55  static public String getMBeanType(ObjectName objectName)
56     {
57         return objectName.getKeyProperty(ObjectNames.kTypeKeyName);
58     }
59
60     static public String getServerInstanceName(ObjectName objectName)
61     {
62         return objectName.getKeyProperty(ObjectNames.kServerInstanceKeyName);
63     }
64     static public String[] getLocationList(ObjectName objectName)
65     {
66         ArrayList list = new ArrayList();
67         int i = 1;
68         String str;
69         while((str=(String)objectName.getKeyProperty(ObjectNames.kLocationNamePrefix + i))!=null)
70         {
71            list.add(str);
72            i++;
73         }
74         String[] res = new String[i];
75         res[0] = getServerInstanceName(objectName);
76         for(i = i-1; i>0; i--)
77             res[i] = (String)list.get(i-1);
78         return res;
79     }
80     static public String generateObjectNamePattern(String type, int parmListSize)
81     {
82         parmListSize++;
83         
84         String[] names = new String[parmListSize];
85         String[] values = new String[parmListSize];
86         
87         names[0] = ObjectNames.kTypeKeyName;
88         values[0] = type;
89         names[1] = ObjectNames.kServerInstanceKeyName;
90         values[1] = "{0}";
91         
92         for(int i=2; i<parmListSize; i++)
93         {
94             names[i] = ObjectNames.kLocationNamePrefix + (i-1);
95             values[i] = "{" + (i-1) + "}";
96         }
97         
98         return ObjectNames.getObjectName(ObjectNames.kDefaultIASDomainName, names, values).toString();
99     }
100 */

101 }
102
Popular Tags