org.apache.axis2.deployment.DeploymentEngine Java Examples

The following examples show how to use org.apache.axis2.deployment.DeploymentEngine. 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: LoadBalancerServiceComponent.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
/**
 * Registers the Endpoint deployer.
 *
 * @param axisConfig         AxisConfiguration to which this deployer belongs
 * @param synapseEnvironment SynapseEnvironment to which this deployer belongs
 */
private void registerDeployer(AxisConfiguration axisConfig,
                              SynapseEnvironment synapseEnvironment)
        throws TenantAwareLoadBalanceEndpointException {
    SynapseConfiguration synCfg = synapseEnvironment
            .getSynapseConfiguration();
    DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig
            .getConfigurator();
    SynapseArtifactDeploymentStore deploymentStore = synCfg
            .getArtifactDeploymentStore();

    String synapseConfigPath = ServiceBusUtils
            .getSynapseConfigAbsPath(synapseEnvironment
                    .getServerContextInformation());
    String endpointDirPath = synapseConfigPath + File.separator
            + MultiXMLConfigurationBuilder.ENDPOINTS_DIR;

    for (Endpoint ep : synCfg.getDefinedEndpoints().values()) {
        if (ep.getFileName() != null) {
            deploymentStore.addRestoredArtifact(endpointDirPath
                    + File.separator + ep.getFileName());
        }
    }
    deploymentEngine.addDeployer(new EndpointDeployer(), endpointDirPath,
            ServiceBusConstants.ARTIFACT_EXTENSION);
}
 
Example #2
Source File: UtilServer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public static ServiceContext createAdressedEnabledClientSide(
        AxisService service) throws AxisFault {
    File file = getAddressingMARFile();
    TestCase.assertTrue(file.exists());
    ConfigurationContext configContext = ConfigurationContextFactory
            .createConfigurationContextFromFileSystem(
                    "target/test-resources/integrationRepo", null);
    AxisModule axisModule = DeploymentEngine.buildModule(file,
                                                         configContext.getAxisConfiguration());

    AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
    axisConfiguration.addModule(axisModule);
    axisConfiguration.addService(service);
    ServiceGroupContext serviceGroupContext =
            configContext.createServiceGroupContext((AxisServiceGroup) service.getParent());
    return serviceGroupContext.getServiceContext(service);
}
 
Example #3
Source File: UtilServer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public static ServiceContext createAdressedEnabledClientSide(
        AxisService service, String clientHome) throws AxisFault {
    File file = getAddressingMARFile();
    TestCase.assertTrue(file.exists());

    ConfigurationContext configContext = ConfigurationContextFactory
            .createConfigurationContextFromFileSystem(clientHome, null);
    AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();

    AxisModule axisModule = DeploymentEngine.buildModule(file,axisConfiguration);
    axisConfiguration.addModule(axisModule);

    axisConfiguration.addService(service);
    ServiceGroupContext serviceGroupContext =
            configContext.createServiceGroupContext((AxisServiceGroup) service.getParent());
    return serviceGroupContext.getServiceContext(service);
}
 
Example #4
Source File: LoadBalancerServiceComponent.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
/**
 * Un-registers the Endpoint deployer.
 *
 * @param axisConfig         AxisConfiguration to which this deployer belongs
 * @param synapseEnvironment SynapseEnvironment to which this deployer belongs
 */
private void unregisterDeployer(AxisConfiguration axisConfig,
                                SynapseEnvironment synapseEnvironment)
        throws TenantAwareLoadBalanceEndpointException {
    if (axisConfig != null) {
        DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig
                .getConfigurator();
        String synapseConfigPath = ServiceBusUtils
                .getSynapseConfigAbsPath(synapseEnvironment
                        .getServerContextInformation());
        String endpointDirPath = synapseConfigPath + File.separator
                + MultiXMLConfigurationBuilder.ENDPOINTS_DIR;
        deploymentEngine.removeDeployer(endpointDirPath,
                ServiceBusConstants.ARTIFACT_EXTENSION);
    }
}
 
Example #5
Source File: AppDeployerServiceComponent.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize and add the Data Service Deployer to the Deployment Engine.
 */
private void addDBDeployer(DeploymentEngine deploymentEngine) {
    String artifactRepoPath = configCtx.getAxisConfiguration().getRepository().getPath();

    // Create data services deployer
    DBDeployer dbDeployer = new DBDeployer();
    dbDeployer.setDirectory(artifactRepoPath + DeploymentConstants.DSS_DIR_NAME);
    dbDeployer.setExtension(DeploymentConstants.DSS_TYPE_EXTENSION);

    // Register deployer in DeploymentEngine
    deploymentEngine.addDeployer(dbDeployer, DeploymentConstants.DSS_DIR_NAME, DeploymentConstants.DSS_TYPE_DBS);

    if (log.isDebugEnabled()) {
        log.debug("Successfully registered Data Service Deployer");
    }
}
 
Example #6
Source File: AppDeployerServiceComponent.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize and add the CappDeployer to the Deployment Engine.
 */
private void addCAppDeployer(DeploymentEngine deploymentEngine) {
    String artifactRepoPath = configCtx.getAxisConfiguration().getRepository().getPath();

    // Initialize CApp deployer here
    CappDeployer cappDeployer = new CappDeployer();
    cappDeployer.setDirectory(artifactRepoPath + DeploymentConstants.CAPP_DIR_NAME);
    cappDeployer.init(configCtx);

    // Register application deployment handlers
    cappDeployer.registerDeploymentHandler(new FileRegistryResourceDeployer(
            synapseEnvironmentService.getSynapseEnvironment().getSynapseConfiguration().getRegistry()));
    cappDeployer.registerDeploymentHandler(new DataSourceCappDeployer());
    cappDeployer.registerDeploymentHandler(new DefaultAppDeployer());
    cappDeployer.registerDeploymentHandler(new SynapseAppDeployer());

    //Add the deployer to deployment engine. This should be done after registering the deployment handlers.
    deploymentEngine.addDeployer(cappDeployer, artifactRepoPath + DeploymentConstants.CAPP_DIR_NAME,
                                 DeploymentConstants.CAPP_TYPE_EXTENSION);
    if (log.isDebugEnabled()) {
        log.debug("Successfully registered CappDeployer");
    }
}
 
Example #7
Source File: CarbonSynapseController.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Override
public void init(ServerConfigurationInformation serverConfigurationInformation,
                 ServerContextInformation serverContextInformation) {
    
    Object context = serverContextInformation.getServerContext();
    if (context instanceof ConfigurationContext) {
        AxisConfiguration axisCfg = ((ConfigurationContext) context).getAxisConfiguration();
        synchronized (axisCfg) {
            DeploymentEngine deploymentEngine = (DeploymentEngine) axisCfg.getConfigurator();
            // File carbonHome = new File(System.getProperty(ServerConstants.CARBON_HOME));
            // subjected to change
            String carbonRepoPath = axisCfg.getRepository().getPath();
            String mediatorsPath = carbonRepoPath + File.separator + "mediators";
            String extensionsPath = carbonRepoPath + File.separator + "extensions";
            ExtensionDeployer deployer = new ExtensionDeployer();
            deploymentEngine.addDeployer(deployer, mediatorsPath, "xar");
            deploymentEngine.addDeployer(deployer, extensionsPath, "xar");
            deploymentEngine.addDeployer(deployer, mediatorsPath, "jar");
            deploymentEngine.addDeployer(deployer, extensionsPath, "jar");

            // Register deployer for class mediators
            String classMediatorsPath = carbonRepoPath + File.separator + "class-mediators";
            deploymentEngine.addDeployer(new ClassMediatorDeployer(),
                                         classMediatorsPath,
                                         ServiceBusConstants.CLASS_MEDIATOR_EXTENSION);
        }
        this.currentConfigurationName = ((ConfigurationContext) context).
                getAxisConfiguration().getParameterValue(
                ServiceBusConstants.SYNAPSE_CURRENT_CONFIGURATION).toString();

        this.synapseXMLLocation = serverConfigurationInformation.getSynapseXMLLocation();
    }

    super.init(serverConfigurationInformation, serverContextInformation);
}
 
Example #8
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 #9
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 #10
Source File: AppDeployerServiceComponent.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Function to initialize deployers.
 */
private void initializeDeployers() {
    DeploymentEngine deploymentEngine = (DeploymentEngine) configCtx.getAxisConfiguration().getConfigurator();

    // Register data services deployer in DeploymentEngine
    addDBDeployer(deploymentEngine);

    // Register CappDeployer in DeploymentEngine (required for CApp hot deployment)
    addCAppDeployer(deploymentEngine);

}
 
Example #11
Source File: SampleAxis2Server.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public void deployService(Object service) throws IOException {
    String artifactName = service + ".aar";
    File file = copyResourceToFileSystem(artifactName, artifactName);
    AxisServiceGroup serviceGroup = DeploymentEngine.loadServiceGroup(file, cfgCtx);
    cfgCtx.getAxisConfiguration().addServiceGroup(serviceGroup);

}
 
Example #12
Source File: SampleAxis2Server.java    From product-ei with Apache License 2.0 5 votes vote down vote up
public void deployService(Object service) throws IOException {
    String artifactName = service + ".aar";
    File file = copyResourceToFileSystem(artifactName, artifactName);
    AxisServiceGroup serviceGroup = DeploymentEngine.loadServiceGroup(file, cfgCtx);
    cfgCtx.getAxisConfiguration().addServiceGroup(serviceGroup);

}
 
Example #13
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 #14
Source File: StartupAdminServiceComponent.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Un-registers the Task Deployer.
 *
 * @param axisConfig         AxisConfiguration to which this deployer belongs
 * @param synapseEnvironment SynapseEnvironment to which this deployer belongs
 */
private void unregistryDeployer(AxisConfiguration axisConfig, SynapseEnvironment synapseEnvironment) {

    if (axisConfig != null && synapseEnvironment != null) {
        DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig.getConfigurator();
        String synapseConfigPath = ServiceBusUtils
                .getSynapseConfigAbsPath(synapseEnvironment.getServerContextInformation());
        String proxyDirPath = synapseConfigPath + File.separator + MultiXMLConfigurationBuilder.TASKS_DIR;
        deploymentEngine.removeDeployer(proxyDirPath, ServiceBusConstants.ARTIFACT_EXTENSION);
    }
}
 
Example #15
Source File: StartupAdminServiceComponent.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void registerDeployer(AxisConfiguration axisConfig, SynapseEnvironment synEnv) {

        DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig.getConfigurator();
        SynapseArtifactDeploymentStore deploymentStore = synEnv.getSynapseConfiguration().getArtifactDeploymentStore();
        String synapseConfigPath = ServiceBusUtils.getSynapseConfigAbsPath(synEnv.getServerContextInformation());
        String taskDirDirPath = synapseConfigPath + File.separator + MultiXMLConfigurationBuilder.TASKS_DIR;
        for (Startup stp : synEnv.getSynapseConfiguration().getStartups()) {
            if (stp.getFileName() != null) {
                deploymentStore.addRestoredArtifact(taskDirDirPath + File.separator + stp.getFileName());
            }
        }
        synchronized (axisConfig) {
            deploymentEngine.addDeployer(new TaskDeployer(), taskDirDirPath, ServiceBusConstants.ARTIFACT_EXTENSION);
        }
    }
 
Example #16
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 #17
Source File: UtilServer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public static ConfigurationContext createClientConfigurationContext() throws AxisFault {
    File file = getAddressingMARFile();
    TestCase.assertTrue(file.exists());

    ConfigurationContext configContext =
            ConfigurationContextFactory .createConfigurationContextFromFileSystem(
                    "target/test-resources/integrationRepo",
                    "target/test-resources/integrationRepo/conf/axis2.xml");
    AxisModule axisModule = DeploymentEngine.buildModule(file,
                                                         configContext.getAxisConfiguration());
    configContext.getAxisConfiguration().addModule(axisModule);
    return configContext;
}
 
Example #18
Source File: Axis2ServerManager.java    From product-ei with Apache License 2.0 4 votes vote down vote up
public void deployService(Object service) throws IOException {
    String artifactName = service + ".aar";
    File file = copyResourceToFileSystem(artifactName, artifactName);
    AxisServiceGroup serviceGroup = DeploymentEngine.loadServiceGroup(file, cfgCtx);
    cfgCtx.getAxisConfiguration().addServiceGroup(serviceGroup);
}
 
Example #19
Source File: ServerManagement.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
private boolean isDeploymentSchedulerRunning(ConfigurationContext configurationContext) {
    DeploymentEngine deploymentEngine =
            (DeploymentEngine) configurationContext.getAxisConfiguration().getConfigurator();
    return deploymentEngine.isDeploymentTaskRunning();
}
 
Example #20
Source File: SynapseAppDeployer.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
/**
 * Register synapse deployers to the deployment engine.
 *
 * @param axisConfig   - axisConfiguration to which this deployer belongs
 * @param artifactType - type of the artifact
 * @param deployer     - related deployer
 */
private void registerSynapseDeployer(AxisConfiguration axisConfig, String artifactType, Deployer deployer) {

    DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig.getConfigurator();
    String artifactDirName = getArtifactDirName(artifactType);

    if (artifactDirName != null) {
        SynapseArtifactDeploymentStore deploymentStore = getSynapseConfiguration(axisConfig).getArtifactDeploymentStore();
        SynapseConfiguration synCfg = getSynapseConfiguration(axisConfig);
        String artifactDir = getArtifactDirPath(axisConfig, artifactDirName);

        switch (artifactType) {
            case SynapseAppDeployerConstants.SEQUENCE_TYPE:
                for (SequenceMediator seq : synCfg.getDefinedSequences().values()) {
                    if (seq.getFileName() != null) {
                        deploymentStore.addRestoredArtifact(artifactDir + File.separator + seq.getFileName());
                    }
                }
                break;
            case SynapseAppDeployerConstants.ENDPOINT_TYPE:
                for (Endpoint ep : synCfg.getDefinedEndpoints().values()) {
                    if (ep.getFileName() != null) {
                        deploymentStore.addRestoredArtifact(artifactDir + File.separator + ep.getFileName());
                    }
                }
                break;
            case SynapseAppDeployerConstants.PROXY_SERVICE_TYPE:
                for (ProxyService proxyService : synCfg.getProxyServices()) {
                    if (proxyService.getFileName() != null) {
                        deploymentStore.addRestoredArtifact(artifactDir + File.separator + proxyService.getFileName());
                    }
                }
                break;
            case SynapseAppDeployerConstants.LOCAL_ENTRY_TYPE:
                for (Entry entry : synCfg.getDefinedEntries().values()) {
                    if (entry.getFileName() != null) {
                        deploymentStore.addRestoredArtifact(artifactDir + File.separator + entry.getFileName());
                    }
                }
                break;
            case SynapseAppDeployerConstants.TASK_TYPE:
                for (Startup stp : synCfg.getStartups()) {
                    if (stp.getFileName() != null) {
                        deploymentStore.addRestoredArtifact(artifactDir + File.separator + stp.getFileName());
                    }
                }
                break;
            case SynapseAppDeployerConstants.MESSAGE_STORE_TYPE:
                for (MessageStore messageStore : synCfg.getMessageStores().values()) {
                    if (messageStore.getFileName() != null) {
                        deploymentStore.addRestoredArtifact(artifactDir + File.separator + messageStore.getFileName());
                    }
                }
                break;
            case SynapseAppDeployerConstants.MESSAGE_PROCESSOR_TYPE:
                for (MessageProcessor processor : synCfg.getMessageProcessors().values()) {
                    if (processor.getFileName() != null) {
                        deploymentStore.addRestoredArtifact(artifactDir + File.separator + processor.getFileName());
                    }
                }
                break;
            case SynapseAppDeployerConstants.API_TYPE:
                for (API api : synCfg.getAPIs()) {
                    if (api.getFileName() != null) {
                        deploymentStore.addRestoredArtifact(artifactDir + File.separator + api.getFileName());
                    }
                }
                break;
            case SynapseAppDeployerConstants.TEMPLATE_TYPE:
                for (TemplateMediator seqTempl : synCfg.getSequenceTemplates().values()) {
                    if (seqTempl.getFileName() != null) {
                        deploymentStore.addRestoredArtifact(artifactDir + File.separator + seqTempl.getFileName());
                    }
                }
                for (Template epTempl : synCfg.getEndpointTemplates().values()) {
                    if (epTempl.getFileName() != null) {
                        deploymentStore.addRestoredArtifact(artifactDir + File.separator + epTempl.getFileName());
                    }
                }
                break;
            case SynapseAppDeployerConstants.INBOUND_ENDPOINT_TYPE:
                for (InboundEndpoint inboundEndpoint : synCfg.getInboundEndpoints()) {
                    if (inboundEndpoint.getFileName() != null) {
                        deploymentStore.addRestoredArtifact(artifactDir + File.separator + inboundEndpoint.getFileName());
                    }
                }
                break;
            default:
                // do nothing

        }
        deploymentEngine.addDeployer(deployer, artifactDir, ServiceBusConstants.ARTIFACT_EXTENSION);
    }
}
 
Example #21
Source File: ConfigurationServiceProcessor.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public ConfigurationServiceProcessor(AxisConfiguration axisConfig, BundleContext bundleContext){
    this.bundleContext = bundleContext;
    this.axisConfig = axisConfig;
    this.deploymentEngine = (DeploymentEngine) this.axisConfig.getConfigurator();
}
 
Example #22
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 #23
Source File: Axis2ServerManager.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public void deployService(Object service) throws IOException {
    String artifactName = service + ".aar";
    File file = copyResourceToFileSystem(artifactName, artifactName);
    AxisServiceGroup serviceGroup = DeploymentEngine.loadServiceGroup(file, cfgCtx);
    cfgCtx.getAxisConfiguration().addServiceGroup(serviceGroup);
}
 
Example #24
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);
}