ConstructorParameters.java revision 13532:859397229dc4
1199482Srdivacky/* 2195099Sed * Copyright (c) 2006, 2015 Oracle and/or its affiliates. All rights reserved. 3195099Sed * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4195099Sed * 5195099Sed * This code is free software; you can redistribute it and/or modify it 6195099Sed * under the terms of the GNU General Public License version 2 only, as 7195099Sed * published by the Free Software Foundation. Oracle designates this 8195099Sed * particular file as subject to the "Classpath" exception as provided 9195099Sed * by Oracle in the LICENSE file that accompanied this code. 10195099Sed * 11195099Sed * This code is distributed in the hope that it will be useful, but WITHOUT 12195099Sed * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13195099Sed * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14195099Sed * version 2 for more details (a copy is included in the LICENSE file that 15195099Sed * accompanied this code). 16195099Sed * 17195099Sed * You should have received a copy of the GNU General Public License version 18226633Sdim * 2 along with this work; if not, write to the Free Software Foundation, 19195099Sed * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20199990Srdivacky * 21195099Sed * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22195099Sed * or visit www.oracle.com if you need additional information or have any 23195099Sed * questions. 24195099Sed */ 25195099Sed 26195099Sedpackage javax.management; 27195099Sed 28195099Sedimport java.lang.annotation.*; 29199990Srdivackyimport static java.lang.annotation.ElementType.*; 30199990Srdivackyimport static java.lang.annotation.RetentionPolicy.*; 31199990Srdivacky 32199990Srdivacky/** 33226633Sdim * <p> 34199990Srdivacky * An annotation on a constructor that shows how the parameters of 35226633Sdim * that constructor correspond to the constructed object's getter 36226633Sdim * methods. For example: 37199990Srdivacky * </p> 38199990Srdivacky * <blockquote> 39199990Srdivacky * <pre> 40199990Srdivacky * public class MemoryUsage { 41218893Sdim * // standard JavaBean conventions with getters 42199990Srdivacky * <b>@ConstructorParameters({"init", "used", "committed", "max"})</b> 43199990Srdivacky * public MemoryUsage(long init, long used, 44218893Sdim * long committed, long max) {...} 45218893Sdim * public long getInit() {...} 46218893Sdim * public long getUsed() {...} 47218893Sdim * public long getCommitted() {...} 48218893Sdim * public long getMax() {...} 49218893Sdim * } 50199990Srdivacky * </pre> 51199990Srdivacky * </blockquote> 52195099Sed * <p> 53195099Sed * The annotation shows that the first parameter of the constructor 54195099Sed * can be retrieved with the {@code getInit()} method, the second one with 55195099Sed * the {@code getUsed()} method, and so on. Since parameter names are not in 56195099Sed * general available at runtime, without the annotation there would be 57195099Sed * no way of knowing which parameter corresponds to which property. 58195099Sed * </p> 59195099Sed * <p> 60195099Sed * If a constructor is annotated by the both {@code @java.beans.ConstructorProperties} 61195099Sed * and {@code @javax.management.ConstructorParameters} annotations 62198092Srdivacky * the JMX introspection will give an absolute precedence to the latter one. 63195099Sed * </p> 64195099Sed * 65199482Srdivacky * @since 9 66195099Sed */ 67195099Sed@Documented @Target(CONSTRUCTOR) @Retention(RUNTIME) 68195099Sedpublic @interface ConstructorParameters { 69198092Srdivacky /** 70195099Sed * <p>The getter names.</p> 71198092Srdivacky * 72195099Sed * @return the getter names corresponding to the parameters in the 73195099Sed * annotated constructor. 74195099Sed */ 75199990Srdivacky String[] value(); 76199990Srdivacky} 77199990Srdivacky