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.context.annotation;
018
019import java.lang.annotation.Documented;
020import java.lang.annotation.ElementType;
021import java.lang.annotation.Retention;
022import java.lang.annotation.RetentionPolicy;
023import java.lang.annotation.Target;
024
025import org.springframework.jmx.export.annotation.AnnotationMBeanExporter;
026import org.springframework.jmx.support.RegistrationPolicy;
027
028/**
029 * Enables default exporting of all standard {@code MBean}s from the Spring context, as
030 * well as well all {@code @ManagedResource} annotated beans.
031 *
032 * <p>The resulting {@link org.springframework.jmx.export.MBeanExporter MBeanExporter}
033 * bean is defined under the name "mbeanExporter". Alternatively, consider defining a
034 * custom {@link AnnotationMBeanExporter} bean explicitly.
035 *
036 * <p>This annotation is modeled after and functionally equivalent to Spring XML's
037 * {@code <context:mbean-export/>} element.
038 *
039 * @author Phillip Webb
040 * @since 3.2
041 * @see MBeanExportConfiguration
042 */
043@Target(ElementType.TYPE)
044@Retention(RetentionPolicy.RUNTIME)
045@Documented
046@Import(MBeanExportConfiguration.class)
047public @interface EnableMBeanExport {
048
049        /**
050         * The default domain to use when generating JMX ObjectNames.
051         */
052        String defaultDomain() default "";
053
054        /**
055         * The bean name of the MBeanServer to which MBeans should be exported. Default is to
056         * use the platform's default MBeanServer.
057         */
058        String server() default "";
059
060        /**
061         * The policy to use when attempting to register an MBean under an
062         * {@link javax.management.ObjectName} that already exists. Defaults to
063         * {@link RegistrationPolicy#FAIL_ON_EXISTING}.
064         */
065        RegistrationPolicy registration() default RegistrationPolicy.FAIL_ON_EXISTING;
066}