001/* 002 * Copyright 2002-2012 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 java.lang.reflect.Method; 020 021import org.springframework.lang.Nullable; 022 023/** 024 * Interface used by the {@code MetadataMBeanInfoAssembler} to 025 * read source-level metadata from a managed resource's class. 026 * 027 * @author Rob Harrop 028 * @author Jennifer Hickey 029 * @since 1.2 030 * @see org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler#setAttributeSource 031 * @see org.springframework.jmx.export.MBeanExporter#setAssembler 032 */ 033public interface JmxAttributeSource { 034 035 /** 036 * Implementations should return an instance of {@code ManagedResource} 037 * if the supplied {@code Class} has the appropriate metadata. 038 * Otherwise should return {@code null}. 039 * @param clazz the class to read the attribute data from 040 * @return the attribute, or {@code null} if not found 041 * @throws InvalidMetadataException in case of invalid attributes 042 */ 043 @Nullable 044 ManagedResource getManagedResource(Class<?> clazz) throws InvalidMetadataException; 045 046 /** 047 * Implementations should return an instance of {@code ManagedAttribute} 048 * if the supplied {@code Method} has the corresponding metadata. 049 * Otherwise should return {@code null}. 050 * @param method the method to read the attribute data from 051 * @return the attribute, or {@code null} if not found 052 * @throws InvalidMetadataException in case of invalid attributes 053 */ 054 @Nullable 055 ManagedAttribute getManagedAttribute(Method method) throws InvalidMetadataException; 056 057 /** 058 * Implementations should return an instance of {@code ManagedMetric} 059 * if the supplied {@code Method} has the corresponding metadata. 060 * Otherwise should return {@code null}. 061 * @param method the method to read the attribute data from 062 * @return the metric, or {@code null} if not found 063 * @throws InvalidMetadataException in case of invalid attributes 064 */ 065 @Nullable 066 ManagedMetric getManagedMetric(Method method) throws InvalidMetadataException; 067 068 /** 069 * Implementations should return an instance of {@code ManagedOperation} 070 * if the supplied {@code Method} has the corresponding metadata. 071 * Otherwise should return {@code null}. 072 * @param method the method to read the attribute data from 073 * @return the attribute, or {@code null} if not found 074 * @throws InvalidMetadataException in case of invalid attributes 075 */ 076 @Nullable 077 ManagedOperation getManagedOperation(Method method) throws InvalidMetadataException; 078 079 /** 080 * Implementations should return an array of {@code ManagedOperationParameter} 081 * if the supplied {@code Method} has the corresponding metadata. Otherwise 082 * should return an empty array if no metadata is found. 083 * @param method the {@code Method} to read the metadata from 084 * @return the parameter information. 085 * @throws InvalidMetadataException in the case of invalid attributes. 086 */ 087 ManagedOperationParameter[] getManagedOperationParameters(Method method) throws InvalidMetadataException; 088 089 /** 090 * Implementations should return an array of {@link ManagedNotification ManagedNotifications} 091 * if the supplied the {@code Class} has the corresponding metadata. Otherwise 092 * should return an empty array. 093 * @param clazz the {@code Class} to read the metadata from 094 * @return the notification information 095 * @throws InvalidMetadataException in the case of invalid metadata 096 */ 097 ManagedNotification[] getManagedNotifications(Class<?> clazz) throws InvalidMetadataException; 098 099 100 101}