1 22 package org.objectweb.petals.jbi.management.deployment.deploy; 23 24 import java.io.File ; 25 import java.net.URI ; 26 import java.util.HashMap ; 27 28 import javax.jbi.management.LifeCycleMBean; 29 30 import org.objectweb.petals.jbi.management.deployment.DeploymentContextConstants; 31 import org.objectweb.petals.jbi.management.deployment.DeploymentUtils; 32 import org.objectweb.petals.jbi.management.systemstate.SystemState; 33 import org.objectweb.petals.processor.Task; 34 import org.objectweb.petals.repository.RepositoryService; 35 import org.objectweb.petals.tools.jbicommon.descriptor.JBIDescriptor; 36 import org.objectweb.petals.util.LoggingUtil; 37 38 44 public class SAStateHolderCreationTask implements Task { 45 46 49 protected SystemState recoverySrv; 50 51 54 protected RepositoryService repositorySrv; 55 56 59 protected LoggingUtil log; 60 61 public SAStateHolderCreationTask(SystemState recoverySrv, 62 RepositoryService repositorySrv, LoggingUtil log) { 63 super(); 64 this.recoverySrv = recoverySrv; 65 this.repositorySrv = repositorySrv; 66 this.log = log; 67 } 68 69 public void execute(HashMap context) throws Exception { 70 JBIDescriptor descriptor = (JBIDescriptor) context 71 .get(DeploymentContextConstants.SA_DESCRIPTOR); 72 73 URI saArchiveURI = (URI ) context 74 .get(DeploymentContextConstants.ARCHIVE_URI); 75 76 String saName = DeploymentUtils.getServiceAssemblyName(descriptor); 77 78 File file = DeploymentUtils.getArchiveFile(saArchiveURI); 79 File installedArchive = DeploymentUtils.getInstalledArchive(file); 80 81 recoverySrv.createServiceAssemblyStateHolder(saName, repositorySrv 82 .getServiceAssemblyInstallRoot(saName).toURL().toString(), 83 installedArchive.toURL().toString(), LifeCycleMBean.SHUTDOWN); 84 85 } 86 87 public void undo(HashMap context) { 88 JBIDescriptor descriptor = (JBIDescriptor) context 89 .get(DeploymentContextConstants.SA_DESCRIPTOR); 90 91 try { 92 recoverySrv.deleteServiceAssemblyStateHolder(DeploymentUtils 93 .getServiceAssemblyName(descriptor)); 94 } catch (Exception e) { 95 String msg = "Failed to revert a SAStateHolderCreationTask"; 96 log.error(msg, e); 97 } 98 99 } 100 101 } 102 | Popular Tags |