Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright (c) 2005-2012 EBM WebSourcing, 2012-2016 Linagora
*
* This program/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 (at your
* option) any later version.
*
* This program/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 program/library; If not, see http://www.gnu.org/licenses/
* for the GNU Lesser General Public License version 2.1.
*/
package org.ow2.petals.microkernel.jbi.management.deployment;
import static org.ow2.petals.jbi.descriptor.AbstractJBIDescriptorBuilder.JBI_DESCRIPTOR_RESOURCE;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import javax.jbi.management.DeploymentException;
import org.apache.commons.io.IOUtils;
import org.objectweb.fractal.fraclet.annotations.Component;
import org.objectweb.fractal.fraclet.annotations.Interface;
import org.objectweb.fractal.fraclet.annotations.Lifecycle;
import org.objectweb.fractal.fraclet.annotations.Requires;
import org.objectweb.fractal.fraclet.types.Step;
import org.ow2.petals.jbi.descriptor.original.generated.ServiceUnit;
import org.ow2.petals.microkernel.api.configuration.ConfigurationService;
import org.ow2.petals.microkernel.api.container.ContainerService;
import org.ow2.petals.microkernel.api.container.Installer;
import org.ow2.petals.microkernel.api.container.ServiceAssemblyLifeCycle;
import org.ow2.petals.microkernel.api.container.ServiceUnitLifeCycle;
import org.ow2.petals.microkernel.api.jbi.management.Context;
import org.ow2.petals.microkernel.api.jbi.management.DeploymentService;
import org.ow2.petals.microkernel.api.jbi.management.TaskProcessor;
import org.ow2.petals.microkernel.api.jbi.management.XMLResult;
import org.ow2.petals.microkernel.api.jbi.management.XMLResult.MessageType;
import org.ow2.petals.microkernel.api.jbi.management.XMLResult.TaskResult;
import org.ow2.petals.microkernel.api.jbi.messaging.endpoint.EndpointDirectoryService;
import org.ow2.petals.microkernel.api.system.SystemStateService;
import org.ow2.petals.microkernel.api.system.repository.RepositoryService;
import org.ow2.petals.microkernel.extension.InstallationExtensionsManager;
import org.ow2.petals.microkernel.jbi.management.task.deployment.DeploymentTaskFactory;
import org.ow2.petals.microkernel.util.ParameterCheckHelper;
import org.ow2.petals.systemstate.generated.ServiceAssembly;
import com.ebmwebsourcing.easycommons.lang.ExceptionHelper;
import com.ebmwebsourcing.easycommons.log.LoggingUtil;
/**
* JBI deployment service implementation.
*
* @author Olivier Fabre - EBM WebSourcing
* @author ddesjardins - EBM WebSourcing
* @author wjoseph - EBM WebSourcing
*/
@Component(provides = @Interface(name = "service", signature = DeploymentService.class))
public class DeploymentServiceImpl implements DeploymentService {
/**
* Container :: Container Service
*/
@Requires(name = "container")
private ContainerService containerService;
/**
* Configuration Service
*/
@Requires(name = "configuration")
private ConfigurationService configurationService;
private DeploymentTaskFactory deploymentTaskFactory;
/**
* JBI messaging :: Endpoint Directory service
*/
@Requires(name = "endpointDirectory")
private EndpointDirectoryService endpointDirectory;
@Requires(name = "installationExtensionManager")
private InstallationExtensionsManager installationExtensionManager;
/**
* logger wrapper
*/
private final LoggingUtil log = new LoggingUtil(Logger.getLogger(DeploymentService.COMPONENT_LOGGER_NAME));
/**
* Platform :: Repository Service
*/
@Requires(name = "repository")
private RepositoryService repositoryService;
/**
* Platform :: SystemState Service
*/
@Requires(name = "systemstate")
private SystemStateService systemStateService;
/**
* Default constructor.
*/
public DeploymentServiceImpl() {
super();
}
@Override
public boolean canDeployToComponent(String componentName) {
this.log.call();
ParameterCheckHelper
.isNullOrEmptyParameterWithLog(componentName, "componentName", this.log);
boolean result = false;
Installer installer = this.containerService.getInstallerByName(componentName);
if (installer.isInstalled() && (installer.getComponent().getServiceUnitManager() != null)) {
result = true;
}
return result;
}
/**
* TODO deploy verify that all Service units are present in the package and that all targeted components are
* installed in the JBI System
*
* TODO check duplicate service units as describe in spec section 6.6
*
* TODO deploy add the result of deploy method call on su to the management message "result"
*
* TODO deploy verify deployment success before registration
*/
@Override
public String deploy(String serviceAssemblyZipUrl) throws Exception {
this.log.start();
ParameterCheckHelper.isNullParameterWithLog(serviceAssemblyZipUrl, "serviceAssemblyZipUrl",
this.log);
String result = null;
try {
// if it's invalid, then it will fail but it shouldn't be invalid!
URL archiveURL = new URL(serviceAssemblyZipUrl);
// Create deployment execution context
Context deploymentContext = this.createDeploymentContext(archiveURL);
// Create deployment processor and fill it with tasks
TaskProcessor processor = this.createDeploymentProcessor(deploymentContext, archiveURL);
// Launch the process
final Throwable processResult = processor.process();
if (processResult != null) {
throw new DeploymentException("The deployment of the Service Assembly '"
+ serviceAssemblyZipUrl + "' failed.", processResult);
}
// get the result string
result = deploymentContext.getXmlResult().getString();
if (result.contains("FAILED")) {
this.log.warning("Service Assembly '" + deploymentContext.getEntityName()
+ "' deployed with some SU deployment in failure");
} else {
this.log.info("Service Assembly '" + deploymentContext.getEntityName()
+ "' deployed");
}
} catch (Exception e) {
this.log.error("Unable to deploy the service assembly at '" + serviceAssemblyZipUrl
+ "'", e);
// Redefine the exception to prevent exotic exception cause type,
// and then unserialization problem for external class-loaders (JMX
// client)
throw new Exception(ExceptionHelper.getStackTrace(e));
}
this.log.end();
return result;
}
@Override
public boolean forceUndeploy(String serviceAssemblyName) {
this.log.start();
boolean removed = false;
final ServiceAssemblyLifeCycle saLifeCycle = this.containerService
.getServiceAssemblyByName(serviceAssemblyName);
if (saLifeCycle == null) {
this.log.warning("Cannot retrieve Service Assembly with the specified name : "
+ serviceAssemblyName);
this.log.end();
return false;
}
try {
if (saLifeCycle.isStartedState()) {
this.stop(serviceAssemblyName, true);
}
} catch (Exception e) {
this.log.warning("Cannot stop Service Assembly: " + serviceAssemblyName, e);
}
try {
if (saLifeCycle.isStoppedState()) {
this.shutDown(serviceAssemblyName, true);
}
} catch (Exception e) {
this.log.warning("Cannot shutdown Service Assembly: " + serviceAssemblyName, e);
}
try {
this.undeploy(serviceAssemblyName);
removed = true;
} catch (Exception e) {
this.log.warning("Cannot undeploy Service Assembly: " + serviceAssemblyName, e);
}
this.log.end();
return removed;
}
@Override
public String[] getComponentsForDeployedServiceAssembly(String serviceAssemblyName)
throws Exception {
this.log.start();
ParameterCheckHelper.isNullOrEmptyParameterWithLog(serviceAssemblyName,
"serviceAssemblyName", this.log);
List result = new ArrayList();
final ServiceAssemblyLifeCycle saLifeCycle = this.containerService
.getServiceAssemblyByName(serviceAssemblyName);
if (saLifeCycle != null) {
List sus = saLifeCycle.getServiceAssembly().getServiceUnit();
for (ServiceUnit unit : sus) {
result.add(unit.getTarget().getComponentName());
}
} else {
throw new Exception("Cannot retrieve service assembly with the specified name: "
+ serviceAssemblyName);
}
this.log.end();
return result.toArray(new String[result.size()]);
}
@Override
public String[] getDeployedServiceAssemblies() throws Exception {
this.log.call();
final Set sas = this.containerService.getServiceAssemblies().keySet();
return sas.toArray(new String[sas.size()]);
}
@Override
public String[] getDeployedServiceAssembliesForComponent(String componentName) throws Exception {
this.log.start();
ParameterCheckHelper
.isNullOrEmptyParameterWithLog(componentName, "componentName", this.log);
final List result = new ArrayList<>();
final Map saLifeCycles = this.containerService
.getServiceAssemblies();
for (final ServiceAssemblyLifeCycle salc : saLifeCycles.values()) {
final List sus = salc.getServiceAssembly().getServiceUnit();
for (final ServiceUnit unit : sus) {
if (componentName.equals(unit.getTarget().getComponentName())) {
result.add(salc.getServiceAssembly().getIdentification().getName());
// let's add it only once!
break;
}
}
}
this.log.end();
return result.toArray(new String[result.size()]);
}
@Override
public String[] getDeployedServiceUnitList(String componentName) throws Exception {
this.log.start();
ParameterCheckHelper
.isNullOrEmptyParameterWithLog(componentName, "componentName", this.log);
final List result = new ArrayList<>();
for (final ServiceUnitLifeCycle suLC : this.containerService
.getServiceUnitsLifeCyclesByComponent(componentName)) {
result.add(suLC.getSuName());
}
this.log.end();
return result.toArray(new String[result.size()]);
}
@Override
public String getServiceAssemblyDescriptor(final String serviceAssemblyName) throws Exception {
this.log.start();
ParameterCheckHelper.isNullOrEmptyParameterWithLog(serviceAssemblyName,
"serviceAssemblyName", this.log);
final String result;
final File serviceAssemblyInstallFile = this.repositoryService
.getServiceAssemblyInstallDirectory(serviceAssemblyName);
if (serviceAssemblyInstallFile != null) {
File jbiFile = new File(serviceAssemblyInstallFile, JBI_DESCRIPTOR_RESOURCE);
result = IOUtils.toString(new FileInputStream(jbiFile));
} else {
result = "Service Assembly doesn't exist :" + serviceAssemblyName;
}
this.log.end();
return result;
}
@Override
public String[] getServiceUnitForServiceAssembly(String saName) throws Exception {
this.log.start();
ParameterCheckHelper.isNullOrEmptyParameterWithLog(saName, "saName", this.log);
final List result = new ArrayList();
final ServiceAssemblyLifeCycle saLifeCycle = this.containerService
.getServiceAssemblyByName(saName);
if (saLifeCycle != null) {
final List serviceUnits = saLifeCycle.getServiceAssembly().getServiceUnit();
for (ServiceUnit serviceUnit : serviceUnits) {
result.add(serviceUnit.getIdentification().getName());
}
} else {
String msg = "Cannot retrieve service assembly with the name '" + saName + '"';
this.log.error(msg);
throw new Exception(msg);
}
this.log.end();
return result.toArray(new String[result.size()]);
}
@Override
public String getState(String serviceAssemblyName) throws Exception {
this.log.start();
ParameterCheckHelper.isNullOrEmptyParameterWithLog(serviceAssemblyName,
"serviceAssemblyName", this.log);
final ServiceAssemblyLifeCycle saLifeCycle = this.containerService
.getServiceAssemblyByName(serviceAssemblyName);
if (saLifeCycle == null) {
throw new Exception("Cannot retrieve service assembly with the specified name : " + serviceAssemblyName);
}
if (!(saLifeCycle.isShutdownState() || saLifeCycle.isStartedState() || saLifeCycle.isStoppedState())) {
throw new Exception("Service Assembly state isn't correctly defined: "+saLifeCycle.getCurrentState());
}
this.log.end();
return saLifeCycle.getCurrentState();
}
@Override
public boolean isDeployedServiceUnit(String componentName, String serviceUnitName) {
this.log.start();
ParameterCheckHelper.isNullOrEmptyParameterWithLog(serviceUnitName, "serviceUnitName",
this.log);
ParameterCheckHelper
.isNullOrEmptyParameterWithLog(componentName, "componentName", this.log);
try {
for (final String suName : getDeployedServiceUnitList(componentName)) {
if (suName.equals(serviceUnitName)) {
return true;
}
}
} catch (final Exception e) {
// note: this should never happen...
this.log.error("Error while querying deployed SUs for component " + componentName, e);
} finally {
this.log.end();
}
return false;
}
@Override
public void shutdown() throws Exception {
this.log.call();
// Undeploy all service assemblies
this.undeployAllServiceAssemblies(true);
}
@Override
public String shutDown(String serviceAssemblyName) throws Exception {
return this.shutDown(serviceAssemblyName, false);
}
@Override
public String[] shutdownAllServiceAssemblies() {
this.log.start();
List shutdownSAs = new ArrayList();
// Try to shutdown all service assemblies. If a SA can't be shutdown,
// it's skipped and the shutting down process ins't aborted.
List serviceAssemblies = this.systemStateService
.getServiceAssemblyStateHolders();
Collections.reverse(serviceAssemblies);
for (ServiceAssembly serviceAssembly : serviceAssemblies) {
try {
this.shutDown(serviceAssembly.getName());
shutdownSAs.add(serviceAssembly.getName());
} catch (Exception e) {
// continue
}
}
this.log.end();
return shutdownSAs.toArray(new String[shutdownSAs.size()]);
}
@Override
public String start(String serviceAssemblyName) throws Exception {
this.log.start();
ParameterCheckHelper.isNullOrEmptyParameterWithLog(serviceAssemblyName,
"serviceAssemblyName", this.log);
final XMLResult xmlResult = new XMLResult("start");
try {
final ServiceAssemblyLifeCycle saLifeCycle = this.containerService
.getServiceAssemblyByName(serviceAssemblyName);
if (saLifeCycle == null) {
throw new DeploymentException("The service assembly '" + serviceAssemblyName
+ "' is not deployed");
}
final List results = saLifeCycle.start();
xmlResult.addFrameworkTaskResult(TaskResult.SUCCESS, MessageType.INFO,
"Successfully started service assembly : {1}",
new String[] { serviceAssemblyName }, null);
for (final String r : results) {
xmlResult.addComponentTaskResult(r);
}
} catch (Exception e) {
this.log.error("Unable to start the service assembly '" + serviceAssemblyName + "'", e);
// Redefine the exception to prevent exotic exception cause type,
// and then unserialization problem for external class-loaders (JMX
// client)
throw new Exception(ExceptionHelper.getStackTrace(e));
}
this.log.info("Service Assembly '" + serviceAssemblyName + "' started");
this.log.end();
return xmlResult.getString();
}
@Override
public String[] startAllServiceAssemblies() {
this.log.start();
List startedSAs = new ArrayList();
// Try to start all service assemblies, if a SA can't be started, it's
// skipped and the starting process ins't aborted.
for (ServiceAssembly serviceAssembly : this.systemStateService
.getServiceAssemblyStateHolders()) {
try {
this.start(serviceAssembly.getName());
startedSAs.add(serviceAssembly.getName());
} catch (Exception e) {
// continue
}
}
this.log.end();
return startedSAs.toArray(new String[startedSAs.size()]);
}
@Override
public String stop(String serviceAssemblyName) throws Exception {
return this.stop(serviceAssemblyName, false);
}
@Override
public String[] stopAllServiceAssemblies() {
this.log.start();
List stoppedSAs = new ArrayList();
// Try to stop all service assemblies. If a SA can't be stopped, it's
// skipped and the stopping process ins't aborted.
List serviceAssemblies = this.systemStateService
.getServiceAssemblyStateHolders();
Collections.reverse(serviceAssemblies);
for (ServiceAssembly serviceAssembly : serviceAssemblies) {
try {
this.stop(serviceAssembly.getName());
stoppedSAs.add(serviceAssembly.getName());
} catch (Exception e) {
// continue
}
}
this.log.end();
return stoppedSAs.toArray(new String[stoppedSAs.size()]);
}
@Override
public String undeploy(String serviceAssemblyName) throws Exception {
this.log.start();
ParameterCheckHelper.isNullParameterWithLog(serviceAssemblyName, "serviceAssemblyZipUrl",
this.log);
String output = null;
try {
// Check if the SA exists
ServiceAssembly serviceAssemblyStateHolder = this.systemStateService
.getServiceAssemblyStateHolder(serviceAssemblyName);
if (serviceAssemblyStateHolder == null) {
throw new DeploymentException("The service assembly '" + serviceAssemblyName
+ "' is not deployed");
} else if (!SHUTDOWN.equals(serviceAssemblyStateHolder.getLifecycleState())) {
throw new DeploymentException("The service assembly '" + serviceAssemblyName
+ "' is not at the state SHUTDOWN");
}
// Create undeployment execution context
Context undeploymentContext = this.createUndeploymentContext(serviceAssemblyName);
// Create undeployment processor and fill with tasks
TaskProcessor processor = this.createUndeploymentProcessor(undeploymentContext);
// Launch the process
final Throwable processResult = processor.process();
if (processResult != null) {
throw new DeploymentException("The undeployment of the Service Assembly '"
+ serviceAssemblyName + "' failed.", processResult);
}
// Create the result string
output = undeploymentContext.getXmlResult().getString();
} catch (Exception e) {
this.log.error("Unable to undeploy the service assembly '" + serviceAssemblyName + "'",
e);
// Redefine the exception to prevent exotic exception cause type,
// and then unserialization problem for external class-loaders (JMX
// client)
throw new Exception(ExceptionHelper.getStackTrace(e));
}
this.log.info("Service Assembly '" + serviceAssemblyName + "' undeployed");
this.log.end();
return output;
}
@Override
public String[] undeployAllServiceAssemblies(boolean force) {
this.log.start();
List undeployedSAs = new ArrayList();
/*
* Try to undeploy all service assemblies. If a SA can't be undeployed,
* it's skipped and the undeploying process ins't aborted.
*/
List serviceAssemblies = this.systemStateService
.getServiceAssemblyStateHolders();
Collections.reverse(serviceAssemblies);
for (ServiceAssembly serviceAssembly : serviceAssemblies) {
if (force) {
if (this.forceUndeploy(serviceAssembly.getName())) {
undeployedSAs.add(serviceAssembly.getName());
}
} else if (SHUTDOWN.equals(serviceAssembly.getLifecycleState())) {
try {
this.undeploy(serviceAssembly.getName());
undeployedSAs.add(serviceAssembly.getName());
} catch (Exception e) {
// continue
}
}
}
this.log.end();
return undeployedSAs.toArray(new String[undeployedSAs.size()]);
}
@Lifecycle(step = Step.START)
public void start() {
this.log.start();
this.deploymentTaskFactory = new DeploymentTaskFactory(this.endpointDirectory, this, this.systemStateService,
this.repositoryService, this.log, this.containerService,
this.configurationService.getContainerConfiguration(),
this.installationExtensionManager.getExtensions());
this.log.end();
}
@Lifecycle(step = Step.STOP)
public void stop() {
this.log.call();
}
/**
* Create the deployment context
*
* @param archiveURI
* URI of the Service Assembly installation package file; must be
* non-null, non-empty, and a legal URI.
* @return the Deployment Context HashMap
*/
private Context createDeploymentContext(URL archiveURL) {
this.log.call();
Context deploymentContext = new Context();
deploymentContext.setArchiveUrl(archiveURL);
return deploymentContext;
}
/**
* Create the deployment processor and add all required task for the
* complete deployment of a service assembly
*
* @param deploymentContext
* the deployment context
* @param archiveURI
* the sl archive URI
* @return the filled deployment processor
*/
private TaskProcessor createDeploymentProcessor(Context deploymentContext, URL archiveURL) {
this.log.call();
TaskProcessor processor = new TaskProcessor(deploymentContext, this.log);
String scheme = archiveURL.getProtocol();
if (scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("ftp")) {
processor.addTask(this.deploymentTaskFactory.getDownloadTask());
} else if (scheme.equalsIgnoreCase("file")) {
processor.addTask(this.deploymentTaskFactory.getCopyArchiveToWorkDirTask());
} else {
throw new IllegalArgumentException("URL protocol not supported:" + scheme);
}
processor.addTask(this.deploymentTaskFactory.getExtractTask());
processor.addTask(this.deploymentTaskFactory.getSaCheckPackageTask());
processor.addTask(this.deploymentTaskFactory.getCopySAPackageToRepositoryTask());
processor.addTask(this.deploymentTaskFactory.getCreateSAStateHolderTask());
processor.addTask(this.deploymentTaskFactory.getCreateXMLDeploymentResultTask());
processor.addTask(this.deploymentTaskFactory.getExtractSUsTask());
processor.addTask(this.deploymentTaskFactory.getRegisterSALifeCycleTask());
processor.addTask(this.deploymentTaskFactory.getDeployAllSUTask());
processor.addTask(this.deploymentTaskFactory.getRegisterAllConnectionTask());
processor.addTask(this.deploymentTaskFactory.getCopyArchiveToInstalledDirTask());
return processor;
}
/**
* Create the undeployment context
*
* @param serviceAssemblyName
* the service assembly name
* @return the undeployment context
*/
private Context createUndeploymentContext(String serviceAssemblyName) throws IOException {
this.log.call();
Context undeploymentContext = new Context();
undeploymentContext.setEntityName(serviceAssemblyName);
final File installFile = this.repositoryService.getServiceAssemblyInstallDirectory(serviceAssemblyName);
undeploymentContext.setArchiveFile(installFile);
return undeploymentContext;
}
/**
* Create the undeployment processor and add all required task for the
* complete undeployment of a service assembly
*
* @param undeploymentContext
* the deployment context
* @return filled undeployment processor
*/
private TaskProcessor createUndeploymentProcessor(Context undeploymentContext) {
this.log.call();
TaskProcessor processor = new TaskProcessor(undeploymentContext, this.log);
processor.addTask(this.deploymentTaskFactory.getCreateXMLUndeploymentResultTask());
processor.addTask(this.deploymentTaskFactory.getRetrieveSALifeCycleTask());
processor.addTask(this.deploymentTaskFactory.getUndeployAllSUTask());
processor.addTask(this.deploymentTaskFactory.getRemoveAllConnectionsTask());
processor.addTask(this.deploymentTaskFactory.getUnregisterSALifeCycleTask());
processor.addTask(this.deploymentTaskFactory.getRemoveSAStateHolderTask());
processor.addTask(this.deploymentTaskFactory.getRemoveSAFolderTask());
processor.addTask(this.deploymentTaskFactory.getRemoveSAArchiveTask());
return processor;
}
/**
* Shut down the given service assembly. if {@code forceState=true}, the SA
* would be in the {@code SHUTDOWN} state even errors occur in starting of
* service units, otherwise the SA get back to its previous state.
*
* @see javax.jbi.management.DeploymentServiceMBean#start(java.lang.String)
*
* @param serviceAssemblyName
* @param forcedState
* @return
* @throws Exception
*/
private String shutDown(final String serviceAssemblyName, final boolean forcedState) throws Exception {
this.log.start();
ParameterCheckHelper.isNullOrEmptyParameterWithLog(serviceAssemblyName,
"serviceAssemblyName", this.log);
final XMLResult xmlResult = new XMLResult("shutdown");
try {
final ServiceAssemblyLifeCycle saLifeCycle = this.containerService
.getServiceAssemblyByName(serviceAssemblyName);
if (saLifeCycle != null) {
saLifeCycle.shutDown();
} else {
throw new DeploymentException("The service assembly '" + serviceAssemblyName
+ "' is not deployed");
}
// TODO maybe later add SU results
xmlResult.addFrameworkTaskResult(TaskResult.SUCCESS, MessageType.INFO,
"Successfully shutdown service assembly : {1}",
new String[] { serviceAssemblyName }, null);
} catch (final Exception e) {
this.log.error("Unable to shutdown the service assembly '" + serviceAssemblyName + "'",
e);
// Redefine the exception to prevent exotic exception cause type,
// and then unserialization problem for external class-loaders (JMX
// client)
if (!forcedState) {
throw new Exception(ExceptionHelper.getStackTrace(e));
} else {
xmlResult.addFrameworkTaskResult(TaskResult.FAILED, MessageType.ERROR,
"Failed to shutdown service assembly: {1}", new String[] { serviceAssemblyName }, null,
e.getMessage(), new String[0], ExceptionHelper.getStackTrace(e), null);
}
}
this.log.info("Service Assembly '" + serviceAssemblyName + "' shut down");
this.log.end();
return xmlResult.getString();
}
private String stop(String serviceAssemblyName, boolean force) throws Exception {
this.log.start();
ParameterCheckHelper.isNullOrEmptyParameterWithLog(serviceAssemblyName,
"serviceAssemblyName", this.log);
final XMLResult xmlResult = new XMLResult("stop");
try {
final ServiceAssemblyLifeCycle saLifeCycle = this.containerService
.getServiceAssemblyByName(serviceAssemblyName);
if (saLifeCycle != null) {
saLifeCycle.stop();
} else {
throw new DeploymentException("The service assembly '" + serviceAssemblyName
+ "' is not deployed");
}
// TODO maybe later add SU results
xmlResult.addFrameworkTaskResult(TaskResult.SUCCESS, MessageType.INFO,
"Successfully stopped service assembly: {1}",
new String[] { serviceAssemblyName }, null);
} catch (final Exception e) {
this.log.error("Unable to stop the service assembly '" + serviceAssemblyName + "'", e);
// Redefine the exception to prevent exotic exception cause type,
// and then unserialization problem for external class-loaders (JMX
// client)
if (!force) {
throw new Exception(ExceptionHelper.getStackTrace(e));
} else {
xmlResult.addFrameworkTaskResult(TaskResult.FAILED, MessageType.ERROR,
"Failed to stop service assembly: {1}", new String[] { serviceAssemblyName }, null,
e.getMessage(), new String[0], ExceptionHelper.getStackTrace(e), null);
}
}
this.log.info("Service Assembly '" + serviceAssemblyName + "' stopped");
this.log.end();
return xmlResult.getString();
}
}