Transparent in Spring makes pojo A mbean that supports JMX

Source: Internet
Author: User

One of the few updates in spring 1.2 is JMX support.
Through a simple xml configuration file, the pojo pheasant becomes a phoenix export as a mbean, so that the customer can call the pojo method through the JMX client to view the attributes and status of pojo.
This integration method is the same as spring's integration of quartz, which is transparent and simple and worthy of promotion in the framework field.

The example is in samples/petlinc of spring, which is very simple. For more information, see Chapter 18th of spring refrence.

For example, there is a pojo named myjob. I want to output the excute () and getcallcount () functions for JMX management:

1. Definition of applicationcontext. xml file

<bean id="myJob" class="com.itorgan.myappfuse.job.MyJob"/>

<bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter">
        <property name="beans">
            <map>
                <entry key="myappfuse:service=myJob" value-ref="myJob"/>
            </map>
        </property>
        <property name="assembler">
            <bean class="org.springframework.jmx.export.assembler.MethodNameBasedMBeanInfoAssembler">
                <property name="managedMethods">
                    <value>execute,getCallCount</value>
                </property>
            </bean>
        </property>
     </bean>

2. myjob, the most common pojo, is not described.

3. With JMX client, you can execute myjob. excute () and view the getcallcount () result.

PS. My JMX Environment
1. tomcat5.5 alpha-10
Tomcat5.5 A10 uses the jdt of eclipse 3.1, and finally supports JSP using the jdk1.5 syntax
Modify $ tomcat_home/bin/Catalina. bat

Set catalina_opts =-DCOM. sun. management. jmxremote-DCOM. sun. management. jmxremote. port = 8899-DCOM. sun. management. jmxremote. SSL = false-DCOM. sun. management. jmxremote. authenticate = false

2. mc4j 
My favorite JMX client can be downloaded from mc4j.sf.net or the built-in JDK.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.