Package com.sun.enterprise.config.serverbeans

Examples of com.sun.enterprise.config.serverbeans.Application


            NotProcessed np = null;
            if(instance instanceof Application){
                Resources resources = ((Application)instance).getResources();
                pingConnectionPool(resources);

                Application app = (Application)instance;
                List<Module> modules = app.getModule();
                if(modules != null){
                    for(Module module : modules){
                        if(module.getResources() !=null && module.getResources().getResources() != null){
                            pingConnectionPool(module.getResources());
                        }
View Full Code Here


            NotProcessed np = null;
            if(instance instanceof Application){
                Resources resources = ((Application)instance).getResources();
                pingConnectionPool(resources);

                Application app = (Application)instance;
                List<Module> modules = app.getModule();
                if(modules != null){
                    for(Module module : modules){
                        if(module.getResources() !=null && module.getResources().getResources() != null){
                            pingConnectionPool(module.getResources());
                        }
View Full Code Here

        }
    }

    private boolean isApplicationEnabled(String appId) {
        if (appId != null) {
            Application app = applications.getApplication(appId);
            if (app != null)
                return deployment.isAppEnabled(app);
        }
        return false;
    }
View Full Code Here

        }
    }

    private boolean isApplicationEnabled(String appId) {
        if (appId != null) {
            Application app = applications.getApplication(appId);
            if (app != null)
                return deployment.isAppEnabled(app);
        }
        return false;
    }
View Full Code Here

    public String getVersionFromSameDir(File dir)
            throws VersioningSyntaxException{

        try {
            Iterator it = domain.getApplications().getApplications().iterator();
            Application app = null;

            // check if directory deployment exist
            while ( it.hasNext() ) {
                app = (Application) it.next();
                /*
                 * A lifecycle module appears as an application but has a null location.
                 */
                if (dir.toURI().toString().equals(app.getLocation())) {
                    if(!VersioningUtils.getUntaggedName(app.getName()).equals(app.getName())){
                        return app.getName();
                    }
                }
            }
        } catch (VersioningSyntaxException ex) {
            // return null if an exception is thrown
View Full Code Here

        if (applications == null)
            return apps;        // no apps

        // all apps are under <server>, even in a cluster
        for (ApplicationRef ref : server.getApplicationRef()) {
            Application app = applications.getApplication(ref.getRef());
            if (app != null) {
                logger.finest("ServerSynchronizer: got app " + app.getName());
                if (Boolean.parseBoolean(app.getDirectoryDeployed()))
                    logger.finest("ServerSynchronizer: skipping directory " +
                                "deployed app: " + app.getName());
                else
                    apps.put(VersioningUtils.getRepositoryName(app.getName()), app);
            }
        }
        return apps;
    }
View Full Code Here

        // for each matched version
        Iterator it = matchedVersions.iterator();
        while (it.hasNext()) {
            String appName = (String)it.next();

            Application application = applications.getApplication(appName);
            if (application == null) {
                if (env.isDas()) {
                    // let's only do this check for DAS to be more
                    // tolerable of the partial deployment case
                    report.setMessage(localStrings.getLocalString("application.notreg","Application {0} not registered", appName));
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                }
                return;
            }

            ApplicationRef applicationRef = domain.getApplicationRefInTarget(appName, target);
            if (applicationRef == null) {
                if (env.isDas()) {
                    // let's only do this check for DAS to be more
                    // tolerable of the partial deployment case
                    report.setMessage(localStrings.getLocalString("appref.not.exists","Target {1} does not have a reference to application {0}.", appName, target));
                    report.setActionExitCode(ActionReport.ExitCode.WARNING);
                }
                return;
            }

            if (application.isLifecycleModule()) {
                try  {
                    deployment.unregisterAppFromDomainXML(appName, target, true);
                } catch(Exception e) {
                    report.failure(logger, e.getMessage());
                }
                return;
            }

            try {
                ReadableArchive source = null;
                ApplicationInfo appInfo = deployment.get(appName);
                if (appInfo != null) {
                    source = appInfo.getSource();
                } else {
                    File location = new File(new URI(application.getLocation()));
                    source = archiveFactory.openArchive(location);
                }

                commandParams.name = appName;
                commandParams.cascade = cascade;

                final ExtendedDeploymentContext deploymentContext =
                        deployment.getBuilder(logger, commandParams, report).source(source).build();
                deploymentContext.getAppProps().putAll(
                    application.getDeployProperties());
                deploymentContext.setModulePropsMap(
                    application.getModulePropertiesMap());

                if (domain.isCurrentInstanceMatchingTarget(target, appName, server.getName(), null)&& appInfo != null) {
                    // stop and unload application if it's the target and the
                    // the application is in enabled state
                    deployment.unload(appInfo, deploymentContext);
                }

                if (report.getActionExitCode().equals(
                    ActionReport.ExitCode.SUCCESS)) {
                    try {
                        if (server.isInstance()) {
                            // if it's on instance, we should clean up
                            // the bits
                            deployment.undeploy(appName, deploymentContext);
                            deploymentContext.clean();
                            if (!Boolean.valueOf(application.getDirectoryDeployed()) && source.exists()) {
                                FileUtils.whack(new File(source.getURI()));
                            }
                            deployment.unregisterAppFromDomainXML(appName, target);
                        } else {
                            deployment.unregisterAppFromDomainXML(appName, target, true);
View Full Code Here

        apps.addAll(applications.getApplicationsWithSnifferType("web"));
        apps.addAll(applications.getApplicationsWithSnifferType("webservices"));

        Iterator<Application> appsIter = apps.iterator();
        while (appsIter.hasNext()) {
            Application app = appsIter.next();
            String appName = app.getName();
            if (!refferedApps.containsKey(appName)) {
                continue;
            }
            ApplicationInfo appInfo = appRegistry.get(appName);
            if (appInfo == null) {
View Full Code Here

        while (it.hasNext()) {
            String appName = (String)it.next();
           
            ApplicationInfo info = deployment.get(appName);

            Application application = apps.getModule(Application.class, appName);

            if (application==null) {
                report.setMessage(localStrings.getLocalString("application.notreg","Application {0} not registered", appName));
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                return;

            }

            deployment.validateUndeploymentTarget(target, appName);

            if (!DeploymentUtils.isDomainTarget(target)) {
                ApplicationRef ref = domain.getApplicationRefInTarget(appName, target);
                if (ref == null) {
                    report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", appName, target));
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    return;
                }
            }

            ReadableArchive source = null;
            if (info==null) {
                // disabled application or application failed to be
                // loaded for some reason
                URI uri = null;
                try {
                    uri = new URI(application.getLocation());
                } catch (URISyntaxException e) {
                    logger.severe("Cannot determine original location for application : " + e.getMessage());
                }
                if (uri != null) {
                    File location = new File(uri);
                    if (location.exists()) {
                        try {
                            source = archiveFactory.openArchive(location);
                        } catch (IOException e) {
                            logger.log(Level.INFO, e.getMessage(),e );
                        }
                    } else {
                        logger.warning("Originally deployed application at "+ location + " not found");
                    }
                }
            } else {
                source = info.getSource();
            }

            if (source == null) {
                logger.fine("Cannot get source archive for undeployment");
                // remove the application from the domain.xml so at least server is
                // in a consistent state
                try {
                    deployment.unregisterAppFromDomainXML(appName, target);
                } catch(TransactionFailure e) {
                    logger.warning("Module " + appName + " not found in configuration");
                }
                return;
            }

            File sourceFile = new File(source.getURI());
            if (!source.exists()) {
                logger.log(Level.WARNING, "Cannot find application bits at " +
                    sourceFile.getPath());
                // remove the application from the domain.xml so at least server is
                // in a consistent state
                try {
                    deployment.unregisterAppFromDomainXML(appName, target);
                } catch(TransactionFailure e) {
                    logger.warning("Module " + appName + " not found in configuration");
                }
                return;
            }

            // now start the normal undeploying
            this.name = appName;

            ExtendedDeploymentContext deploymentContext = null;
            try {
                deploymentContext = deployment.getBuilder(logger, this, report).source(source).build();
            } catch (IOException e) {
                logger.log(Level.SEVERE, "Cannot create context for undeployment ", e);
                report.setMessage(localStrings.getLocalString("undeploy.contextcreation.failed","Cannot create context for undeployment : {0} ", e.getMessage()));
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                return;
            }

            final Properties appProps = deploymentContext.getAppProps();
            appProps.putAll(application.getDeployProperties());

            if (properties!=null) {
                appProps.putAll(properties);
            }

            deploymentContext.setModulePropsMap(
                application.getModulePropertiesMap());

            events.send(new Event<DeploymentContext>(Deployment.UNDEPLOYMENT_VALIDATION, deploymentContext), false);

            if (report.getActionExitCode()==ActionReport.ExitCode.FAILURE) {
                // if one of the validation listeners sets the action report
                // status as failure, return
                return;
            }

            // disable the application first for non-DAS target
            if (env.isDas() && !DeploymentUtils.isDASTarget(target)) {
                CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("disable", report);

                try {
                    final ParameterMapExtractor extractor = new ParameterMapExtractor(this);
                    final ParameterMap parameters = extractor.extract(Collections.EMPTY_LIST);
                    parameters.set("DEFAULT", appName);
                    parameters.add(DeploymentProperties.IS_UNDEPLOY, Boolean.TRUE.toString());
                    inv.parameters(parameters).execute();

                    if (report.getActionExitCode().equals(
                    ActionReport.ExitCode.FAILURE)) {
                    // if disable application failed
                    // we should just return
                        report.setMessage(localStrings.getLocalString("disable.command.failed","{0} disabled failed", appName));
                    return;
                    }

                    if (DeploymentUtils.isDomainTarget(target)) {
                        List<String> targets = domain.getAllReferencedTargetsForApplication(appName);
                        // replicate command to all referenced targets
                        parameters.remove("isUndeploy");
                        ClusterOperationUtil.replicateCommand("undeploy", FailurePolicy.Error, FailurePolicy.Warn, targets, context, parameters, habitat);
                    }
                } catch (Exception e) {
                    report.failure(logger, e.getMessage());
                    return;
                }
            }  

            /*
             * Extract the generated artifacts from the application's properties
             * and record them in the DC.  This will be useful, for example,
             * during Deployer.clean.
             */
            final Artifacts generatedArtifacts = DeploymentUtils.generatedArtifacts(application);
            generatedArtifacts.record(deploymentContext);
           
            if (info!=null) {
                deployment.undeploy(appName, deploymentContext);
            }

            // check if it's directory deployment
            boolean isDirectoryDeployed = false;
            if (application!=null) {
                isDirectoryDeployed = Boolean.valueOf(application.getDirectoryDeployed());
            }

            // we should try to unregister the application for both success
            // and warning case
            if (!report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) {
View Full Code Here

            deploymentContext.getAppProps().putAll(appprops);

            processGeneratedContent(generatedcontent, deploymentContext, logger);
            
            Transaction t = null;
            Application application = applications.getApplication(name);
            if (application != null) {
                // application element already been synchronized over
                t = new Transaction();
            } else {
                t = deployment.prepareAppConfigChanges(deploymentContext);
View Full Code Here

TOP

Related Classes of com.sun.enterprise.config.serverbeans.Application

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.