Spring Framework
  1. Spring Framework
  2. SPR-8943

Introduce @EnableMBeanExport equivalent to <context:mbean-export>

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Complete
    • Affects Version/s: 3.1 GA
    • Fix Version/s: 3.2 RC1
    • Component/s: JMX
    • Last commented by a User:
      false

      Description

      Spring 3.1 introduces several @Enable* annotations. However this code snippet:

      <context:mbean-export/>
      

      cannot be expressed with annotations. There is a valid simple workaround:

      @Bean
      public AnnotationMBeanExporter annotationMBeanExporter() {
          return new AnnotationMBeanExporter();
      }
      

      but it would be nice to have built-in @Enable... annotation. Note that in JavaConfig project there was @MBeanExport annotation.

        Activity

        Hide
        Bob Tiernay added a comment -

        I agree. @EnableMBeanExport seams to be missing from the list of @Enable* annotations. In order to fully support this, @ManagedResource should be relaxed to allow for putting this on a method in @Configuration classes. Otherwise it is not possible to expose a bean via annotations for which you do not have the source for.

        Show
        Bob Tiernay added a comment - I agree. @EnableMBeanExport seams to be missing from the list of @Enable * annotations. In order to fully support this, @ManagedResource should be relaxed to allow for putting this on a method in @Configuration classes. Otherwise it is not possible to expose a bean via annotations for which you do not have the source for.
        Hide
        Phil Webb added a comment -

        Bob Tiernay I have created SPR-9908 for allowing @ManagedResource to be used on @Bean methods. Please track that issue if you want to monitor progress. This issue will only target @EnableMBeanExport functionality.

        Show
        Phil Webb added a comment - Bob Tiernay I have created SPR-9908 for allowing @ManagedResource to be used on @Bean methods. Please track that issue if you want to monitor progress. This issue will only target @EnableMBeanExport functionality.
        Show
        Phil Webb added a comment - https://github.com/SpringSource/spring-framework/pull/171
        Hide
        Chris Beams added a comment -

        Thanks, Phil!

        commit cae08db6a9808bf9708d8bfd69417f792d4b06b6
        Author: Phillip Webb <pwebb@vmware.com>
        Commit: Chris Beams <cbeams@vmware.com>
        
            Introduce @EnableMBeanExport
            
            Add support for @EnableMBeanExport annotation allowing @Configuration
            classes to easily export all MBeans and @ManagedResources from the
            Spring application context. The annotation is functionally equivalent
            to the XML <context:mbean-export/> element.
            
            Issue: SPR-8943
        
        Show
        Chris Beams added a comment - Thanks, Phil! commit cae08db6a9808bf9708d8bfd69417f792d4b06b6 Author: Phillip Webb <pwebb@vmware.com> Commit: Chris Beams <cbeams@vmware.com> Introduce @EnableMBeanExport Add support for @EnableMBeanExport annotation allowing @Configuration classes to easily export all MBeans and @ManagedResources from the Spring application context. The annotation is functionally equivalent to the XML <context:mbean-export/> element. Issue: SPR-8943
        Hide
        Chris Beams added a comment -
        commit 5d4d1eaca4fa8af29f07e23b89bee8fd028820bd
        Author: Chris Beams <cbeams@vmware.com>
        Commit: Chris Beams <cbeams@vmware.com>
        
            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 <context:mbean-export> and
            <context:load-time-weaver> under the context: XML namespace, so too do
            you find their @Enable* counterparts under the context.annotation
            namespace.
            
            Issue: SPR-8943
        
        Show
        Chris Beams added a comment - commit 5d4d1eaca4fa8af29f07e23b89bee8fd028820bd Author: Chris Beams <cbeams@vmware.com> Commit: Chris Beams <cbeams@vmware.com> 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 <context:mbean-export> and <context:load-time-weaver> under the context: XML namespace, so too do you find their @Enable* counterparts under the context.annotation namespace. Issue: SPR-8943

          People

          • Assignee:
            Chris Beams
            Reporter:
            Tomasz Nurkiewicz
            Last updater:
            Chris Beams
          • Votes:
            5 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              1 year, 25 weeks, 6 days ago