KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > support > ComSunAppservTest


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 package com.sun.enterprise.management.support;
24
25 import javax.management.ObjectName JavaDoc;
26
27 import java.util.Set JavaDoc;
28 import java.util.Map JavaDoc;
29 import java.util.HashMap JavaDoc;
30
31 import java.io.IOException JavaDoc;
32
33 import javax.management.j2ee.statistics.Statistic JavaDoc;
34 import javax.management.j2ee.statistics.Stats JavaDoc;
35 import javax.management.j2ee.statistics.CountStatistic JavaDoc;
36 import javax.management.j2ee.statistics.BoundaryStatistic JavaDoc;
37 import javax.management.j2ee.statistics.RangeStatistic JavaDoc;
38 import javax.management.j2ee.statistics.BoundedRangeStatistic JavaDoc;
39 import javax.management.j2ee.statistics.TimeStatistic JavaDoc;
40
41 import com.sun.appserv.management.util.j2ee.J2EEUtil;
42 import com.sun.appserv.management.util.jmx.JMXUtil;
43 import com.sun.appserv.management.base.Util;
44
45 import com.sun.appserv.management.j2ee.statistics.*;
46
47
48 import com.sun.enterprise.management.AMXTestBase;
49 import com.sun.enterprise.management.Capabilities;
50
51 /**
52     Base class for testing the com.sun.appserv MBeans relied
53     upon by AMX.
54  */

55 public class ComSunAppservTest
56     extends AMXTestBase
57 {
58         public
59     ComSunAppservTest()
60     {
61     }
62     
63     /**
64         @return Map<String,ObjectName>, keyed by value of 'type' property from ObjectName
65      */

66         public Map JavaDoc<String JavaDoc,ObjectName JavaDoc>
67     getAllComSunAppservCategory( final String JavaDoc category )
68         throws IOException JavaDoc
69     {
70         final ObjectName JavaDoc pattern =
71             Util.newObjectName( "com.sun.appserv:category=" + category + ",*");
72         final Set JavaDoc<ObjectName JavaDoc> objectNames =
73             JMXUtil.queryNames( getMBeanServerConnection(), pattern, null );
74         
75         final HashMap JavaDoc<String JavaDoc,ObjectName JavaDoc> m = new HashMap JavaDoc<String JavaDoc,ObjectName JavaDoc>();
76         for( final ObjectName JavaDoc objectName : objectNames )
77         {
78             final String JavaDoc type = objectName.getKeyProperty( "type" );
79             if ( type != null )
80             {
81                 m.put( type, objectName );
82             }
83         }
84         
85         return m;
86     }
87             
88         public Map JavaDoc<String JavaDoc,ObjectName JavaDoc>
89     getAllComSunAppservMonitor()
90         throws java.io.IOException JavaDoc
91     {
92         return getAllComSunAppservCategory( "monitor" );
93     }
94     
95         public Map JavaDoc<String JavaDoc,ObjectName JavaDoc>
96     getAllComSunAppservConfig()
97         throws java.io.IOException JavaDoc
98     {
99         return getAllComSunAppservCategory( "config" );
100     }
101   
102     
103     
104 }
105
106
107
108
109
110
111
Popular Tags