
org.objectweb.petals.ant.task.DeployServiceAssemblyTask Maven / Gradle / Ivy
The newest version!
/**
* PETALS: PETALS Services Platform
* Copyright (C) 2005 EBM WebSourcing
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): EBM WebSourcing
* --------------------------------------------------------------------------
* $Id$
* --------------------------------------------------------------------------
*/
package org.objectweb.petals.ant.task;
import java.io.IOException;
import javax.management.MBeanServerConnection;
import org.objectweb.petals.ant.AbstractInstallerAntTask;
import org.objectweb.petals.ant.JBIJMXConnectorUtil;
/**
* Ant task : jbi-deploy-service-assembly. This task deploys a service assembly
* into the JBI environment.
*
* @author ddesjardins chamerling - eBMWebsourcing
*/
public class DeployServiceAssemblyTask extends AbstractInstallerAntTask {
/**
* Creates a new instance of {@link DeployServiceAssemblyTask}
*
*/
public DeployServiceAssemblyTask() {
super();
}
/**
* Execute the ant task
*
* @throws IOException
*/
public void doTask() throws Exception {
validateFileParameter();
MBeanServerConnection connection = connector.getMBeanServerConnection();
Object[] objects = new Object[1];
objects[0] = getFileAsUrl(file);
String[] strings = new String[1];
strings[0] = "java.lang.String";
Object result = connection.invoke(JBIJMXConnectorUtil
.getDeploymentServiceMBeanName(connection), "deploy", objects,
strings);
if (result instanceof String) {
// Extract the service assembly name
String xml = (String) result;
if (xml.indexOf("Successfully") > -1) {
String saName = xml.substring(xml.indexOf("") + 11,
xml.indexOf(" "));
try {
log("The service assembly '" + saName
+ "' has been deployed");
} catch (NullPointerException e) {
}
} else {
try {
log("Problem during SA '" + file + "' deployement :\n"
+ (String) result);
} catch (Exception e) {
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy