Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Problem with JMX and AJDT

Hi

I have an Object A, and an Aspect B (See below), where I in B define an Interface AMBean, and declare that A implements this. Then I have an advice that after the contruction of A should register A as a JMX bean. However the JMX framework throws an exception :

javax.management.NotCompliantMBeanException: com.acme.A does not implement the com.acme.AMBean interface or the DynamicMBean interface

Is this a known bug, or is there something else that is wrong.

Hermod

public class A {
	
	public A()
	{		
	}
	
	public void doNothing()
	{
		System.err.println("Did'nt do anything");
	}

}

public aspect B {

	public interface AMBean {

		public void sayHello();

	}

	public interface I2 {
		
		public void sayGoodbye();
	}
	
	declare parents : A implements AMBean;

	public void AMBean.sayHello() {
		System.err.println("Hello World");
	}

	public void AMBean.somemethod()
	{
		System.err.println("in somemethod");
	}

    private pointcut managedBeanConstruction(AMBean bean) : 
        execution(AMBean+.new(..)) && this(bean); 
    
    private pointcut topLevelManagedBeanConstruction(AMBean bean) : 
        managedBeanConstruction(bean) && if(thisJoinPointStaticPart == null || thisJoinPointStaticPart.getSignature().getDeclaringType() == bean.getClass()); 
    
    after(AMBean bean) returning: topLevelManagedBeanConstruction(bean) {
		System.err.println("Loaded A: " + bean);
		bean.sayHello();
		bean.somemethod();
		MBeanServer server = ManagementFactory.getPlatformMBeanServer();
		ObjectName objectName = null;
		try {
			objectName = new ObjectName("no.dnbnor.it01.jmxtest:type=Hello");
		} catch (Exception e) {
			e.printStackTrace();
		}
		try {
			server.registerMBean(bean, objectName);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
}
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

This email with attachments is solely for the use of the individual or
entity to whom it is addressed. Please also be aware that the DnB NOR Group
cannot accept any payment orders or other legally binding correspondence with
customers as a part of an email. 

This email message has been virus checked by the anti virus programs used
in the DnB NOR Group.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


Back to the top