StandardMBeanInfoCombiner6.java
package com.ziesemer.utils.jmx.server;
import javax.management.JMException;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanInfo;
import javax.management.MBeanOperationInfo;
import javax.management.MBeanParameterInfo;
import javax.management.StandardMBean;
/**
* <p>Designed to utilize {@link MBeanInfoCombiner}, and this particular class
* is designed for Java 1.6 / 6.
* An extended copy of {@link StandardMBeanInfoCombiner5}, this class provides the
* additional constructor added in Java 1.6 / 6 that supports {@link javax.management.MXBean}s.</p>
* @author Mark A. Ziesemer
* <a href="http://www.ziesemer.com."><www.ziesemer.com></a>
* @see MBeanInfoCombiner
*/
public class StandardMBeanInfoCombiner6 extends StandardMBean{
protected MBeanInfoCombiner extraInfoC;
/**
* <p>Calls {@link #StandardMBeanInfoCombiner6(Object, Class, MBeanInfo)},
* passing <code>null</code> for the {@link MBeanInfo}.</p>
*/
public <T> StandardMBeanInfoCombiner6(final T implementation, final Class<T> mBeanInterface)
throws JMException{
this(implementation, mBeanInterface, null);
}
/**
* <p>Calls {@link #StandardMBeanInfoCombiner6(Object, Class, boolean, MBeanInfo)},
* passing <code>null</code> for the {@link MBeanInfo}.</p>
*/
public <T> StandardMBeanInfoCombiner6(final T implementation, final Class<T> mBeanInterface,
final boolean isMXBean) throws JMException{
this(implementation, mBeanInterface, isMXBean, null);
}
/**
* <p>Functionally the same as {@link StandardMBean#StandardMBean(Object, Class)},
* but accepts an optional {@link MBeanInfo} to combine from.</p>
* @param extraInfo The extra {@link MBeanInfo} to combine from.
* If null, it will be built automatically using {@link MBeanInfoBuilder}.
*/
public <T> StandardMBeanInfoCombiner6(final T implementation, final Class<T> mBeanInterface,
final MBeanInfo extraInfo) throws JMException{
this(implementation, mBeanInterface, false, extraInfo);
}
/**
* <p>Functionally the same as {@link StandardMBean#StandardMBean(Object, Class, boolean)},
* but accepts an optional {@link MBeanInfo} to combine from.</p>
* @param extraInfo The extra {@link MBeanInfo} to combine from.
* If null, it will be built automatically using {@link MBeanInfoBuilder}.
*/
public <T> StandardMBeanInfoCombiner6(final T implementation, final Class<T> mBeanInterface,
final boolean isMXBean, final MBeanInfo extraInfo) throws JMException{
super(implementation, mBeanInterface, isMXBean);
MBeanInfo extraInfo2 = extraInfo;
if(extraInfo2 == null){
extraInfo2 = new MBeanInfoBuilder().build(getMBeanInterface());
}
this.extraInfoC = new MBeanInfoCombiner(extraInfo2);
}
@Override
protected synchronized void cacheMBeanInfo(final MBeanInfo info){
super.cacheMBeanInfo(info);
// Allow garbage collection.
extraInfoC = null;
}
@Override
public String getDescription(final MBeanInfo mbi){
return extraInfoC.getDescription(mbi);
}
@Override
public String getDescription(final MBeanAttributeInfo mbai){
return extraInfoC.getDescription(mbai);
}
@Override
public String getDescription(final MBeanOperationInfo mboi){
return extraInfoC.getDescription(mboi);
}
@Override
public int getImpact(final MBeanOperationInfo mboi){
return extraInfoC.getImpact(mboi);
}
@Override
public String getParameterName(final MBeanOperationInfo mboi,
final MBeanParameterInfo mbpi, final int sequence){
return extraInfoC.getParameterName(mboi, mbpi, sequence);
}
@Override
public String getDescription(final MBeanOperationInfo mboi,
final MBeanParameterInfo mbpi, final int sequence){
return extraInfoC.getDescription(mboi, mbpi, sequence);
}
}