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.naming; 018 019import javax.management.MalformedObjectNameException; 020import javax.management.ObjectName; 021 022import org.springframework.lang.Nullable; 023 024/** 025 * Strategy interface that encapsulates the creation of {@code ObjectName} instances. 026 * 027 * <p>Used by the {@code MBeanExporter} to obtain {@code ObjectName}s 028 * when registering beans. 029 * 030 * @author Rob Harrop 031 * @since 1.2 032 * @see org.springframework.jmx.export.MBeanExporter 033 * @see javax.management.ObjectName 034 */ 035@FunctionalInterface 036public interface ObjectNamingStrategy { 037 038 /** 039 * Obtain an {@code ObjectName} for the supplied bean. 040 * @param managedBean the bean that will be exposed under the 041 * returned {@code ObjectName} 042 * @param beanKey the key associated with this bean in the beans map 043 * passed to the {@code MBeanExporter} 044 * @return the {@code ObjectName} instance 045 * @throws MalformedObjectNameException if the resulting {@code ObjectName} is invalid 046 */ 047 ObjectName getObjectName(Object managedBean, @Nullable String beanKey) throws MalformedObjectNameException; 048 049}