2
|
1 |
/*
|
|
2 |
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
import java.beans.ConstructorProperties;
|
|
25 |
import java.util.Arrays;
|
|
26 |
import java.util.Collections;
|
|
27 |
import java.util.HashSet;
|
|
28 |
import java.util.List;
|
|
29 |
import java.util.Map;
|
|
30 |
import java.util.Set;
|
|
31 |
import java.util.SortedMap;
|
|
32 |
import java.util.SortedSet;
|
|
33 |
import java.util.TreeMap;
|
|
34 |
import java.util.TreeSet;
|
|
35 |
import javax.management.openmbean.ArrayType;
|
|
36 |
import javax.management.openmbean.CompositeType;
|
|
37 |
import javax.management.openmbean.OpenDataException;
|
|
38 |
import javax.management.openmbean.OpenType;
|
|
39 |
import javax.management.openmbean.SimpleType;
|
|
40 |
import javax.management.openmbean.TabularType;
|
|
41 |
|
|
42 |
public interface TigerMXBean {
|
|
43 |
|
|
44 |
class Point {
|
|
45 |
@ConstructorProperties({"x", "y"})
|
|
46 |
public Point(double x, double y) {
|
|
47 |
this.x = x;
|
|
48 |
this.y = y;
|
|
49 |
}
|
|
50 |
|
|
51 |
public boolean equals(Object o) {
|
|
52 |
if (!(o instanceof Point))
|
|
53 |
return false;
|
|
54 |
Point p = (Point) o;
|
|
55 |
return p.x == x && p.y == y;
|
|
56 |
}
|
|
57 |
|
|
58 |
public int hashCode() {
|
|
59 |
return new Double(x).hashCode() ^ new Double(y).hashCode();
|
|
60 |
}
|
|
61 |
|
|
62 |
public double getX() {return x;}
|
|
63 |
public double getY() {return y;}
|
|
64 |
private final double x, y;
|
|
65 |
}
|
|
66 |
|
|
67 |
Point Point = new Point(1.5, 2.5);
|
|
68 |
CompositeType PointType = MerlinMXBean.CompositeTypeMaker.make(
|
|
69 |
Point.class.getName(),
|
|
70 |
Point.class.getName(),
|
|
71 |
new String[] {"x", "y"},
|
|
72 |
new String[] {"x", "y"},
|
|
73 |
new OpenType[] {SimpleType.DOUBLE, SimpleType.DOUBLE});
|
|
74 |
Point getPoint();
|
|
75 |
void setPoint(Point x);
|
|
76 |
Point opPoint(Point x, Point y);
|
|
77 |
|
|
78 |
enum Tuiseal {AINMNEACH, GAIRMEACH, GINIDEACH, TABHARTHACH}
|
|
79 |
Tuiseal Enum = Tuiseal.GINIDEACH;
|
|
80 |
SimpleType EnumType = SimpleType.STRING;
|
|
81 |
Tuiseal getEnum();
|
|
82 |
void setEnum(Tuiseal x);
|
|
83 |
Tuiseal opEnum(Tuiseal x, Tuiseal y);
|
|
84 |
|
|
85 |
List<String> StringList = Arrays.asList(new String[] {"a", "b", "x"});
|
|
86 |
ArrayType StringListType =
|
|
87 |
MerlinMXBean.ArrayTypeMaker.make(1, SimpleType.STRING);
|
|
88 |
List<String> getStringList();
|
|
89 |
void setStringList(List<String> x);
|
|
90 |
List<String> opStringList(List<String> x, List<String> y);
|
|
91 |
|
|
92 |
Set<String> StringSet = new HashSet(StringList);
|
|
93 |
ArrayType StringSetType = StringListType;
|
|
94 |
Set<String> getStringSet();
|
|
95 |
void setStringSet(Set<String> x);
|
|
96 |
Set<String> opStringSet(Set<String> x, Set<String> y);
|
|
97 |
|
|
98 |
SortedSet<String> SortedStringSet = new TreeSet(StringList);
|
|
99 |
ArrayType SortedStringSetType = StringListType;
|
|
100 |
SortedSet<String> getSortedStringSet();
|
|
101 |
void setSortedStringSet(SortedSet<String> x);
|
|
102 |
SortedSet<String> opSortedStringSet(SortedSet<String> x,
|
|
103 |
SortedSet<String> y);
|
|
104 |
|
|
105 |
Map<String,List<String>> XMap = Collections.singletonMap("yo", StringList);
|
|
106 |
String XMapTypeName =
|
|
107 |
"java.util.Map<java.lang.String, java.util.List<java.lang.String>>";
|
|
108 |
CompositeType XMapRowType = MerlinMXBean.CompositeTypeMaker.make(
|
|
109 |
XMapTypeName, XMapTypeName,
|
|
110 |
new String[] {"key", "value"},
|
|
111 |
new String[] {"key", "value"},
|
|
112 |
new OpenType[] {SimpleType.STRING, StringListType});
|
|
113 |
TabularType XMapType =
|
|
114 |
TabularTypeMaker.make(XMapTypeName, XMapTypeName, XMapRowType,
|
|
115 |
new String[] {"key"});
|
|
116 |
Map<String,List<String>> getXMap();
|
|
117 |
void setXMap(Map<String,List<String>> x);
|
|
118 |
Map<String,List<String>> opXMap(Map<String,List<String>> x,
|
|
119 |
Map<String,List<String>> y);
|
|
120 |
|
|
121 |
SortedMap<String,String> XSortedMap =
|
|
122 |
new TreeMap(Collections.singletonMap("foo", "bar"));
|
|
123 |
String XSortedMapTypeName =
|
|
124 |
"java.util.SortedMap<java.lang.String, java.lang.String>";
|
|
125 |
CompositeType XSortedMapRowType = MerlinMXBean.CompositeTypeMaker.make(
|
|
126 |
XSortedMapTypeName, XSortedMapTypeName,
|
|
127 |
new String[] {"key", "value"},
|
|
128 |
new String[] {"key", "value"},
|
|
129 |
new OpenType[] {SimpleType.STRING, SimpleType.STRING});
|
|
130 |
TabularType XSortedMapType =
|
|
131 |
TabularTypeMaker.make(XSortedMapTypeName, XSortedMapTypeName,
|
|
132 |
XSortedMapRowType, new String[] {"key"});
|
|
133 |
SortedMap<String,String> getXSortedMap();
|
|
134 |
void setXSortedMap(SortedMap<String,String> x);
|
|
135 |
SortedMap<String,String> opXSortedMap(SortedMap<String,String> x,
|
|
136 |
SortedMap<String,String> y);
|
|
137 |
|
|
138 |
// For bug 6319960, try constructing Set and Map with non-Comparable
|
|
139 |
|
|
140 |
Set<Point> PointSet = new HashSet(Collections.singleton(Point));
|
|
141 |
ArrayType PointSetType =
|
|
142 |
MerlinMXBean.ArrayTypeMaker.make(1, PointType);
|
|
143 |
Set<Point> getPointSet();
|
|
144 |
void setPointSet(Set<Point> x);
|
|
145 |
Set<Point> opPointSet(Set<Point> x, Set<Point> y);
|
|
146 |
|
|
147 |
Map<Point,Point> PointMap = Collections.singletonMap(Point, Point);
|
|
148 |
String PointMapTypeName =
|
|
149 |
"java.util.Map<" + Point.class.getName() + ", " +
|
|
150 |
Point.class.getName() + ">";
|
|
151 |
CompositeType PointMapRowType = MerlinMXBean.CompositeTypeMaker.make(
|
|
152 |
PointMapTypeName, PointMapTypeName,
|
|
153 |
new String[] {"key", "value"},
|
|
154 |
new String[] {"key", "value"},
|
|
155 |
new OpenType[] {PointType, PointType});
|
|
156 |
TabularType PointMapType =
|
|
157 |
TabularTypeMaker.make(PointMapTypeName, PointMapTypeName,
|
|
158 |
PointMapRowType, new String[] {"key"});
|
|
159 |
Map<Point,Point> getPointMap();
|
|
160 |
void setPointMap(Map<Point,Point> x);
|
|
161 |
Map<Point,Point> opPointMap(Map<Point,Point> x, Map<Point,Point> y);
|
|
162 |
|
|
163 |
static class TabularTypeMaker {
|
|
164 |
static TabularType make(String typeName, String description,
|
|
165 |
CompositeType rowType, String[] indexNames) {
|
|
166 |
try {
|
|
167 |
return new TabularType(typeName, description, rowType,
|
|
168 |
indexNames);
|
|
169 |
} catch (OpenDataException e) {
|
|
170 |
throw new Error(e);
|
|
171 |
}
|
|
172 |
}
|
|
173 |
}
|
|
174 |
}
|