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