1 package org.apache.tools.ant.taskdefs.optional.jmx; 2 3 52 53 54 55 import org.apache.tools.ant.BuildException; 56 57 67 public class RemoveMBeanTask extends AbstractMBeanTask { 68 69 75 protected void execute(javax.management.MBeanServer mbserver) throws BuildException { 76 77 try { 78 javax.management.ObjectName mbeanName = getObjectName(); 79 80 if (!mbserver.isRegistered(mbeanName)) { 81 String message = "Target mbean does not exist. " + toString(); 82 throw new BuildException(message); 83 } else { 84 try { 85 mbserver.unregisterMBean(mbeanName); 86 } catch (Exception ex) { 87 String message = "Cannot remove MBean. " + toString(); 88 throw new BuildException(message); 89 } 90 } 91 } catch (javax.management.MalformedObjectNameException x) { 92 throw new BuildException(x); 93 } 94 95 } 96 97 } 98 99 | Popular Tags |