Search in sources :

Example 11 with Deployer

use of org.apache.axis2.deployment.Deployer in project carbon-business-process by wso2.

the class BPELBindingContextImpl method removeBPELProcessProxyAndAxisService.

private void removeBPELProcessProxyAndAxisService(String processDeployer, QName serviceName, String portName) {
    if (log.isDebugEnabled()) {
        log.debug("Removing service " + serviceName.toString() + " port " + portName);
    }
    BPELProcessProxy processProxy = (BPELProcessProxy) services.remove(processDeployer, serviceName, portName);
    if (processProxy != null) {
        try {
            String axisServiceName = processProxy.getAxisService().getName();
            AxisConfiguration axisConfig = processProxy.getAxisService().getAxisConfiguration();
            // /////////////////////////////////////////////////////////////////////////////////////////////////////
            // There is a issue in this code due to tenant unloading and loading. When we unload a tenant we don't
            // undeploy the process. So BPELBindingContextImpl#deactivateMyRoleEndpoint will not get invoked and
            // BPELProcessProxy instance will be there in the BPELBindingContextImpl#services map. So at the
            // time we load the tenant again, axisService returned from axisConfig will be null even though we
            // have a BPELProcessProxy instance in service map. This is because teant unloading logic cleans the
            // axis configuration. So if the axisService is null, we ignore the other steps after this.
            // /////////////////////////////////////////////////////////////////////////////////////////////////////
            AxisService axisService = axisConfig.getService(axisServiceName);
            if (axisService != null) {
                // first, de-allocate its schemas
                axisService.releaseSchemaList();
                // then, de-allocate its parameters
                // the service's wsdl object model is stored as one of its parameters!
                // can't stress strongly enough how important it is to clean this up.
                // ArrayList<Parameter> parameters = (ArrayList<Parameter>) axisService.getParameters();
                // for (Parameter parameter : parameters) {
                // if (!parameter.getName().equals(CarbonConstants.PRESERVE_SERVICE_HISTORY_PARAM) &&
                // !BPELProcessStoreImpl.isUndeploying) {
                // axisService.removeParameter(parameter);
                // }
                // }
                // 
                // if (RegistryBasedProcessStoreImpl.isUndeploying) {
                // BPSServerImpl.getAxisConfig().getServiceGroup(axisServiceName).removeParameter(
                // new Parameter(CarbonConstants.PRESERVE_SERVICE_HISTORY_PARAM, "true"));
                // }
                // 
                // if (RegistryBasedProcessStoreImpl.isUpdatingBPELPackage) {
                // axisService.addParameter(new Parameter(CarbonConstants.PRESERVE_SERVICE_HISTORY_PARAM, "true"));
                // axisService.getAxisServiceGroup().addParameter(new Parameter(CarbonConstants
                // .PRESERVE_SERVICE_HISTORY_PARAM, "true"));
                // }
                // now, stop the service
                axisConfig.stopService(axisServiceName);
                // calling removeServiceGroup() is workaround to AXIS2-4314.
                // It happens that Axis2 creates one group per service you add with AxisConfiguration.addService().
                // See this.createService()
                // Once this issue is fixed (hopully in Axis2-1.5), we can use removeService() again.
                axisConfig.removeServiceGroup(axisServiceName);
            // This must not done. This will cause axis configuration to cleanup deployment schedular
            // and it'll throw exception when it tries to reschedule deployer after undeplying.
            // _server._axisConfig.cleanup();
            }
        } catch (AxisFault axisFault) {
            log.error("Couldn't remove service " + serviceName);
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Couldn't find service " + serviceName + " port " + portName + " to remove.");
        }
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) AxisService(org.apache.axis2.description.AxisService)

Example 12 with Deployer

use of org.apache.axis2.deployment.Deployer in project carbon-business-process by wso2.

the class BPMNDeployer method undeploy.

/**
 * Undeployment operation for Bpmn Deployer
 *
 * @param bpmnArchivePath        archivePatch
 * @throws DeploymentException   Deployment failure will result in this exception
 */
public void undeploy(String bpmnArchivePath) throws DeploymentException {
    if (isWorkerNode()) {
        return;
    }
    if (System.getProperty(BPMNConstants.RESOLVE_DEPLOYMENT_SYS_PROP) != null && Boolean.parseBoolean(System.getProperty(BPMNConstants.RESOLVE_DEPLOYMENT_SYS_PROP)) || System.getProperty(BPMNConstants.RESOLVE_DEPLOYMENT_SYS_PROP) == null) {
        File bpmnArchiveFile = new File(bpmnArchivePath);
        if (bpmnArchiveFile.exists()) {
            if (log.isTraceEnabled()) {
                log.trace("BPMN package: " + bpmnArchivePath + " exists in the deployment folder. " + "Therefore, this can be an update of the package and the undeployment will be aborted.");
            }
            return;
        }
        Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        log.info("Undeploying BPMN archive " + bpmnArchivePath + " for tenant: " + tenantId);
        String deploymentName = FilenameUtils.getBaseName(bpmnArchivePath);
        try {
            tenantRepository.undeploy(deploymentName, true);
        } catch (BPSFault be) {
            String errorMsg = "Error un deploying BPMN Package " + deploymentName;
            throw new DeploymentException(errorMsg, be);
        }
    }
}
Also used : BPSFault(org.wso2.carbon.bpmn.core.BPSFault) DeploymentException(org.apache.axis2.deployment.DeploymentException) File(java.io.File)

Aggregations

DeploymentException (org.apache.axis2.deployment.DeploymentException)9 File (java.io.File)6 Deployer (org.apache.axis2.deployment.Deployer)6 Artifact (org.wso2.carbon.application.deployer.config.Artifact)6 CappFile (org.wso2.carbon.application.deployer.config.CappFile)6 DeploymentFileData (org.apache.axis2.deployment.repository.util.DeploymentFileData)3 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)2 Operation (javax.wsdl.Operation)1 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)1 HTTPBinding (javax.wsdl.extensions.http.HTTPBinding)1 AxisFault (org.apache.axis2.AxisFault)1 MessageContext (org.apache.axis2.context.MessageContext)1 DeploymentEngine (org.apache.axis2.deployment.DeploymentEngine)1 AxisService (org.apache.axis2.description.AxisService)1 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)1 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)1 MutableEndpoint (org.apache.ode.bpel.epr.MutableEndpoint)1 LibraryArtifactDeployer (org.apache.synapse.deployers.LibraryArtifactDeployer)1 BPELServer (org.wso2.carbon.bpel.core.ode.integration.BPELServer)1 BPSFault (org.wso2.carbon.bpmn.core.BPSFault)1