Results 1 to 2 of 2

Thread: How to specify custom naming stragegy using Spring JMX Annotations

  1. #1

    Default How to specify custom naming stragegy using Spring JMX Annotations

    Currently I specify MBeanExporter like this:

    Code:
    	<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
    		<property name="beans">
    			<map>
    				<entry key="RouterCache" value-ref="routerCache" />
    			</map>
    		</property>
    		<property name="namingStrategy" ref="websphereNamingStrategy" />
    	</bean>
    
    	<bean id="websphereNamingStrategy" class="com.xxx.WebSphereNamingStrategy">
    		<constructor-arg ref="WASAdminService" />
    	</bean>
    This works fine, but I want to achieve the same thing using Spring JMX annotations, but I couldn't find a way to specify 'namingStragey' reference in the Annotations (@ManagedResource or on <context:managed /> tag). Any help is appreciated.

    Thanks, Kiran

  2. #2

    Default

    Only way I found is that define MetadataMBeanInfoAssembler and configure the MBeanExporter with this assembler. In this way it will identify the annotations using AnnotationJmxAttributeSource. It may just be the limitation of <context:managed/> annotation. Here is how it looks my configuration..

    Code:
    	<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
    		<property name="assembler" ref="assembler" />
    		<property name="namingStrategy" ref="namingStrategy" />
    		<property name="autodetect" value="true" />
    		<property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING" />
    	</bean>
    	
    	<bean id="jmxAttributeSource"
    		class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource" />
    
    	<bean id="assembler"
    		class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
    		<property name="attributeSource" ref="jmxAttributeSource" />
    	</bean>
    	
    	<bean id="WASAdminService" class="com.ibm.websphere.management.AdminServiceFactory"
    			factory-method="getAdminService" />
    
    	<bean id="namingStrategy" class="com.xxx.xxx.WebSphereNamingStrategy">
    		<constructor-arg ref="WASAdminService" />
    	</bean>
    And I annotated the classes that I need to expose as MBeans with @ManagedResource and everything works fine.. I am not sure if there is a better way to do this.

    Kiran
    Last edited by gundakiran; Mar 7th, 2012 at 12:03 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •