001/* 002 * Copyright 2012-2018 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 * http://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.boot.actuate.autoconfigure.endpoint.jmx; 018 019import java.util.LinkedHashSet; 020import java.util.Properties; 021import java.util.Set; 022 023import org.springframework.boot.context.properties.ConfigurationProperties; 024import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; 025import org.springframework.core.env.Environment; 026import org.springframework.util.StringUtils; 027 028/** 029 * Configuration properties for JMX export of endpoints. 030 * 031 * @author Stephane Nicoll 032 * @since 2.0.0 033 */ 034@ConfigurationProperties("management.endpoints.jmx") 035public class JmxEndpointProperties { 036 037 private final Exposure exposure = new Exposure(); 038 039 /** 040 * Endpoints JMX domain name. Fallback to 'spring.jmx.default-domain' if set. 041 */ 042 private String domain = "org.springframework.boot"; 043 044 /** 045 * Whether unique runtime object names should be ensured. 046 */ 047 private Boolean uniqueNames; 048 049 /** 050 * Additional static properties to append to all ObjectNames of MBeans representing 051 * Endpoints. 052 */ 053 private final Properties staticNames = new Properties(); 054 055 public JmxEndpointProperties(Environment environment) { 056 String defaultDomain = environment.getProperty("spring.jmx.default-domain"); 057 if (StringUtils.hasText(defaultDomain)) { 058 this.domain = defaultDomain; 059 } 060 } 061 062 public Exposure getExposure() { 063 return this.exposure; 064 } 065 066 public String getDomain() { 067 return this.domain; 068 } 069 070 public void setDomain(String domain) { 071 this.domain = domain; 072 } 073 074 @Deprecated 075 @DeprecatedConfigurationProperty(replacement = "spring.jmx.unique-names") 076 public Boolean getUniqueNames() { 077 return this.uniqueNames; 078 } 079 080 @Deprecated 081 public void setUniqueNames(Boolean uniqueNames) { 082 this.uniqueNames = uniqueNames; 083 } 084 085 public Properties getStaticNames() { 086 return this.staticNames; 087 } 088 089 public static class Exposure { 090 091 /** 092 * Endpoint IDs that should be included or '*' for all. 093 */ 094 private Set<String> include = new LinkedHashSet<>(); 095 096 /** 097 * Endpoint IDs that should be excluded or '*' for all. 098 */ 099 private Set<String> exclude = new LinkedHashSet<>(); 100 101 public Set<String> getInclude() { 102 return this.include; 103 } 104 105 public void setInclude(Set<String> include) { 106 this.include = include; 107 } 108 109 public Set<String> getExclude() { 110 return this.exclude; 111 } 112 113 public void setExclude(Set<String> exclude) { 114 this.exclude = exclude; 115 } 116 117 } 118 119}