You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Preben.Asmussen" <pr...@dr.dk> on 2012/05/23 13:06:21 UTC

exposing custom jmx properties

hi

I have used the @ManagedResource and @ManagedAttribute on a Bean that get's
used in a route.

The bean and new attribute works just fine and is visible using the jmx
console under processors, but the default processor attributes and
operations turns up as 'Unavailable' with a ReflectionException since it
using reflection on my custom bean.

Would i have to extend or implement any camel class/interface ?

Pojo class
@ManagedResource(description = "My fine res")
public class EpgMessageHandler {

        .......

        @ManagedAttribute
	public String getBSDTriggerServerState() {
		if (triggerServer != null && triggerServer.getServerState() != null) {
			return triggerServer.getServerState().toString();
		}
		return "Unknown state";
	}
}

The documentation and unittests are not clear in this respect.
http://camel.apache.org/camel-jmx.html#CamelJMX-CamelJMX

Camel version 2.9.1

Cheers
Preben

--
View this message in context: http://camel.465427.n5.nabble.com/exposing-custom-jmx-properties-tp5713375.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: exposing custom jmx properties

Posted by agagliardi <an...@gmail.com>.
Same problem in 2.9.2.

Check
org.apache.camel.management.MBeanInfoAssembler.getMBeanInfo(Object, Object,
String)

Use attributes from wrapper and from custom object too.

Solution could be a proxy on wrapper that forward custom method call to
custom object.

My workaround, but lost wrapper jmx attributes/operation.

    public ModelMBeanInfo getMBeanInfo(Object defaultManagedBean, Object
customManagedBean, String objectName)
        throws JMException
    {
        // maps and lists to contain information about attributes and
operations
        Map<String, ManagedAttributeInfo> attributes = new HashMap<String,
ManagedAttributeInfo>();
        Set<ManagedOperationInfo> operations = new
LinkedHashSet<ManagedOperationInfo>();
        Set<ModelMBeanAttributeInfo> mBeanAttributes = new
LinkedHashSet<ModelMBeanAttributeInfo>();
        Set<ModelMBeanOperationInfo> mBeanOperations = new
LinkedHashSet<ModelMBeanOperationInfo>();
        Set<ModelMBeanNotificationInfo> mBeanNotifications = new
LinkedHashSet<ModelMBeanNotificationInfo>();

        if (customManagedBean == null)
        {
            // extract details from default managed bean
            extractAttributesAndOperations(defaultManagedBean.getClass(),
attributes, operations);
            extractMbeanAttributes(defaultManagedBean, attributes,
mBeanAttributes, mBeanOperations);
            extractMbeanOperations(defaultManagedBean, operations,
mBeanOperations);
            extractMbeanNotifications(defaultManagedBean,
mBeanNotifications);

            // extract details from custom managed bean
        }
        else
        {
            attributes = new HashMap<String, ManagedAttributeInfo>();
            operations = new LinkedHashSet<ManagedOperationInfo>();
            extractAttributesAndOperations(customManagedBean.getClass(),
attributes, operations);
            extractMbeanAttributes(customManagedBean, attributes,
mBeanAttributes, mBeanOperations);
            extractMbeanOperations(customManagedBean, operations,
mBeanOperations);
            extractMbeanNotifications(customManagedBean,
mBeanNotifications);
        }





--
View this message in context: http://camel.465427.n5.nabble.com/exposing-custom-jmx-properties-tp5713375p5713514.html
Sent from the Camel - Users mailing list archive at Nabble.com.