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