From 5d4d1eaca4fa8af29f07e23b89bee8fd028820bd Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Fri, 26 Oct 2012 15:07:48 +0200 Subject: [PATCH] Fix package cycle in @EnableMBeanExport Prior to this commit, @EnableMBeanExport was declared in the jmx.export.annotation package. This makes logical sense, but nevertheless creates a package cycle, because @EnableMBeanExport depends on MBeanExportConfiguration which in turn depends on context.annotation types like @Configuration, @Bean, and @Role. context.annotation.config.MBeanExportBeanDefinitionParser, on the other hand already has dependencies on types in jmx.support. Together, this means that a package cycle was introduced. The solution to this is simple: move @EnableMBeanExport and friends from jmx.export.annotation => context.annotation. This has been the strategy for other @Enable annotations and for the same reasons. It also makes a kind of logical sense: just like you find and under the context: XML namespace, so too do you find their @Enable* counterparts under the context.annotation namespace. Issue: SPR-8943 --- .../export => context}/annotation/EnableMBeanExport.java | 4 ++-- .../annotation/MBeanExportConfiguration.java | 7 ++----- .../annotation/EnableMBeanExportConfigurationTests.java | 2 ++ 3 files changed, 6 insertions(+), 7 deletions(-) rename spring-context/src/main/java/org/springframework/{jmx/export => context}/annotation/EnableMBeanExport.java (94%) rename spring-context/src/main/java/org/springframework/{jmx/export => context}/annotation/MBeanExportConfiguration.java (94%) diff --git a/spring-context/src/main/java/org/springframework/jmx/export/annotation/EnableMBeanExport.java b/spring-context/src/main/java/org/springframework/context/annotation/EnableMBeanExport.java similarity index 94% rename from spring-context/src/main/java/org/springframework/jmx/export/annotation/EnableMBeanExport.java rename to spring-context/src/main/java/org/springframework/context/annotation/EnableMBeanExport.java index 98dbca72da..0d01e1f3ca 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/annotation/EnableMBeanExport.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/EnableMBeanExport.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.jmx.export.annotation; +package org.springframework.context.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -22,7 +22,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.springframework.context.annotation.Import; +import org.springframework.jmx.export.annotation.AnnotationMBeanExporter; import org.springframework.jmx.support.RegistrationPolicy; /** diff --git a/spring-context/src/main/java/org/springframework/jmx/export/annotation/MBeanExportConfiguration.java b/spring-context/src/main/java/org/springframework/context/annotation/MBeanExportConfiguration.java similarity index 94% rename from spring-context/src/main/java/org/springframework/jmx/export/annotation/MBeanExportConfiguration.java rename to spring-context/src/main/java/org/springframework/context/annotation/MBeanExportConfiguration.java index 4b4993c0fe..f9d38ecefd 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/annotation/MBeanExportConfiguration.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/MBeanExportConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.jmx.export.annotation; +package org.springframework.context.annotation; import java.util.Map; @@ -25,12 +25,9 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportAware; -import org.springframework.context.annotation.Role; import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.type.AnnotationMetadata; +import org.springframework.jmx.export.annotation.AnnotationMBeanExporter; import org.springframework.jmx.support.RegistrationPolicy; import org.springframework.jmx.support.WebSphereMBeanServerFactoryBean; import org.springframework.jndi.JndiObjectFactoryBean; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java b/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java index 3c53e2a5b1..3dd6cfe08c 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java @@ -25,7 +25,9 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableMBeanExport; import org.springframework.context.annotation.Lazy; +import org.springframework.context.annotation.MBeanExportConfiguration; import org.springframework.jmx.export.MBeanExporterTests; import org.springframework.jmx.export.TestDynamicMBean; import org.springframework.jmx.support.MBeanServerFactoryBean;