java - Regarding adding spring jmx functionality in the below application -


i new world of jmx , far have explored used in monitoring , managing applications , since interested in spring jmx , have developed interface , class , could please advise me how make in perfect jmx specially spring , settings need done in spring xml this...

package dustin.jmx.modelmbeans;  /**  * interface expose model mbean via spring.  */ public interface simplecalculatorif {    public int add(final int augend, final int addend);     public int subtract(final int minuend, final int subtrahend);     public int multiply(final int factor1, final int factor2);     public double divide(final int dividend, final int divisor); }  

and below class..

package dustin.jmx.modelmbeans;   public class simplecalculator implements simplecalculatorif {    /**     * calculate sum of augend , addend.     *     * @param augend first integer added.     * @param addend second integer added.     * @return sum of augend , addend.     */    public int add(final int augend, final int addend)    {       return augend + addend;    }     /**     * calculate difference between minuend , subtrahend.     *      * @param minuend minuend in subtraction operation.     * @param subtrahend subtrahend in subtraction operation.     * @return difference of minuend , subtrahend.     */    public int subtract(final int minuend, final int subtrahend)    {       return minuend - subtrahend;    }     /**     * calculate product of 2 provided factors.     *     * @param factor1 first integer factor.     * @param factor2 second integer factor.     * @return product of provided factors.     */    public int multiply(final int factor1, final int factor2)    {       return factor1 * factor2;    }     /**     * calculate quotient of dividend divided divisor.     *     * @param dividend integer dividend.     * @param divisor integer divisor.     * @return quotient of dividend divided divisor.     */    public double divide(final int dividend, final int divisor)    {       return dividend / divisor;    } } 

1) rename simplecalculatorif simplecalculatormbean. these 2 lines in context.xml enough spring detect , register simplecalculator mbean http://docs.oracle.com/javase/tutorial/jmx/mbeans/standard.html

<context:mbean-export/> <bean class="dustin.jmx.modelmbeans.simplecalculator"/> 

2) efficient way use spring annotations, dont need interface

@managedresource(objectname="bean:name=simplecalculator", description="my managed calculator", log=true, logfile="jmx.log", currencytimelimit=15, persistpolicy="onupdate", persistperiod=200, persistlocation="foo", persistname="bar") public class simplecalculator implements simplecalculatorif {    @managedoperation    public int add(final int augend, final int addend)    {       return augend + addend;    }    ... 

actually default @managedresource no param work too, wanted show how many options have annotations. read more in spring docs


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -