Package org.wso2.carbon.application.deployer

Examples of org.wso2.carbon.application.deployer.CarbonApplication


    public String[] listAllApplications() throws Exception {
        String tenantId = AppDeployerUtils.getTenantIdString(getAxisConfig());
        ArrayList<CarbonApplication> appList
                = AppManagementServiceComponent.getAppManager().getCarbonApps(tenantId);
        List<String> existingApps = new ArrayList<String>();
        CarbonApplication tempApp;
        for (CarbonApplication anAppList : appList) {
            tempApp = anAppList;
            if (tempApp.isDeploymentCompleted()) {
                existingApps.add(tempApp.getAppName());
            }
        }
        return existingApps.toArray(new String[existingApps.size()]);
    }
View Full Code Here


            handleException("Application name can't be null");
            return;
        }

        // CarbonApplication instance to delete
        CarbonApplication currentApp = null;

        // Iterate all applications for this tenant and find the application to delete
        String tenantId = AppDeployerUtils.getTenantIdString(getAxisConfig());
        ArrayList<CarbonApplication> appList =
                AppManagementServiceComponent.getAppManager().getCarbonApps(tenantId);
        for (CarbonApplication carbonApp : appList) {
            if (appName.equals(carbonApp.getAppName())) {
                currentApp = carbonApp;
            }
        }

        // If requested application not found, throw an exception
        if (currentApp == null) {
            handleException("No Carbon Application found of the name : " + appName);
            return;
        }

        // Remove the app artifact file from repository, cApp hot undeployer will do the rest
        String appFilePath = currentApp.getAppFilePath();
        File file = new File(appFilePath);
        if (file.exists() && !file.delete()) {
            log.error("Artifact file couldn't be deleted for Application : "
                    + currentApp.getAppName());
        }
    }
View Full Code Here

            handleException("Application name can't be null");
            return null;
        }

        ApplicationMetadata appData = new ApplicationMetadata();
        CarbonApplication currentApplication = null;

        // Check whether there is an application in the system from the given name
        String tenantId = AppDeployerUtils.getTenantIdString(getAxisConfig());
        ArrayList<CarbonApplication> appList
                = AppManagementServiceComponent.getAppManager().getCarbonApps(tenantId);
        for (CarbonApplication application : appList) {
            if (appName.equals(application.getAppName())) {
                appData.setAppName(appName);
                currentApplication = application;
                break;
            }
        }

        // If the app not found, throw an exception
        if (currentApplication == null) {
            handleException("No Carbon Application found of the name : " + appName);
            return null;
        }

        // list of service groups which are owned by this app
        List<ServiceGroupMetadata> serviceGroups = new ArrayList<ServiceGroupMetadata>();
        // list of registry artifacts
        List<RegistryMetadata> regArtifacts = new ArrayList<RegistryMetadata>();

        List<String> regFilterList = new ArrayList<String>();
        List<String> regHandlerList = new ArrayList<String>();

        List<Artifact.Dependency> dependencies = currentApplication.getAppConfig().
                getApplicationArtifact().getDependencies();

        for (Artifact.Dependency dependency : dependencies) {
            Artifact artifact = dependency.getArtifact();
            String type = artifact.getType();
            String instanceName = artifact.getRuntimeObjectName();

            if (DefaultAppDeployer.AAR_TYPE.equals(type) ||
                    DefaultAppDeployer.JAXWS_TYPE.equals(type) ||
                    DefaultAppDeployer.DS_TYPE.equals(type)) {

                AxisServiceGroup sg;
                if (instanceName == null) {
                    sg = findServiceGroupForArtifact(artifact);
                    if (sg != null) {
                        // set the instance name in Artifact so that we don't have to find it
                        // next time
                        artifact.setRuntimeObjectName(sg.getServiceGroupName());
                    }
                } else {
                    sg = getAxisConfig().getServiceGroup(instanceName);
                }

                if (sg == null) {
                    continue;
                }
                // set the service group name
                ServiceGroupMetadata sgMetadata = new ServiceGroupMetadata();
                sgMetadata.setSgName(sg.getServiceGroupName());
                sgMetadata.setSgType(type);

                // find services in the service group
                List<String> services = new ArrayList<String>();
                for (Iterator serviceIter = sg.getServices(); serviceIter.hasNext();) {
                    AxisService axisService = (AxisService) serviceIter.next();
                    // ignore if this is a client side serivce
                    if (axisService.isClientSide()) {
                        break;
                    }
                    services.add(axisService.getName());
                }
                sgMetadata.setServices(services.toArray(new String[services.size()]));
                serviceGroups.add(sgMetadata);

            } else if (RegistryResourceDeployer.REGISTRY_RESOURCE_TYPE.equals(type)) {
                // Create a Registry config metadata instance
                RegistryConfig regConf = artifact.getRegConfig();
                if (regConf == null) {
                    regConf = readRegConfig(currentApplication.getAppName(), artifact.getName());
                }
                if (regConf == null) {
                    continue;
                }
                artifact.setRegConfig(regConf);
View Full Code Here

        String tenantId = AppDeployerUtils.getTenantIdString(getAxisConfig());

        // Check whether there is an application in the system from the given name
        ArrayList<CarbonApplication> appList
                = WarAppServiceComponent.getAppManager().getCarbonApps(tenantId);
        CarbonApplication currentApplication = null;
        for (CarbonApplication application : appList) {
            if (appName.equals(application.getAppName())) {
                currentApplication = application;
                break;
            }
        }

        // If the app not found, throw an exception
        if (currentApplication == null) {
            String msg = "No Carbon Application found of the name : " + appName;
            log.error(msg);
            throw new Exception(msg);
        }

        // get all dependent artifacts of the cApp
        List<Artifact.Dependency> deps = currentApplication.getAppConfig().
                getApplicationArtifact().getDependencies();
        // package list to return
        List<WarCappMetadata> webappList = new ArrayList<WarCappMetadata>();

        for (Artifact.Dependency dep : deps) {
View Full Code Here

     * @param axisConfig - AxisConfiguration instance
     * @return - true if exits
     */
    private boolean appExists(String newAppName, AxisConfiguration axisConfig) {
        String tenantId = AppDeployerUtils.getTenantIdString(axisConfig);
        CarbonApplication appToRemove = null;
        for (CarbonApplication carbonApp : getCarbonApps(tenantId)) {
            if (newAppName.equals(carbonApp.getAppName())) {
                if (carbonApp.isDeploymentCompleted()) {
                    return true;
                } else {
View Full Code Here

        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);
            }
        } else {
            log.error("Some dependencies in cApp : " + appName + " were not satisfied. Check " +
                    "whether all dependent artifacts are included in cApp file : " + archPath);
            return;
        }

        currentApp.setDeploymentCompleted(true);
        this.addCarbonApp(tenantId, currentApp);
        log.info("Successfully Deployed Carbon Application : " + currentApp.getAppName()
                + AppDeployerUtils.getTenantIdLogString(AppDeployerUtils.getTenantId(axisConfig)));
    }
View Full Code Here

            String[] appPaths = allApps.getChildren();
            ApplicationManager appManager = ApplicationManager.getInstance();
            String tenantId = AppDeployerUtils.getTenantIdString(axisConfig);

            for (String currentAppPath : appPaths) {
                CarbonApplication carbonApp = new CarbonApplication();

                //get application collection
                Collection currentAppCollection = (Collection) configRegistry.get(currentAppPath);
                carbonApp.setAppName(currentAppCollection.getProperty(AppDeployerConstants.NAME));
                carbonApp.setAppFilePath(currentAppCollection.
                        getProperty(AppDeployerConstants.APP_FILE_PATH));

                //read the artifacts.xml and construct the ApplicationConfiguration
                String artifactsXmlPath = currentAppPath + AppDeployerConstants.APP_ARTIFACTS_XML;
                if (configRegistry.resourceExists(artifactsXmlPath)) {
                    Resource artifactXmlResource = configRegistry.get(artifactsXmlPath);
                    InputStream artifactsXmlStream = artifactXmlResource.getContentStream();
                    if (artifactsXmlStream != null) {
                        ApplicationConfiguration appConfig =
                                new ApplicationConfiguration(this, artifactsXmlStream);
                        carbonApp.setAppConfig(appConfig);
                    }
                }

                String dependencyPath = currentAppPath + AppDeployerConstants.APP_DEPENDENCIES;
                // list to keep all artifacts
                List<Artifact> allArtifacts = new ArrayList<Artifact>();
                if (configRegistry.resourceExists(dependencyPath)) {
                    Collection dependencies = (Collection) configRegistry.get(dependencyPath);

                    for (String depPath : dependencies.getChildren()) {
                        Resource artifactResource = configRegistry.get(depPath +
                                AppDeployerConstants.ARTIFACT_XML);
                        InputStream xmlStream = artifactResource.getContentStream();
                        Artifact artifact = null;
                        if (xmlStream != null) {
                            artifact = appManager.buildAppArtifact(carbonApp, xmlStream);
                        }
                        if (artifact != null) {
                            Collection artCollection = (Collection) configRegistry.get(depPath);
                            artifact.setRuntimeObjectName(artCollection
                                    .getProperty(AppDeployerConstants.RUNTIME_OBJECT_NAME));
                            allArtifacts.add(artifact);
                        }
                    }
                }
                Artifact appArtifact = carbonApp.getAppConfig().getApplicationArtifact();
                appManager.buildDependencyTree(appArtifact, allArtifacts);
                appManager.addCarbonApp(tenantId, carbonApp);
            }
        } catch (RegistryException e) {
            String msg = "Unable to load Applications. Registry transactions failed.";
View Full Code Here

     * @return The end line number, or -1 if could not be determined
     */
    public int getEndLineNumber() {
      int ret=-1;
     
      ActivityInterface parent=getParent();
     
      if (parent != null) {
        int index=parent.getSubActivities().indexOf(this);
       
        if (index != -1) {
          if (index < (parent.getSubActivities().size()-1)) {
            ActivityInterface other=parent.getSubActivities().get(index+1);
           
            ret = other.getStartLineNumber()-1;
          } else {
            ret = parent.getEndLineNumber();
          }
        }
      }
View Full Code Here

     *
     * @param lineNumber The line number
     * @return The activity, or null if not found
     */
    public ActivityInterface getActivityAtLineNumber(int lineNumber) {
      ActivityInterface ret=null;
     
      int endline=getEndLineNumber();
     
      if (getStartLineNumber() <= lineNumber && (endline == -1 || endline >= lineNumber)) {
       
View Full Code Here

            int width = 0;
            int height = 0;
            dimensions = new SVGDimension(width, height);

            SVGDimension subActivityDim = null;
            ActivityInterface activity = null;
            Iterator<org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface> itr = getSubActivities().iterator();
            while (itr.hasNext()) {
                activity = itr.next();
                subActivityDim = activity.getDimensions();
                if (subActivityDim.getWidth() > width) {
                    width += subActivityDim.getWidth();
                }
                height += subActivityDim.getHeight();
            }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.application.deployer.CarbonApplication

Copyright © 2018 www.massapicom. 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.