[jboss-user] [Management, JMX/JBoss] - Re: user defined mbeans - Notification Broadcaster

konkimalla do-not-reply at jboss.com
Thu Jun 28 11:15:31 EDT 2007


Even after implementing the interface I am getting the same error. Below is the mbean class 


package com.clique.cmg.util;

import org.jboss.annotation.ejb.Service;
import org.jboss.annotation.ejb.Management;
import javax.management.Notification;
import javax.management.*;
import org.jboss.mx.util.*;
import java.util.*;

@Service (objectName="TestJmxBean:service=Jmxcalculate")
@Management(JmxCalculatorMBean.class)
public class JmxCalculator extends JBossNotificationBroadcasterSupport
         implements JmxCalculatorMBean, NotificationBroadcaster {

  int growthrate;
  int result;

  public void setGrowthrate (int growthrate) {
    this.growthrate = growthrate;
  }

  public int getGrowthrate () {
    return growthrate;
  }
  
  public int calculate (int start, int end) {
    result = growthrate + start + end;
    emitNotification();
    return result;
  }

  // Lifecycle methods
  public void create() throws Exception {
       
        growthrate = 50;
        System.out.println("Calculator - Creating");
    
  }

  public void destroy() {
    System.out.println("Calculator - Destroying");
  }

  private void emitNotification() {
     try {
     System.out.println("Send the Notification");
     Notification attribNotify = new Notification("cmg", this, 1L, "Notify the result: " + result);
     sendNotification(attribNotify);         
      }  catch (Exception e)  {
            e.printStackTrace();
            System.out.println("Error in broadcaster");
        }
  }
  
}

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4058796#4058796

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4058796



More information about the jboss-user mailing list