Path: blob/master/test/jdk/javax/management/mxbean/TigerMXBean.java
41152 views
/*1* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import javax.management.ConstructorParameters;24import java.util.Arrays;25import java.util.Collections;26import java.util.HashSet;27import java.util.List;28import java.util.Map;29import java.util.Set;30import java.util.SortedMap;31import java.util.SortedSet;32import java.util.TreeMap;33import java.util.TreeSet;34import javax.management.openmbean.ArrayType;35import javax.management.openmbean.CompositeType;36import javax.management.openmbean.OpenDataException;37import javax.management.openmbean.OpenType;38import javax.management.openmbean.SimpleType;39import javax.management.openmbean.TabularType;4041public interface TigerMXBean {4243class Point {44@ConstructorParameters({"x", "y"})45public Point(double x, double y) {46this.x = x;47this.y = y;48}4950public boolean equals(Object o) {51if (!(o instanceof Point))52return false;53Point p = (Point) o;54return p.x == x && p.y == y;55}5657public int hashCode() {58return new Double(x).hashCode() ^ new Double(y).hashCode();59}6061public double getX() {return x;}62public double getY() {return y;}63private final double x, y;64}6566Point Point = new Point(1.5, 2.5);67CompositeType PointType = MerlinMXBean.CompositeTypeMaker.make(68Point.class.getName(),69Point.class.getName(),70new String[] {"x", "y"},71new String[] {"x", "y"},72new OpenType[] {SimpleType.DOUBLE, SimpleType.DOUBLE});73Point getPoint();74void setPoint(Point x);75Point opPoint(Point x, Point y);7677enum Tuiseal {AINMNEACH, GAIRMEACH, GINIDEACH, TABHARTHACH}78Tuiseal Enum = Tuiseal.GINIDEACH;79SimpleType EnumType = SimpleType.STRING;80Tuiseal getEnum();81void setEnum(Tuiseal x);82Tuiseal opEnum(Tuiseal x, Tuiseal y);8384List<String> StringList = Arrays.asList(new String[] {"a", "b", "x"});85ArrayType<?> StringListType =86MerlinMXBean.ArrayTypeMaker.make(1, SimpleType.STRING);87List<String> getStringList();88void setStringList(List<String> x);89List<String> opStringList(List<String> x, List<String> y);9091Set<String> StringSet = new HashSet<String>(StringList);92ArrayType<?> StringSetType = StringListType;93Set<String> getStringSet();94void setStringSet(Set<String> x);95Set<String> opStringSet(Set<String> x, Set<String> y);9697SortedSet<String> SortedStringSet = new TreeSet<String>(StringList);98ArrayType<?> SortedStringSetType = StringListType;99SortedSet<String> getSortedStringSet();100void setSortedStringSet(SortedSet<String> x);101SortedSet<String> opSortedStringSet(SortedSet<String> x,102SortedSet<String> y);103104Map<String,List<String>> XMap = Collections.singletonMap("yo", StringList);105String XMapTypeName =106"java.util.Map<java.lang.String, java.util.List<java.lang.String>>";107CompositeType XMapRowType = MerlinMXBean.CompositeTypeMaker.make(108XMapTypeName, XMapTypeName,109new String[] {"key", "value"},110new String[] {"key", "value"},111new OpenType[] {SimpleType.STRING, StringListType});112TabularType XMapType =113TabularTypeMaker.make(XMapTypeName, XMapTypeName, XMapRowType,114new String[] {"key"});115Map<String,List<String>> getXMap();116void setXMap(Map<String,List<String>> x);117Map<String,List<String>> opXMap(Map<String,List<String>> x,118Map<String,List<String>> y);119120SortedMap<String,String> XSortedMap =121new TreeMap<String,String>(Collections.singletonMap("foo", "bar"));122String XSortedMapTypeName =123"java.util.SortedMap<java.lang.String, java.lang.String>";124CompositeType XSortedMapRowType = MerlinMXBean.CompositeTypeMaker.make(125XSortedMapTypeName, XSortedMapTypeName,126new String[] {"key", "value"},127new String[] {"key", "value"},128new OpenType[] {SimpleType.STRING, SimpleType.STRING});129TabularType XSortedMapType =130TabularTypeMaker.make(XSortedMapTypeName, XSortedMapTypeName,131XSortedMapRowType, new String[] {"key"});132SortedMap<String,String> getXSortedMap();133void setXSortedMap(SortedMap<String,String> x);134SortedMap<String,String> opXSortedMap(SortedMap<String,String> x,135SortedMap<String,String> y);136137// For bug 6319960, try constructing Set and Map with non-Comparable138139Set<Point> PointSet = new HashSet<Point>(Collections.singleton(Point));140ArrayType<?> PointSetType =141MerlinMXBean.ArrayTypeMaker.make(1, PointType);142Set<Point> getPointSet();143void setPointSet(Set<Point> x);144Set<Point> opPointSet(Set<Point> x, Set<Point> y);145146Map<Point,Point> PointMap = Collections.singletonMap(Point, Point);147String PointMapTypeName =148"java.util.Map<" + Point.class.getName() + ", " +149Point.class.getName() + ">";150CompositeType PointMapRowType = MerlinMXBean.CompositeTypeMaker.make(151PointMapTypeName, PointMapTypeName,152new String[] {"key", "value"},153new String[] {"key", "value"},154new OpenType[] {PointType, PointType});155TabularType PointMapType =156TabularTypeMaker.make(PointMapTypeName, PointMapTypeName,157PointMapRowType, new String[] {"key"});158Map<Point,Point> getPointMap();159void setPointMap(Map<Point,Point> x);160Map<Point,Point> opPointMap(Map<Point,Point> x, Map<Point,Point> y);161162static class TabularTypeMaker {163static TabularType make(String typeName, String description,164CompositeType rowType, String[] indexNames) {165try {166return new TabularType(typeName, description, rowType,167indexNames);168} catch (OpenDataException e) {169throw new Error(e);170}171}172}173}174175176