1 /* 2 * Copyright 2002-2005 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.springframework.jmx.export.metadata; 18 19 import java.lang.reflect.Method; 20 21 /** 22 * Interface used by the <code>MetadataMBeanInfoAssembler</code> to 23 * read source-level metadata from a managed resource's class. 24 * 25 * @author Rob Harrop 26 * @since 1.2 27 * @see org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler#setAttributeSource 28 * @see org.springframework.jmx.export.MBeanExporter#setAssembler 29 */ 30 public interface JmxAttributeSource { 31 32 /** 33 * Implementations should return an instance of <code>ManagedResource</code> 34 * if the supplied <code>Class</code> has the appropriate metadata. 35 * Otherwise should return <code>null</code>. 36 * @param clazz the class to read the attribute data from 37 * @return the attribute, or <code>null</code> if not found 38 * @throws InvalidMetadataException in case of invalid attributes 39 */ 40 ManagedResource getManagedResource(Class clazz) throws InvalidMetadataException; 41 42 /** 43 * Implementations should return an instance of <code>ManagedAttribute</code> 44 * if the supplied <code>Method</code> has the corresponding metadata. 45 * Otherwise should return <code>null</code>. 46 * @param method the method to read the attribute data from 47 * @return the attribute, or <code>null</code> if not found 48 * @throws InvalidMetadataException in case of invalid attributes 49 */ 50 ManagedAttribute getManagedAttribute(Method method) throws InvalidMetadataException; 51 52 /** 53 * Implementations should return an instance of <code>ManagedOperation</code> 54 * if the supplied <code>Method</code> has the corresponding metadata. 55 * Otherwise should return <code>null</code>. 56 * @param method the method to read the attribute data from 57 * @return the attribute, or <code>null</code> if not found 58 * @throws InvalidMetadataException in case of invalid attributes 59 */ 60 ManagedOperation getManagedOperation(Method method) throws InvalidMetadataException; 61 62 /** 63 * Implementations should return an array of <code>ManagedOperationParameter</code> 64 * if the supplied <code>Method</code> has the corresponding metadata. Otherwise 65 * should return an empty array if no metadata is found. 66 * @param method the <code>Method</code> to read the metadata from 67 * @return the parameter information. 68 * @throws InvalidMetadataException in the case of invalid attributes. 69 */ 70 ManagedOperationParameter[] getManagedOperationParameters(Method method) throws InvalidMetadataException; 71 72 /** 73 * Implementations should return an array of {@link ManagedNotification ManagedNotifications} 74 * if the supplied the <code>Class</code> has the corresponding metadata. Otherwise 75 * should return an empty array. 76 * @param clazz the <code>Class</code> to read the metadata from 77 * @return the notification information 78 * @throws InvalidMetadataException in the case of invalid metadata 79 */ 80 ManagedNotification[] getManagedNotifications(Class clazz) throws InvalidMetadataException; 81 } 82