}
// 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();
if (root.getComponent() != null) {
Component comp = root.getComponent();
String componentName = comp.getIdentification().getName();
entry.type = "component";
entry.name = componentName;
try {
if (container.getRegistry().getComponent(componentName) != null) {
installationService.loadInstaller(componentName);
installationService.unloadInstaller(componentName, true);
}
// See if shared libraries are installed
entry.dependencies = getSharedLibraryNames(comp);
if (log.isDebugEnabled()) {
log.debug("Component dependencies: " + entry.dependencies);
}
String missings = null;
boolean canInstall = true;
for (Iterator it = entry.dependencies.iterator(); it.hasNext();) {
String libraryName = (String) it.next();
if (container.getRegistry().getSharedLibrary(libraryName) == null) {
canInstall = false;
if (missings != null) {
missings += ", " + libraryName;
} else {
missings = libraryName;
}
}
}
if (canInstall) {
installationService.install(tmpDir, null, root, autoStart);
checkPendingSAs();
} else {
entry.pending = true;
log.warn("Shared libraries " + missings + " are not installed yet: the component" + componentName +
" installation is suspended and will be resumed once the listed shared libraries are installed");
pendingComponents.put(tmpDir, entry);
}
} catch (Exception e) {
String errStr = "Failed to update Component: " + componentName;
log.error(errStr, e);
throw new DeploymentException(errStr, e);
}
} else if (root.getSharedLibrary() != null) {
String libraryName = root.getSharedLibrary().getIdentification().getName();
entry.type = "library";
entry.name = libraryName;
try {
if (container.getRegistry().getSharedLibrary(libraryName) != null) {
container.getRegistry().unregisterSharedLibrary(libraryName);
environmentContext.removeSharedLibraryDirectory(libraryName);
}
installationService.doInstallSharedLibrary(tmpDir, root.getSharedLibrary());
checkPendingComponents();
} catch (Exception e) {
String errStr = "Failed to update SharedLibrary: " + libraryName;
log.error(errStr, e);
throw new DeploymentException(errStr, e);
}
} else if (root.getServiceAssembly() != null) {
ServiceAssembly sa = root.getServiceAssembly();
String name = sa.getIdentification().getName();
entry.type = "assembly";
entry.name = name;
try {
if (deploymentService.isSaDeployed(name)) {