This documentation is for WSO2 Carbon 4.4.1. View documentation for the latest release.
Creating and Deploying Carbon Applications - Carbon 4.3.0 - WSO2 Documentation
Due to a known issue do not use JDK1.8.0_151 with WSO2 products. Use JDK 1.8.0_144 until JDK 1.8.0_162-ea is released.
||
Skip to end of metadata
Go to start of metadata

See the following topics for details:

 

C-App deployment methods

Anyone of the following methods can be used to deploy C-Apps:

  • Upload the C-App using the Management Console.

  • Directly add the artifact file to the < CARBON_HOME>/repository/deployment/server/carbonapps hot deployment directory.

C-App deployment process

The following are the steps that take place during the deployment of a C-App:

  1. Artifacts inside C-App get extracted to the temp location inside the <PRODUCT_HOME>/tmp/carbonapps/<tenant-ID>/ directory.

  2. The CappDeployer then reads the artifacts.xml file to get the list of artifacts contained in the C-App. In this process the C-App deployer builds a map containing all the required dependencies to deploy the artifacts.

  3. The C-App deployer iteratively deploys the artifacts and required dependencies. This is done by calling the CAppDeployer, which in-turn programmatically calls the relevant deployer of the artifacts based on the server role and the artifactType and thereafter it deploys the artifacts.

  4. When the C-App deployment process is completed all its artifacts relevant to the server role are up and running. However, if any issues are encountered during the deployment it rollbacks to the deployed artifact. 

Sample

The following sample code is based on the new implementation and is for webapp deployment. The deployment of the other artifacts will be done in a similar manner except for Synapse artifacts.

package org.wso2.carbon.application.deployer.webapp
 
/**
*  Check the artifact type and if it is a WAR, copy it to the WAR deployment hot folder
*/
 
List<Artifact.Dependency> artifacts = carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
 
// loop through all artifacts and deploy them iteratively
	for (Artifact.Dependency dep : artifacts) {
	Deployer deployer;
	Artifact artifact = dep.getArtifact();
	if (artifact == null) {
		continue;
	}
 
/**
* for each service type, select the correct deployer
* for this we need to provide the relevent deployment directory on carbon server and the extension of the artifact
* these details are read from the configurations for the corresponding artifact type
* since webapps may have two artifact types we should get the correct deployer
*/
	if (WAR_TYPE.equals(artifact.getType())) {
		deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, WAR_DIR, "war");
	} else if (JAX_WAR_TYPE.equals(artifact.getType())) {
		deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, JAX_WAR_DIR, "war");
	} else {
		continue;
	}
 
	// once the deployer gets called we execute the webapp deployer to deploy
	if (deployer != null) {
		String fileName = artifact.getFiles().get(0).getName();
		String artifactPath = artifact.getExtractedPath() + File.separator + fileName;  
	// extracted path is our artifact extracted temp location. These details are available is the artifact
	try {
		// deploy the artifact 
		deployer.deploy(new DeploymentFileData(new File(artifactPath), deployer)); 
		// set the deployment state 
		artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);   
	} catch (DeploymentException e) {
		artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
	throw e;
	}
}

package org.wso2.carbon.application.deployer
 
/**
* Finds the correct deployer for the given directory and extension
*
* @param axisConfig - AxisConfiguration instance
* @param directory - Directory to retrieve the deployer
* @param extension - Extension of the deployable artifact
* @return Deployer instance
*
*/
public static Deployer getArtifactDeployer(AxisConfiguration axisConfig, String directory, String extension) {
	// access the deployment engine through axis config
	DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig.getConfigurator();
	// return the corresponding deployer to the required artifact type
	return deploymentEngine.getDeployer(directory, extension); 
}
  • No labels