KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > testapp > mbeans > OpenMBeanDataTypeTest


1 /**
2 * Copyright (c) 2004-2005 jManage.org
3 *
4 * This is a free software; you can redistribute it and/or
5 * modify it under the terms of the license at
6 * http://www.jmanage.org.
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */

14 package org.jmanage.testapp.mbeans;
15
16 import javax.management.openmbean.*;
17
18 /**
19  *
20  * <p>
21  * Date: Sep 26, 2005
22  * @author Rakesh Kalra
23  */

24 public class OpenMBeanDataTypeTest implements OpenMBeanDataTypeTestMBean {
25
26     private TabularData tabularData;
27     private CompositeData compositeData;
28
29     public OpenMBeanDataTypeTest() throws OpenDataException {
30
31         String JavaDoc[] itemNames = {
32             "Name",
33             "NumberOfFloors",
34             "Height",
35             "UndergroundParking",
36             "NumberOfElevators",
37             "OfficeSpage"};
38
39         String JavaDoc[] itemDescriptions = {
40             "Name of the building",
41             "The number of floors the building has",
42             "The height of the building in feet",
43             "Whether or not the building has underground parking",
44             "The total number of elevators in the building",
45             "The amount of office space in square feet"
46         };
47
48         OpenType[] itemTypes = {
49             SimpleType.STRING,
50             SimpleType.SHORT,
51             SimpleType.INTEGER,
52             SimpleType.BOOLEAN,
53             SimpleType.SHORT,
54             SimpleType.LONG
55         };
56
57         CompositeType buildingType = new CompositeType(
58             "BuildingCompositeType",
59             "CompositeType that represents a building",
60             itemNames,
61             itemDescriptions,
62             itemTypes);
63
64         Object JavaDoc[] itemValuesA = {
65             "Building A",
66             new Short JavaDoc((short)3),
67             new Integer JavaDoc(100),
68             Boolean.FALSE,
69             new Short JavaDoc((short)1),
70             new Long JavaDoc(10000)
71         };
72
73         Object JavaDoc[] itemValuesB = {
74             "Building B",
75             new Short JavaDoc((short)5),
76             new Integer JavaDoc(90),
77             Boolean.FALSE,
78             new Short JavaDoc((short)2),
79             new Long JavaDoc(20000)
80         };
81
82         Object JavaDoc[] itemValuesC = {
83             "Building C",
84             new Short JavaDoc((short)5),
85             new Integer JavaDoc(80),
86             Boolean.FALSE,
87             new Short JavaDoc((short)2),
88             new Long JavaDoc(20000)
89         };
90
91         compositeData = new CompositeDataSupport(buildingType,
92                 itemNames, itemValuesA);
93
94         TabularType tabularType =
95                 new TabularType(TabularData.class.getName(),
96                         "Table containing building info",
97                         buildingType,
98                         new String JavaDoc[]{"Name"});
99         tabularData = new TabularDataSupport(tabularType);
100         tabularData.put(new CompositeDataSupport(buildingType, itemNames,
101                 itemValuesB));
102         tabularData.put(compositeData);
103         tabularData.put(new CompositeDataSupport(buildingType, itemNames,
104                         itemValuesC));
105     }
106
107     public TabularData getTabularData() {
108         return tabularData;
109     }
110
111     public CompositeData getCompositeData() {
112         return compositeData;
113     }
114
115 }
116
Popular Tags