You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2006/03/15 12:19:57 UTC
svn commit: r386051 -
/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java
Author: gnodet
Date: Wed Mar 15 03:19:48 2006
New Revision: 386051
URL: http://svn.apache.org/viewcvs?rev=386051&view=rev
Log:
Fix NPE when no jbi descriptor is present in the archive to install
Modified:
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java?rev=386051&r1=386050&r2=386051&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java Wed Mar 15 03:19:48 2006
@@ -189,9 +189,26 @@
* @param autoStart
* @throws DeploymentException
*/
- public void updateArchive(String location, ArchiveEntry entry, boolean autoStart) throws DeploymentException{
- File tmp=AutoDeploymentService.unpackLocation(environmentContext.getTmpDir(),location);
- Descriptor root = DescriptorFactory.buildDescriptor(tmp);
+ public void updateArchive(String location, ArchiveEntry entry, boolean autoStart) throws DeploymentException {
+ File tmpDir = null;
+ try {
+ tmpDir = AutoDeploymentService.unpackLocation(environmentContext.getTmpDir(), location);
+ } catch (Exception e) {
+ throw failure("deploy", "Unable to unpack archive: " + location, e);
+ }
+ // unpackLocation returns null if no jbi descriptor is found
+ if (tmpDir == null) {
+ throw failure("deploy", "Unable to find jbi descriptor: " + location);
+ }
+ Descriptor root = null;
+ try {
+ root = DescriptorFactory.buildDescriptor(tmpDir);
+ } catch (Exception e) {
+ throw failure("deploy", "Unable to build jbi descriptor: " + location, e);
+ }
+ if (root == null) {
+ throw failure("deploy", "Unable to find jbi descriptor: " + location);
+ }
if (root != null) {
try{
container.getBroker().suspend();
@@ -200,13 +217,13 @@
entry.type = "component";
entry.name = componentName;
installationService.unloadInstaller(componentName, true);
- installationService.install(tmp, root, autoStart);
+ installationService.install(tmpDir, root, autoStart);
checkPendingSAs();
} else if (root.getSharedLibrary() != null) {
String libraryName = root.getSharedLibrary().getIdentification().getName();
entry.type = "component";
entry.name = libraryName;
- installationService.doInstallSharedLibrary(tmp, root.getSharedLibrary());
+ installationService.doInstallSharedLibrary(tmpDir, root.getSharedLibrary());
} else if (root.getServiceAssembly() != null) {
ServiceAssembly sa = root.getServiceAssembly();
String name = sa.getIdentification().getName();
@@ -216,7 +233,7 @@
if (deploymentService.isSaDeployed(name)) {
deploymentService.shutDown(name);
deploymentService.undeploy(name);
- deploymentService.deployServiceAssembly(tmp, sa);
+ deploymentService.deployServiceAssembly(tmpDir, sa);
if (autoStart) {
deploymentService.start(name);
}
@@ -237,7 +254,7 @@
}
}
if (canDeploy) {
- deploymentService.deployServiceAssembly(tmp, sa);
+ deploymentService.deployServiceAssembly(tmpDir, sa);
if (autoStart){
deploymentService.start(name);
}
@@ -246,7 +263,7 @@
entry.pending = true;
log.info("Components " + missings + " are not installed yet - adding ServiceAssembly "
+ name + " to pending list");
- pendingSAs.put(tmp, entry);
+ pendingSAs.put(tmpDir, entry);
}
}
} catch (Exception e) {
@@ -261,6 +278,24 @@
}
}
+ protected DeploymentException failure(String task, String info) {
+ return failure(task, info, null, null);
+ }
+
+ protected DeploymentException failure(String task, String info, Exception e) {
+ return failure(task, info, e, null);
+ }
+
+ protected DeploymentException failure(String task, String info, Exception e, List componentResults) {
+ ManagementSupport.Message msg = new ManagementSupport.Message();
+ msg.setTask(task);
+ msg.setResult("FAILED");
+ msg.setType("ERROR");
+ msg.setException(e);
+ msg.setMessage(info);
+ return new DeploymentException(ManagementSupport.createFrameworkMessage(msg, componentResults));
+ }
+
protected Set getComponentNames(ServiceAssembly sa) {
Set names = null;
if (sa.getServiceUnits() != null && sa.getServiceUnits().length > 0) {
@@ -470,12 +505,12 @@
+file.getName()+" ...");
try{
updateArchive(file.getAbsolutePath(), entry, true);
+ log.info("Directory: "+root.getName()+": Finished installation of archive: "
+ +file.getName());
}catch(Exception e){
log.warn("Directory: "+root.getName()+": Automatic install of "+file
+" failed",e);
}
- log.info("Directory: "+root.getName()+": Finished installation of archive: "
- +file.getName());
}
public void release(){}