@ -46,9 +46,12 @@ import org.springframework.jmx.export.MBeanExporter;
import org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource ;
import org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource ;
import org.springframework.jmx.export.annotation.ManagedResource ;
import org.springframework.jmx.export.annotation.ManagedResource ;
import org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler ;
import org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler ;
import org.springframework.jmx.export.metadata.InvalidMetadataException ;
import org.springframework.jmx.export.metadata.JmxAttributeSource ;
import org.springframework.jmx.export.naming.MetadataNamingStrategy ;
import org.springframework.jmx.export.naming.MetadataNamingStrategy ;
import org.springframework.jmx.export.naming.SelfNaming ;
import org.springframework.jmx.export.naming.SelfNaming ;
import org.springframework.jmx.support.ObjectNameManager ;
import org.springframework.jmx.support.ObjectNameManager ;
import org.springframework.util.Assert ;
import org.springframework.util.ObjectUtils ;
import org.springframework.util.ObjectUtils ;
/ * *
/ * *
@ -70,7 +73,7 @@ public class EndpointMBeanExporter extends MBeanExporter
private static final Log logger = LogFactory . getLog ( EndpointMBeanExporter . class ) ;
private static final Log logger = LogFactory . getLog ( EndpointMBeanExporter . class ) ;
private final AnnotationJmxAttributeSource attributeSource = new Annotation JmxAttributeSource( ) ;
private final AnnotationJmxAttributeSource attributeSource = new Endpoint JmxAttributeSource( ) ;
private final MetadataMBeanInfoAssembler assembler = new MetadataMBeanInfoAssembler (
private final MetadataMBeanInfoAssembler assembler = new MetadataMBeanInfoAssembler (
this . attributeSource ) ;
this . attributeSource ) ;
@ -253,8 +256,8 @@ public class EndpointMBeanExporter extends MBeanExporter
if ( bean instanceof SelfNaming ) {
if ( bean instanceof SelfNaming ) {
return ( ( SelfNaming ) bean ) . getObjectName ( ) ;
return ( ( SelfNaming ) bean ) . getObjectName ( ) ;
}
}
if ( bean instanceof EndpointMBean ) {
if ( bean instanceof Jmx Endpoint) {
return getObjectName ( ( EndpointMBean ) bean , beanKey ) ;
return getObjectName ( ( Jmx Endpoint) bean , beanKey ) ;
}
}
return this . defaultNamingStrategy . getObjectName ( bean , beanKey ) ;
return this . defaultNamingStrategy . getObjectName ( bean , beanKey ) ;
}
}
@ -363,4 +366,19 @@ public class EndpointMBeanExporter extends MBeanExporter
}
}
}
}
/ * *
* { @link JmxAttributeSource } for { @link JmxEndpoint JmxEndpoints } .
* /
private static class EndpointJmxAttributeSource extends AnnotationJmxAttributeSource {
@Override
public org . springframework . jmx . export . metadata . ManagedResource getManagedResource (
Class < ? > beanClass ) throws InvalidMetadataException {
Assert . state ( super . getManagedResource ( beanClass ) = = null ,
"@ManagedResource annotation found on JmxEndpoint " + beanClass ) ;
return new org . springframework . jmx . export . metadata . ManagedResource ( ) ;
}
}
}
}