1 25 package org.objectweb.petals.tools.ant; 26 27 import java.net.URL ; 28 29 import javax.management.MBeanServerConnection ; 30 import javax.management.remote.JMXConnector ; 31 32 import org.apache.tools.ant.BuildException; 33 import org.objectweb.petals.tools.ant.managers.InstallerAntTaskAbstract; 34 import org.objectweb.petals.tools.ant.util.JBIJMXConnectorUtil; 35 36 41 public class DeployServiceAssemblyTask extends InstallerAntTaskAbstract { 42 43 public DeployServiceAssemblyTask() { 44 super(); 45 } 46 47 52 public void execute() throws BuildException { 53 if (file == null) { 54 throw new BuildException("Required attribute : file"); 55 } 56 try { 57 new URL (file); 59 JMXConnector connector = JBIJMXConnectorUtil.getConnection(host, 60 port, username, password); 61 MBeanServerConnection connection = connector 62 .getMBeanServerConnection(); 63 Object [] objects = new Object [1]; 64 objects[0] = file; 65 String [] strings = new String [1]; 66 strings[0] = "java.lang.String"; 67 Object result = connection.invoke(JBIJMXConnectorUtil 68 .getDeploymentServiceMBeanName(connection), "deploy", 69 objects, strings); 70 if (result instanceof String ) { 71 String xml = (String ) result; 73 if (xml.indexOf("Successfully") > -1) { 74 String saName = ""; 75 saName = xml.substring(xml.indexOf("<loc-param>") + 11, xml 76 .indexOf("</loc-param>")); 77 try { 78 log("Deployed service assembly name : " + saName); 79 } catch (NullPointerException e) { 80 } 83 } else { 84 try { 85 log("Problem during deployement :\n" + (String ) result); 86 } catch (NullPointerException e) { 87 } 90 } 91 } 92 connector.close(); 93 } catch (Exception e) { 94 if (Boolean.parseBoolean(failOnError)) { 95 throw new BuildException(e.getMessage(), e.getCause()); 96 } 97 } 98 } 99 } 100 | Popular Tags |