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