use of org.apache.axis2.deployment.Deployer in project carbon-business-process by wso2.
the class PartnerService method invoke.
public void invoke(final PartnerRoleMessageExchange partnerRoleMessageExchange) {
boolean isTwoWay = (partnerRoleMessageExchange.getMessageExchangePattern() == MessageExchange.MessageExchangePattern.REQUEST_RESPONSE);
try {
// Override options are passed to the axis MessageContext so we can
// retrieve them in our session out changeHandler
//
// Below logic is required only if tenant information from the thread local context is required here.
// However,
// it does not seem required, hence commenting out.
String deployer = processConfiguration.getDeployer();
if (log.isDebugEnabled()) {
String msg = "Process Name => " + processConfiguration.getProcessId() + " Deployer =>" + processConfiguration.getDeployer();
log.debug(msg);
}
PrivilegedCarbonContext.startTenantFlow();
// Assuming that deployer should not be null
String domain = BPELServerHolder.getInstance().getRealmService().getTenantManager().getDomain(Integer.parseInt(deployer));
if (domain != null) {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(domain);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(Integer.parseInt(deployer));
} else {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(Integer.parseInt(deployer));
}
final MessageContext mctx = new MessageContext();
BPELMessageContext partnerInvocationContext = BPELMessageContextFactory.createBPELMessageContext(mctx, this);
ExtensibilityElement bindingType = WSDLAwareSOAPProcessor.getBindingExtension(binding);
try {
if (bindingType instanceof HTTPBinding) {
// =========================================================
if (uep.getAddress() == null) {
uep.setAddress(endpointUrl);
}
partnerInvocationContext.setUep(uep);
partnerInvocationContext.setTwoWay(isTwoWay);
partnerInvocationContext.setService(serviceName);
partnerInvocationContext.setPort(portName);
partnerInvocationContext.setCaller(partnerRoleMessageExchange.getCaller().getLocalPart());
partnerInvocationContext.setOperationName(partnerRoleMessageExchange.getOperationName());
SOAPUtils.createSOAPRequest(partnerInvocationContext, partnerRoleMessageExchange);
String mexEndpointUrl = ((MutableEndpoint) partnerRoleMessageExchange.getEndpointReference()).getUrl();
if (!endpointUrl.equals(mexEndpointUrl)) {
uep.setAddress(mexEndpointUrl);
}
if (messageTraceLog.isDebugEnabled()) {
messageTraceLog.debug("Invoking service: MEXId: " + partnerRoleMessageExchange.getMessageExchangeId() + " :: " + serviceName + "." + partnerRoleMessageExchange.getOperationName());
if (messageTraceLog.isTraceEnabled()) {
messageTraceLog.trace("Request message: MEXId: " + partnerRoleMessageExchange.getMessageExchangeId() + " :: " + partnerInvocationContext.getInMessageContext().getEnvelope());
}
}
HTTPBindingHandler httpBindingHandler = new HTTPBindingHandler(clientConfigCtx, serviceName, portName, wsdlDefinition);
HTTPBindingHandler.HTTPBindingResponse response = httpBindingHandler.invoke(partnerRoleMessageExchange, partnerInvocationContext);
if (isTwoWay) {
MessageContext responseMessageContext = response.getReponseMessageContext();
partnerInvocationContext.setOutMessageContext(responseMessageContext);
MessageContext fltMessageContext = response.getFaultMessageContext();
if (messageTraceLog.isTraceEnabled()) {
messageTraceLog.trace("Response message: MEXId: " + partnerRoleMessageExchange.getMessageExchangeId() + " :: " + responseMessageContext.getEnvelope());
}
if (fltMessageContext != null) {
replyHTTP(partnerInvocationContext, partnerRoleMessageExchange, true);
} else {
replyHTTP(partnerInvocationContext, partnerRoleMessageExchange, response.isFault());
}
} else {
/* one-way case */
partnerRoleMessageExchange.replyOneWayOk();
}
} else {
if (uep.getAddress() == null) {
uep.setAddress(endpointUrl);
}
partnerInvocationContext.setUep(uep);
partnerInvocationContext.setTwoWay(isTwoWay);
partnerInvocationContext.setService(serviceName);
partnerInvocationContext.setPort(portName);
partnerInvocationContext.setCaller(partnerRoleMessageExchange.getCaller().getLocalPart());
partnerInvocationContext.setOperationName(partnerRoleMessageExchange.getOperationName());
SOAPUtils.createSOAPRequest(partnerInvocationContext, partnerRoleMessageExchange);
String mexEndpointUrl = ((MutableEndpoint) partnerRoleMessageExchange.getEndpointReference()).getUrl();
if (!endpointUrl.equals(mexEndpointUrl)) {
uep.setAddress(mexEndpointUrl);
}
if (messageTraceLog.isDebugEnabled()) {
messageTraceLog.debug("Invoking service: MEXId: " + partnerRoleMessageExchange.getMessageExchangeId() + " :: " + serviceName + "." + partnerRoleMessageExchange.getOperationName());
if (messageTraceLog.isTraceEnabled()) {
messageTraceLog.trace("Request message: MEXId: " + partnerRoleMessageExchange.getMessageExchangeId() + " :: " + partnerInvocationContext.getInMessageContext().getEnvelope());
}
}
AxisServiceUtils.invokeService(partnerInvocationContext, clientConfigCtx);
if (messageTraceLog.isDebugEnabled()) {
messageTraceLog.debug("Service invocation completed: MEXId: " + partnerRoleMessageExchange.getMessageExchangeId() + " :: " + serviceName + "." + partnerRoleMessageExchange.getOperationName());
}
if (isTwoWay) {
final Operation operation = partnerRoleMessageExchange.getOperation();
MessageContext response = partnerInvocationContext.getOutMessageContext();
MessageContext flt = partnerInvocationContext.getFaultMessageContext();
if (messageTraceLog.isTraceEnabled()) {
messageTraceLog.trace("Response message: MEXId: " + partnerRoleMessageExchange.getMessageExchangeId() + " :: " + response.getEnvelope());
}
if (flt != null) {
reply(partnerInvocationContext, partnerRoleMessageExchange, operation, flt, true);
} else {
reply(partnerInvocationContext, partnerRoleMessageExchange, operation, response, response.isFault());
}
} else {
/* one-way case */
partnerRoleMessageExchange.replyOneWayOk();
}
}
} finally {
// make sure the HTTP connection is released to the pool!
TransportOutDescription out = mctx.getTransportOut();
if (out != null && out.getSender() != null) {
out.getSender().cleanup(mctx);
}
}
} catch (Exception e) {
String errmsg = Messages.msgErrorSendingMessageToAxisForODEMex(partnerRoleMessageExchange.toString());
log.error(errmsg, e);
replyWithFailure(partnerRoleMessageExchange, MessageExchange.FailureType.COMMUNICATION_ERROR, errmsg);
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
}
use of org.apache.axis2.deployment.Deployer in project carbon-business-process by wso2.
the class BPELDeployer method init.
public void init(ConfigurationContext configurationContext) {
Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
log.info("Initializing BPEL Deployer for tenant " + tenantId + ".");
File bpelRepo = null;
try {
BPELDeployerServiceComponent.getTenantRegistryLoader().loadTenantRegistry(tenantId);
bpelRepo = createBPELRepository(configurationContext);
} catch (DeploymentException e) {
log.warn("BPEL repository creation failed.", e);
} catch (RegistryException e) {
log.warn("Initialization of tenant process store failed for tenant: " + tenantId + " This can cause issues in deployment of BPEL packages.", e);
}
BPELServer bpsServer = BPELDeployerServiceComponent.getBPELServer();
tenantProcessStore = bpsServer.getMultiTenantProcessStore().createProcessStoreForTenant(configurationContext);
tenantProcessStore.setBpelArchiveRepo(bpelRepo);
configurationContext.setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, bpsServer.getHttpConnectionManager());
try {
tenantProcessStore.init();
} catch (Exception re) {
log.warn("Initialization of tenant process store failed for tenant: " + tenantId + " This can cause issues in deployment of BPEL packages.", re);
}
}
use of org.apache.axis2.deployment.Deployer in project carbon-business-process by wso2.
the class BPELAppDeployer method undeployArtifacts.
/**
* Check the artifact type and if it is a BPEL, delete the file from the BPEL
* deployment hot folder
*
* @param carbonApp - CarbonApplication instance to check for BPEL artifacts
* @param axisConfig - - axisConfig of the current tenant
*/
public void undeployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) {
List<Artifact.Dependency> artifacts = carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
for (Artifact.Dependency dep : artifacts) {
Deployer deployer;
Artifact artifact = dep.getArtifact();
if (artifact == null) {
continue;
}
if (BPEL_TYPE.equals(artifact.getType())) {
deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, BPEL_DIR, "zip");
} else {
continue;
}
// loop through all dependencies
List<CappFile> files = artifact.getFiles();
if (files.size() != 1) {
log.error("A BPEL workflow must have a single file. But " + files.size() + " files found.");
continue;
}
if (deployer != null && AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED.equals(artifact.getDeploymentStatus())) {
String fileName = artifact.getFiles().get(0).getName();
String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
try {
File artifactFile = new File(artifactPath);
if (artifactFile.exists() && !artifactFile.delete()) {
log.warn("Couldn't delete App artifact file : " + artifactPath);
}
deployer.undeploy(artifactPath);
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_PENDING);
} catch (DeploymentException e) {
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
log.error("Error occured while trying to un deploy : " + artifact.getName());
}
}
}
}
use of org.apache.axis2.deployment.Deployer in project carbon-business-process by wso2.
the class BPELAppDeployer method deployArtifacts.
/**
* Check the artifact type and if it is a BPEL, copy it to the BPEL deployment hot folder
*
* @param carbonApp - CarbonApplication instance to check for BPEL artifacts
* @param axisConfig - AxisConfiguration of the current tenant
*/
public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) throws DeploymentException {
List<Artifact.Dependency> artifacts = carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
// loop through all artifacts
for (Artifact.Dependency dep : artifacts) {
Deployer deployer;
Artifact artifact = dep.getArtifact();
if (artifact == null) {
continue;
}
if (!isAccepted(artifact.getType())) {
log.warn("Can't deploy artifact : " + artifact.getName() + " of type : " + artifact.getType() + ". Required features are not installed in the system");
continue;
}
if (BPEL_TYPE.equals(artifact.getType())) {
deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, BPEL_DIR, "zip");
} else {
continue;
}
List<CappFile> files = artifact.getFiles();
if (files.size() != 1) {
log.error("BPEL workflows must have a single file to " + "be deployed. But " + files.size() + " files found.");
continue;
}
if (deployer != null) {
String fileName = artifact.getFiles().get(0).getName();
String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
try {
deployer.deploy(new DeploymentFileData(new File(artifactPath), deployer));
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
} catch (DeploymentException e) {
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
throw e;
}
}
}
}
use of org.apache.axis2.deployment.Deployer in project carbon-business-process by wso2.
the class BPMNAppDeployer method deployArtifacts.
/**
* Check the artifact type and if it is a BPMN artifact, copy it to the BPMN deployment hot folder
*
* @param carbonApp - CarbonApplication instance to check for BPMN artifacts
* @param axisConfig - AxisConfiguration of the current tenant
*/
public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) throws DeploymentException {
List<Artifact.Dependency> artifacts = carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
// loop through all dependencies
for (Artifact.Dependency dep : artifacts) {
Deployer deployer;
Artifact artifact = dep.getArtifact();
if (artifact == null) {
continue;
}
if (!isAccepted(artifact.getType())) {
log.warn("Can't deploy artifact : " + artifact.getName() + " of type : " + artifact.getType() + ". Required features are not installed in the system");
continue;
}
if (BPMN_TYPE.equals(artifact.getType())) {
deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, BPMN_DIR, "bar");
} else {
continue;
}
List<CappFile> files = artifact.getFiles();
if (files.size() != 1) {
log.error("BPMN artifacts must have a single file to " + "be deployed. But " + files.size() + " files found.");
continue;
}
if (deployer != null) {
String fileName = artifact.getFiles().get(0).getName();
String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
try {
deployer.deploy(new DeploymentFileData(new File(artifactPath), deployer));
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
File artifactFile = new File(artifactPath);
if (artifactFile.exists() && !artifactFile.delete()) {
log.warn("Couldn't delete App artifact file : " + artifactPath);
}
} catch (DeploymentException e) {
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
throw e;
}
}
}
}
Aggregations