Examples of CarbonAppPersistenceManager


Examples of org.wso2.carbon.application.deployer.persistence.CarbonAppPersistenceManager

    }

    private RegistryConfig readRegConfig(String parentAppName, String artifactName) {
        RegistryConfig regConfig = null;
        try {
            CarbonAppPersistenceManager capm = new CarbonAppPersistenceManager(getAxisConfig());
            regConfig = capm.loadRegistryConfig(AppDeployerConstants.APPLICATIONS + parentAppName +
                                    AppDeployerConstants.APP_DEPENDENCIES + artifactName);
        } catch (Exception e) {
            log.error("Error while trying to load registry config for C-App : " +
                    parentAppName + " artifact : " + artifactName, e);
        }
View Full Code Here

Examples of org.wso2.carbon.application.deployer.persistence.CarbonAppPersistenceManager

        if (initialHandlers != handlerCount) {
            pendingCarbonApps.add(new PendingApplication(archPath, axisConfig));
            return;
        }

        CarbonAppPersistenceManager capm = getPersistenceManager(axisConfig);
        String tenantId = AppDeployerUtils.getTenantIdString(axisConfig);
        archPath = AppDeployerUtils.formatPath(archPath);
        String fileName = archPath.substring(archPath.lastIndexOf('/') + 1);
        //check whether this app already exists..
        CarbonApplication existingApp = null;
        for (CarbonApplication carbonApp : getCarbonApps(tenantId)) {
            if (archPath.equals(carbonApp.getAppFilePath())) {
                existingApp = carbonApp;
                break;
            }
        }

        //If the app already exists, check the last updated time and redeploy if needed.
        //Return if not updated..
        if (existingApp != null) {
            File file = new File(archPath);
            if (file.exists()) {
                String hashValue = CarbonUtils.getMD5(CarbonUtils.getBytesFromFile(file));
                String hashValueFromRegistry = capm.getHashValue(existingApp.getAppName());
                if (hashValueFromRegistry != null && hashValueFromRegistry.equals(hashValue)) {
                    existingApp.setDeploymentCompleted(true);
                    return;
                } else {
                    // we are going to do an update for the application
                    log.warn("Carbon Application : " + fileName + " has been updated. Removing" +
                            " the existing application and redeploying...");
                    // undeploy the existing one before proceeding
                    undeployCarbonApp(existingApp, axisConfig);
                }
            }
        }

        log.info("Deploying Carbon Application : " + fileName + "...");

        CarbonApplication currentApp = new CarbonApplication();
        currentApp.setAppFilePath(archPath);
        String extractedPath = AppDeployerUtils.extractCarbonApp(archPath);

        // Build the app configuration by providing the artifacts.xml path
        ApplicationConfiguration appConfig = new ApplicationConfiguration(capm, extractedPath +
                ApplicationConfiguration.ARTIFACTS_XML);

        // If we don't have features (artifacts) for this server, ignore
        if (appConfig.getApplicationArtifact().getDependencies().size() == 0) {
            log.warn("No artifacts found to be deployed in this server. " +
                    "Ignoring Carbon Application : " + fileName);
            return;
        }

        currentApp.setExtractedPath(extractedPath);
        currentApp.setAppConfig(appConfig);

        String appName = appConfig.getAppName();
        if (appName == null) {
            log.warn("No application name found in Carbon Application : " + fileName + ". Using " +
                    "the file name as the application name");
            appName = fileName.substring(0, fileName.lastIndexOf("."));
        }

        if (appExists(appName, axisConfig)) {
            String msg = "Carbon Application : " + appName + " already exists. Two applications " +
                    "can't have the same Id. Deployment aborted.";
            log.error(msg);
            throw new Exception(msg);
        }

        currentApp.setAppName(appName);

//        lock.lock();
//        try {
//            installArtifactFeatures(currentApp);
//        } catch (Exception e) {
//            handleException("Failed to installed features for cApp : " + appName, e);
//        } finally {
//            lock.unlock();
//        }

        // deploy sub artifacts of this cApp
        this.searchArtifacts(currentApp.getExtractedPath(), currentApp);

        // If all dependencies are resolved, we deploy the entire app
        if (isArtifactReadyToDeploy(currentApp.getAppConfig().getApplicationArtifact())) {
            // persist the completed cApp into registry..
            capm.persistCarbonApp(currentApp);

            // send the CarbonApplication instance through the handler chain
            for (AppDeploymentHandler handler : appDeploymentHandlers) {
                handler.deployArtifacts(currentApp, axisConfig);
            }
View Full Code Here

Examples of org.wso2.carbon.application.deployer.persistence.CarbonAppPersistenceManager

        // Remove the app from tenant cApp list
        removeCarbonApp(AppDeployerUtils.getTenantIdString(axisConfig), carbonApp);

        // Remove the app from registry
        try {
            CarbonAppPersistenceManager capm = getPersistenceManager(axisConfig);
            capm.deleteApplication(carbonApp.getAppName());
        } catch (Exception e) {
            log.error("Can't delete the Application from Registry : " + carbonApp.getAppName());
        }

        // Uninstall features
View Full Code Here

Examples of org.wso2.carbon.application.deployer.persistence.CarbonAppPersistenceManager

     * @param axisConfig - AxisConfiguration of the current tenant
     * @return - CarbonAppPersistenceManager for the current tenant
     */
    public CarbonAppPersistenceManager getPersistenceManager(AxisConfiguration axisConfig) {
        String tenantId = AppDeployerUtils.getTenantIdString(axisConfig);
        CarbonAppPersistenceManager capm = tenantPMMap.get(tenantId);
        try {
            if (capm == null) {
                capm = new CarbonAppPersistenceManager(axisConfig);
                tenantPMMap.put(tenantId, capm);
            }
        } catch (Exception e) {
            log.error("Error while initializing CAppPersistenceManger for tenant : " + tenantId, e);
        }
View Full Code Here

Examples of org.wso2.carbon.application.deployer.persistence.CarbonAppPersistenceManager

        for (Artifact.Dependency dep : deps) {
            if (dep.getArtifact() != null) {
                artifacts.add(dep.getArtifact());
            }
        }
        CarbonAppPersistenceManager capm = ApplicationManager.getInstance()
                .getPersistenceManager(axisConfig);
        // deploying registry resources in all dependent artifacts
        deployRegistryArtifacts(capm, artifacts, carbonApp.getAppName());
    }
View Full Code Here

Examples of org.wso2.carbon.application.deployer.persistence.CarbonAppPersistenceManager

        }
        this.axisConfig = configurationContext.getAxisConfiguration();
        // load the existing Carbon apps from tenant registry space
        try {
            // create a persistence manager for particular tenant
            CarbonAppPersistenceManager capm = ApplicationManager.getInstance()
                    .getPersistenceManager(axisConfig);
            // load persisted cApps for this tenant
            capm.loadApps();
        } catch (Exception e) {
            log.error("Error while trying to load persisted cApps from registry", e);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.application.deployer.persistence.CarbonAppPersistenceManager

        for (Artifact.Dependency dep : deps) {
            if (dep.getArtifact() != null) {
                artifacts.add(dep.getArtifact());
            }
        }
        CarbonAppPersistenceManager capm = ApplicationManager.getInstance()
                .getPersistenceManager(axisConfig);
        // undeploying registry resources in all dependent artifacts
        undeployRegistryArtifacts(capm, artifacts, carbonApp.getAppName());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.