Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8231227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:24:55+00:00 2026-06-07T17:24:55+00:00

I am creating prototype beans programatically/dynamically. I want those beans after initiation to be

  • 0

I am creating prototype beans programatically/dynamically. I want those beans after initiation to be in the jmx console. How I can distinguish between them? I am using anotations in order to add my beans to the jmx and I have

@ManagedResource(objectName="bean:name=MybBean")

I need to inject the objectName dynamically. Any idea how could I do it?

Here’s my jmx configuration:

<context:mbean-export server="mbeanServer" />

<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean" />

<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter"
        lazy-init="false">

        <property name="beans">
            <map>
                <entry key="Server:name=HttpAdaptor">
                    <bean class="mx4j.tools.adaptor.http.HttpAdaptor">
                        <property name="port" value="8000" />
                        <property name="host" value="0.0.0.0" />
                        <property name="processor">
                            <bean class="mx4j.tools.adaptor.http.XSLTProcessor" />
                        </property>

                    </bean>
                </entry>                
            </map>
        </property>
        <property name="listeners">
            <list>
                <!--

                -->
                <bean class="com.fixgw.jmx.HttpAdaptorMgr">
                    <property name="mbeanServer" ref="mbeanServer" />
                </bean>
            </list>
        </property>
    </bean>

   <bean id="sessionMDB" class="com.fixgw.mdb.SessionMDB"
        scope="prototype" lazy-init="true">
        <constructor-arg ref="0" />
        <constructor-arg ref="0" />
    </bean>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:24:56+00:00Added an answer on June 7, 2026 at 5:24 pm

    You can use a a JMX naming strategy to do this. At work we use an interface:

    public interface RuntimeJmxNames {
        /** this is the name= part of the object name */
        public String getJmxName();
        /** this sets the folders as 00=FirstFolder,01=Second */
        public String[] getJmxPath();
    }
    

    I’ve posted the code to implement the RuntimeMetadataNamingStrategy naming strategy.

    And then something like the following Spring beans:

    <bean id="jmxAttributeSource"
     class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource" />
    
    <bean id="jmxAssembler"
        class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
        <property name="attributeSource" ref="jmxAttributeSource" />
    </bean>
    
    <bean id="jmxNamingStrategy" class="com.j256.jmx.RuntimeMetadataNamingStrategy">
        <property name="attributeSource" ref="jmxAttributeSource" />
    </bean>
    
    <bean id="mbeanExporter" class="org.springframework.jmx.export.MBeanExporter">
        <property name="autodetect" value="true" />
        <property name="assembler" ref="jmxAssembler" />
        <property name="namingStrategy" ref="jmxNamingStrategy" />
        <property name="ensureUniqueRuntimeObjectNames" value="false" />
        <property name="excludedBeans" ref="excludedJmxBeans" />
    </bean>
    

    In your code you do something like:

    @ManagedResource(objectName = "foo.com:name=replaced", description = "...")
    public class Foo implements RuntimeJmxNames {
        ...
        public String getJmxName() {
            // here's where you can make the name be dynamic
            return toString();
        }
        @Override
        public String[] getJmxPath() {
            return new String[] { "folder" };
        }
    }
    

    Here’s the Spring documentation on JMX naming although I’m not 100% sure it covers the custom naming stuff.

    Also, my SimpleJMX package does a this as well. It uses a JmxSelfNaming interface which allows each instance of an object to define it’s own bean-name to make them unique and works well with Spring.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: JavaScript: Class.method vs. Class.prototype.method What's the difference between creating a prototype like
I'm creating a prototype of a CSS/XHTML tables-based calendar that eventually will be generated
I am mlearning javascript and have some trouble creating an onject via prototype. I
(creating a separate question after comments on this: Javascript redeclared global variable overrides old
When creating prototype classes I lay out the destructor as such: virtual ~MyClass(); When
I am creating a website using jsp, ajax, servlets. My framework is prototype. The
I'm creating file(images) upload form. I want to add input elements by clicking on
I'm creating a prototype with Pencil an open source wireframing and mocking tool. I
I am creating a quick and dirty prototype (C#) of an object-relational mapping tool.
I am creating an AJAX API for a web service and I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.