001/* 002 * Copyright 2002-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.jmx.export.metadata; 018 019import org.springframework.jmx.support.MetricType; 020import org.springframework.util.Assert; 021 022/** 023 * Metadata that indicates to expose a given bean property as a JMX attribute, 024 * with additional descriptor properties that indicate that the attribute is a 025 * metric. Only valid when used on a JavaBean getter. 026 * 027 * @author Jennifer Hickey 028 * @since 3.0 029 * @see org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler 030 */ 031public class ManagedMetric extends AbstractJmxAttribute { 032 033 private String category = ""; 034 035 private String displayName = ""; 036 037 private MetricType metricType = MetricType.GAUGE; 038 039 private int persistPeriod = -1; 040 041 private String persistPolicy = ""; 042 043 private String unit = ""; 044 045 046 /** 047 * The category of this metric (ex. throughput, performance, utilization). 048 */ 049 public void setCategory(String category) { 050 this.category = category; 051 } 052 053 /** 054 * The category of this metric (ex. throughput, performance, utilization). 055 */ 056 public String getCategory() { 057 return this.category; 058 } 059 060 /** 061 * A display name for this metric. 062 */ 063 public void setDisplayName(String displayName) { 064 this.displayName = displayName; 065 } 066 067 /** 068 * A display name for this metric. 069 */ 070 public String getDisplayName() { 071 return this.displayName; 072 } 073 074 /** 075 * A description of how this metric's values change over time. 076 */ 077 public void setMetricType(MetricType metricType) { 078 Assert.notNull(metricType, "MetricType must not be null"); 079 this.metricType = metricType; 080 } 081 082 /** 083 * A description of how this metric's values change over time. 084 */ 085 public MetricType getMetricType() { 086 return this.metricType; 087 } 088 089 /** 090 * The persist period for this metric. 091 */ 092 public void setPersistPeriod(int persistPeriod) { 093 this.persistPeriod = persistPeriod; 094 } 095 096 /** 097 * The persist period for this metric. 098 */ 099 public int getPersistPeriod() { 100 return this.persistPeriod; 101 } 102 103 /** 104 * The persist policy for this metric. 105 */ 106 public void setPersistPolicy(String persistPolicy) { 107 this.persistPolicy = persistPolicy; 108 } 109 110 /** 111 * The persist policy for this metric. 112 */ 113 public String getPersistPolicy() { 114 return this.persistPolicy; 115 } 116 117 /** 118 * The expected unit of measurement values. 119 */ 120 public void setUnit(String unit) { 121 this.unit = unit; 122 } 123 124 /** 125 * The expected unit of measurement values. 126 */ 127 public String getUnit() { 128 return this.unit; 129 } 130 131}