1 22 package org.objectweb.petals.jbi.management.deployment.deploy; 23 24 import java.net.URI ; 25 import java.util.HashMap ; 26 import java.util.List ; 27 import java.util.Map ; 28 29 import org.objectweb.petals.jbi.management.deployment.DeploymentContextConstants; 30 import org.objectweb.petals.jbi.management.deployment.DeploymentUtils; 31 import org.objectweb.petals.jbi.management.service.PackageHandler; 32 import org.objectweb.petals.processor.Task; 33 import org.objectweb.petals.repository.RepositoryService; 34 import org.objectweb.petals.tools.jbicommon.descriptor.JBIDescriptor; 35 import org.objectweb.petals.tools.jbicommon.descriptor.ServiceUnit; 36 37 43 public class SAAndSUInstallRootRetrievalTask implements Task { 44 45 48 protected RepositoryService repositorySrv; 49 50 53 protected PackageHandler packageHandler; 54 55 public SAAndSUInstallRootRetrievalTask(RepositoryService repositorySrv, 56 PackageHandler packageHandler) { 57 super(); 58 this.repositorySrv = repositorySrv; 59 this.packageHandler = packageHandler; 60 } 61 62 @SuppressWarnings ("unchecked") 63 public void execute(HashMap context) throws Exception { 64 JBIDescriptor descriptor = (JBIDescriptor) context 65 .get(DeploymentContextConstants.SA_DESCRIPTOR); 66 67 URI installationRoot = repositorySrv.getServiceAssemblyInstallRoot( 68 DeploymentUtils.getServiceAssemblyName(descriptor)).toURI(); 69 Map <String , URI > suInstallRoots = retrieveSUInstallRoots( 70 installationRoot, descriptor); 71 72 75 context.put(DeploymentContextConstants.SA_INSTALL_ROOT, 76 installationRoot); 77 context 78 .put(DeploymentContextConstants.SU_INSTALL_ROOTS, 79 suInstallRoots); 80 81 } 82 83 92 protected Map <String , URI > retrieveSUInstallRoots(URI installationRoot, 93 JBIDescriptor descriptor) { 94 Map <String , URI > suInstallRoots = new HashMap <String , URI >(); 95 List <ServiceUnit> sus = descriptor.getServiceAssembly() 96 .getServiceUnits(); 97 for (ServiceUnit unit : sus) { 98 String suName = unit.getIdentification().getName(); 99 suInstallRoots.put(suName, packageHandler.processAndGetPackageURI( 100 "file://" + installationRoot.getPath() + suName, true)); 101 } 102 return suInstallRoots; 103 } 104 105 public void undo(HashMap context) { 106 108 } 109 110 } 111 | Popular Tags |