Java Code Examples for org.apache.axis2.deployment.DeploymentEngine#getDeployer()

The following examples show how to use org.apache.axis2.deployment.DeploymentEngine#getDeployer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataServiceCappDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Deploy data services.
 * adding the data service to the data services.
 * there can be multiple data sources as separate xml files.
 *
 * @param artifacts  list of artifacts to be deployed.
 * @param axisConfig axis configuration.
 */
private void deployDataSources(List<Artifact> artifacts, AxisConfiguration axisConfig)
        throws DeploymentException {
    for (Artifact artifact : artifacts) {
        if (DS_TYPE.equals(artifact.getType())) {
            List<CappFile> files = artifact.getFiles();
            if (files == null || files.isEmpty()) {
                throw new DeploymentException("DataServiceCappDeployer::deployDataServices --> "
                                                      + "Error No data services found in the artifact to deploy");
            }
            for (CappFile cappFile : files) {
                String fileName = cappFile.getName();
                String dataServiceConfigPath = artifact.getExtractedPath() + File.separator + fileName;

                File file = new File(dataServiceConfigPath);
                if (!file.exists()) {
                    throw new DeploymentException("DataServiceCappDeployer::deployDataServices --> "
                                                          + "Error Data service file cannot be found in artifact, "
                                                          + "file name - " + fileName);
                }
                // access the deployment engine through axis config
                DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig.getConfigurator();
                Deployer deployer = deploymentEngine.getDeployer(DS_DIR, "dbs");

                try {
                    // Call the deploy method of the deployer
                    deployer.deploy(new DeploymentFileData(new File(dataServiceConfigPath), deployer));
                    artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
                } catch (DeploymentException e) {
                    artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
                    throw new DeploymentException(
                            "DataServiceCappDeployer::deployDataServices --> "
                                    + "Error in deploying data service: " + e.getMessage(), e);
                }
            }
        }
    }
}
 
Example 2
Source File: DefaultAppDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the correct deployer for the given artifact type
 *
 * @param axisConfig   - AxisConfiguration instance
 * @param artifactType - type of the artifact
 * @return Deployer instance
 */
private Deployer getDeployer(AxisConfiguration axisConfig, String artifactType) {
    // access the deployment engine through axis config
    DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig.getConfigurator();
    Deployer deployer = null;

    // for each service type, select the correct deployer
    if (AAR_TYPE.equals(artifactType)) {
        deployer = deploymentEngine.getDeployer("axis2services", "aar");

        /* when ghost deployer is off, deployer is null since the ServiceDeployer is not
        registered as a normal deployer. Therefore the axis2service deployer is obtained as
        follows.

        Fix me properly.
        */
        if (deployer == null) {
            deployer = deploymentEngine.getServiceDeployer();
        }
    } else if (DS_TYPE.equals(artifactType)) {
        // TODO : Move data services out of carbon core
        deployer = deploymentEngine.getDeployer(DefaultAppDeployer.DS_DIR, "dbs");
    } else if (org.wso2.micro.application.deployer.AppDeployerConstants.CARBON_APP_TYPE.equals(artifactType)) {
        deployer = deploymentEngine.getDeployer(AppDeployerConstants.CARBON_APPS, "car");
    }
    return deployer;
}
 
Example 3
Source File: SynapseAppDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Get the deployer for the Class Mediators
 *
 * @param axisConfig AxisConfiguration instance
 * @return Deployer instance
 */
private Deployer getClassMediatorDeployer(AxisConfiguration axisConfig) {
    DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig.getConfigurator();
    String classMediatorPath = axisConfig.getRepository().getPath() +
                               File.separator + SynapseAppDeployerConstants.MEDIATORS_FOLDER;
    return deploymentEngine.
            getDeployer(classMediatorPath, ServiceBusConstants.CLASS_MEDIATOR_EXTENSION);
}
 
Example 4
Source File: SynapseAppDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Get the deployer for the Synapse Library
 *
 * @param axisConfig AxisConfiguration instance
 * @return Deployer instance
 */
private Deployer getSynapseLibraryDeployer(AxisConfiguration axisConfig) {
    try {
        String synapseLibraryPath = axisConfig.getRepository().getPath() +
                SynapseAppDeployerConstants.SYNAPSE_LIBS;
        DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig.getConfigurator();
        deploymentEngine.addDeployer(new LibraryArtifactDeployer(), synapseLibraryPath, ServiceBusConstants.SYNAPSE_LIBRARY_EXTENSION);

        return deploymentEngine.
                getDeployer(synapseLibraryPath, ServiceBusConstants.SYNAPSE_LIBRARY_EXTENSION);
    } catch (Exception e) {
        log.error("Error occured while getting the deployer");
        return null;
    }
}
 
Example 5
Source File: DataServiceCappDeployer.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
/**
 * Un-deploy data services.
 * removing the data service from data services.
 * there can be multiple data sources as separate xml files.
 *
 * @param artifacts  list of artifacts to be deployed.
 * @param axisConfig axis configuration.
 */
private void undeployDataSources(List<Artifact> artifacts, AxisConfiguration axisConfig)
        throws DeploymentException {
    for (Artifact artifact : artifacts) {
        if (DS_TYPE.equals(artifact.getType())) {
            List<CappFile> files = artifact.getFiles();
            if (files == null || files.isEmpty()) {
                throw new DeploymentException("DataServiceCappDeployer::unDeployDataServices --> "
                                                      + "Error No data services found in the artifact to deploy");
            }
            for (CappFile cappFile : files) {
                String fileName = cappFile.getName();
                String dataServiceConfigPath = artifact.getExtractedPath() + File.separator + fileName;

                File file = new File(dataServiceConfigPath);
                if (!file.exists()) {
                    throw new DeploymentException("DataServiceCappDeployer::unDeployDataServices --> "
                                                          + "Error Data service file cannot be found in artifact, "
                                                          + "file name - " + fileName);
                }

                // access the deployment engine through axis config
                DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig.getConfigurator();
                Deployer deployer = deploymentEngine.getDeployer(DS_DIR, "dbs");

                if (AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED.equals(
                        artifact.getDeploymentStatus())) {
                    try {
                        // Call the un-deploy method of the deployer
                        deployer.undeploy(dataServiceConfigPath);
                        artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_PENDING);
                        File artifactFile = new File(dataServiceConfigPath);
                        if (artifactFile.exists() && !artifactFile.delete()) {
                            log.warn("Couldn't delete artifact file : " + dataServiceConfigPath);
                        }
                    } catch (DeploymentException e) {
                        artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
                        throw new DeploymentException(
                                "DataServiceCappDeployer::unDeployDataServices --> "
                                        + "Error in un-deploying data service: " + e.getMessage(), e);
                    }
                }
            }
        }
    }
}
 
Example 6
Source File: AppDeployerUtils.java    From micro-integrator with Apache License 2.0 3 votes vote down vote up
/**
 * 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 deploymentEngine.getDeployer(directory, extension);
}