Package com.sun.enterprise.config.serverbeans

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


        if (enabledApps.size()>0) {
            try  {
                ConfigSupport.apply(new ConfigCode() {
                    public Object run(ConfigBeanProxy... configBeanProxies) throws PropertyVetoException, TransactionFailure {
                        for (ConfigBeanProxy proxy : configBeanProxies) {
                            Application app = (Application) proxy;
                            app.setEnabled(Boolean.FALSE.toString());
                        }
                        return null;
                    }
                }, enabledApps.toArray(new Application[enabledApps.size()]));
            } catch(TransactionFailure tf) {
                logger.log(Level.SEVERE, "Exception while disabling applications", tf);
                return;
            }
        }

        // start the application server
        appservStartup.start();

        initializeSigTypeList();

        // redeploy all existing applications
        for (Application app : applications.getApplications()) {
            // we don't need to redeploy lifecycle modules
            if (Boolean.valueOf(app.getDeployProperties().getProperty
                (ServerTags.IS_LIFECYCLE))) {
                continue;
            }
            logger.log(Level.INFO, "Redeploy application " + app.getName() + " located at " + app.getLocation());   
            // we let upgrade proceed even if one application
            // failed to redeploy
            redeployApp(app);
        }

        // re-enables all applications.
        // we need to use the names in the enabledAppNames to find all
        // the application refs that need to be re-enabled
        // as the previous application collected not longer exist
        // after redeployment
        if (enabledAppNames.size()>0) {
            for (Application app : domain.getApplications().getApplications()) {
                if (enabledAppNames.contains(app.getName())) {
                    logger.log(Level.INFO, "Enabling application " + app.getName());
                    try {
                        ConfigSupport.apply(new SingleConfigCode<Application>() {
                            public Object run(Application param) throws PropertyVetoException, TransactionFailure {
                                if (!Boolean.parseBoolean(param.getEnabled())) {
                                    param.setEnabled(Boolean.TRUE.toString());
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

        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) {
                if (logger.isLoggable(Level.FINEST))
                    logger.finest("ServerSynchronizer: got app " +
                                                                app.getName());
                if (Boolean.parseBoolean(app.getDirectoryDeployed())) {
                    if (logger.isLoggable(Level.FINEST))
                        logger.finest("ServerSynchronizer: " +
                                "skipping directory deployed app: " +
                                app.getName());
                } else
                    apps.put(VersioningUtils.getRepositoryName(app.getName()), app);
            }
        }
        return apps;
    }
View Full Code Here

    private synchronized void initAppReloadInfo(Applications applications) throws URISyntaxException {
         appReloadInfo = new HashMap<String,AppReloadInfo>();
         logger.fine("[Reloader] Preparing list of apps to monitor:");
         for (ApplicationName m : applications.getModules()) {
             if (m instanceof Application) {
                 Application app = (Application) m;
                 if (Boolean.valueOf(app.getDeployProperties().getProperty
                     (ServerTags.IS_LIFECYCLE))) {
                     // skip lifecycle modules
                     continue;
                 }
                 AppReloadInfo info = new AppReloadInfo(app);
                 appReloadInfo.put(app.getName(), info);
                 logger.fine("[Reloader] Monitoring " + app.getName() + " at " + app.getLocation());
             }
         }
    }
View Full Code Here

         */
        Set<AppReloadInfo> possiblyUndeployedApps = new HashSet<AppReloadInfo>(appReloadInfo.values());
       
        for (ApplicationName m : applications.getModules()) {
            if (m instanceof Application) {
                Application app = (Application) m;
                if (Boolean.valueOf(app.getDeployProperties().getProperty
                    (ServerTags.IS_LIFECYCLE))) {
                    // skip lifecycle modules
                    continue;
                }
                AppReloadInfo reloadInfo = findOrCreateAppReloadInfo(app);
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

            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;

        }

        Application application = applications.getApplication(applicationName);

        if (application.isLifecycleModule()) {
            if (!terse) {
                part.setMessage(localStrings.getLocalString("listsubcomponents.no.elements.to.list", "Nothing to List."));
            }
            return;
        }

        ApplicationInfo appInfo = appRegistry.get(applicationName);
        if (appInfo == null) {
            report.setMessage(localStrings.getLocalString("application.not.enabled","Application {0} is not in an enabled state", applicationName));
            return;
        }

        com.sun.enterprise.deployment.Application app = appInfo.getMetaData(com.sun.enterprise.deployment.Application.class);

        if (app == null) {
            if (!terse) {
                part.setMessage(localStrings.getLocalString("listsubcomponents.no.elements.to.list", "Nothing to List."));
            }
            return;
        }

        Map<String, String> subComponents ;
        Map<String, String> subComponentsMap = new HashMap<String, String>();

        if (appname == null) {
            subComponents = getAppLevelComponents(app, type, subComponentsMap);
        } else {
            BundleDescriptor bundleDesc = app.getModuleByUri(modulename);
            if (bundleDesc == null) {
                report.setMessage(localStrings.getLocalString("listsubcomponents.invalidmodulename", "Invalid module name", appname, modulename));
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                return;
            }
            subComponents = getModuleLevelComponents(
                bundleDesc, type, subComponentsMap);
        }
       
        // the type param can only have values "ejbs" and "servlets"
        if (type != null)  {
            if (!type.equals("servlets") && !type.equals("ejbs")) {
                report.setMessage(localStrings.getLocalString("listsubcomponents.invalidtype", "The type option has invalid value {0}. It should have a value of servlets or ejbs.", type));
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                return;
            }
        }

        List<String> subModuleInfos = new ArrayList<String>();   
        if (!app.isVirtual()) {
            subModuleInfos = getSubModulesForEar(app);
        }

        int[] longestValue = new int[2];
        for (Map.Entry<String, String> entry : subComponents.entrySet()) {
            String key = entry.getKey();
            if (key.length() > longestValue[0]) {
                longestValue[0] = key.length();
            }
            String value = entry.getValue();
            if (value.length() > longestValue[1]) {
                longestValue[1] = value.length();
            }
        }
        StringBuilder formattedLineBuf = new StringBuilder();
        for (int j = 0; j < 2; j++) {
            longestValue[j] += 2;
            formattedLineBuf.append("%-")
                    .append(longestValue[j])
                    .append("s");
        }
        String formattedLine = formattedLineBuf.toString();
        if (!terse && subComponents.isEmpty()) {
            part.setMessage(localStrings.getLocalString("listsubcomponents.no.elements.to.list", "Nothing to List."));
        }
        int i=0;
        for (String key : subComponents.keySet()) {
            ActionReport.MessagePart childPart = part.addChild();
            childPart.setMessage(
                    String.format(formattedLine,
                    new Object[]{key, subComponents.get(key)} ));
            if (appname == null && !app.isVirtual()) {
                // we use the property mechanism to provide
                // support for JSR88 client
                if (subModuleInfos.get(i) != null) {
                    childPart.addProperty("moduleInfo",
                        subModuleInfos.get(i));
                }
            }
            if (resources) {
                Module module = application.getModule(key);
                if (module != null) {
                    ActionReport subReport = report.addSubActionsReport();
                    CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("_list-resources", subReport, context.getSubject());
                    final ParameterMap parameters = new ParameterMap();
                    parameters.add("appname", application.getName());
                    parameters.add("modulename", module.getName());
                    inv.parameters(parameters).execute();

                    ActionReport.MessagePart subPart = subReport.getTopMessagePart();
                    for (ActionReport.MessagePart cp : subPart.getChildren()) {
View Full Code Here

        } catch (VersioningSyntaxException ex) {
            report.failure(logger,ex.getMessage());
            return;
        }

        Application matchingApp = null;
        for (Application app : apps.getApplications()) {
            if (app.getName().equals(appname)) {
                matchingApp = app;
                break;
            }
View Full Code Here

    @Override
    public void execute(AdminCommandContext context) {
        final ActionReport report = context.getActionReport();
       
        final Application app = apps.getApplication(appname);
        if (app != null) {
            Module appClient = app.getModule(modulename);
            if (appClient == null) {
                appClient = app.getModule(modulename + ".jar");
            }
            if (appClient != null) {
                String result = appClient.getPropertyValue("jws.user.friendly.path");
                /*
                 * For stand-alone app clients the property is stored at the
                 * application level instead of the module level.
                 */
                if (result == null) {
                    result = app.getPropertyValue("jws.user.friendly.path");
                }
                if (result != null) {
                    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                    report.getTopMessagePart().addProperty(URI_PROPERTY_NAME, result);
                    report.setMessage(result);
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

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.