1 22 package org.objectweb.petals.tools.ant; 23 24 import javax.management.MBeanServerConnection ; 25 import javax.management.remote.JMXConnector ; 26 27 import org.apache.tools.ant.BuildException; 28 import org.objectweb.petals.tools.ant.managers.JBIAntTaskAbstract; 29 import org.objectweb.petals.tools.ant.util.JBIJMXConnectorUtil; 30 31 36 public class UninstallSharedLibTask extends JBIAntTaskAbstract { 37 38 41 private String name; 42 43 public UninstallSharedLibTask() { 44 super(); 45 } 46 47 52 public void execute() throws BuildException { 53 if (name == null) { 54 throw new BuildException("Required attribute : name"); 55 } 56 try { 57 JMXConnector connector = JBIJMXConnectorUtil.getConnection(host, 58 port, username, password); 59 MBeanServerConnection connection = connector 60 .getMBeanServerConnection(); 61 Object [] objects = new Object [1]; 62 objects[0] = name; 63 String [] strings = new String [1]; 64 strings[0] = "java.lang.String"; 65 Object result = connection.invoke(JBIJMXConnectorUtil 66 .getInstallationServiceMBeanName(connection), 67 "uninstallSharedLibrary", objects, strings); 68 if (result != null) { 69 try { 70 log("Uninstalled shared library name : " + name); 71 } catch (NullPointerException e) { 72 } 74 } 75 connector.close(); 76 } catch (Exception e) { 77 if (Boolean.parseBoolean(failOnError)) { 78 throw new BuildException(e.getMessage(), e.getCause()); 79 } 80 } 81 } 82 83 public void setName(String name) { 84 this.name = name; 85 } 86 } 87 | Popular Tags |