Package com.sun.enterprise.config.serverbeans

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


        List<String> allVersions = new ArrayList<String>();
        Iterator<Application> it = allApplications.iterator();

        while (it.hasNext()) {
            Application app = it.next();

            // if a tagged version or untagged version of the app
            if (app.getName().startsWith(untaggedName + EXPRESSION_SEPARATOR)
                    || app.getName().equals(untaggedName)) {
                allVersions.add(app.getName());
            }
        }
        return allVersions;
    }
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 (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 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

            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);
                    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

     * command arguments.
     *
     * @return Application object for the app
     */
    private Application application() {
        final Application result = apps.getModule(Application.class,
                appName());

        return result;
    }
View Full Code Here

        return result;
    }

    private Module module(final ActionReport report) {
        final Application app = application();
        if (app == null) {
            fail(report, "appNotReg","Application {0} not registered",
                    appName());
            return null;
        }

        /*
         * Be helpful by announcing if the user specified a submodule but this
         * is not an EAR or if the user did NOT specify a submodule but this IS
         * an EAR.
         */
        if (app.isStandaloneModule() && appNameAndOptionalModuleName.contains("/")) {
            fail(report, "standaloneAppNoSubMods",
                    "Application {0} is a stand-alone application and contains no submodules but submodule {1} was specified",
                    appName(),
                    moduleName());
            return null;
        }

        if ( ! app.isStandaloneModule() && ! appNameAndOptionalModuleName.contains("/")) {
            fail(report, "earNoModuleSelection",
                    "Application {0} is an enterprise application; please also specify one of the web module names ({1}) as part of the command argument (for example, {0}/{2})",
                    appName(),
                    webModuleList(app),
                    app.getModule().get(0).getName());
            return null;
        }

        final Module module = app.getModule(moduleName());
        if (module == null) {
            if (app.getModule().isEmpty()) {
                fail(report, "noWebModules", "Application {0} contains no web modules",
                        appName());
            } else {
                fail(report, "noSuchModule","Application {0} contains web modules {1} but {2} is not one of them",
                        appName(),
View Full Code Here

     * command arguments.
     *
     * @return Application object for the app
     */
    private Application application() {
        final Application result = apps.getModule(Application.class,
                appName());

        return result;
    }
View Full Code Here

        return result;
    }

    private Module module(final ActionReport report) {
        final Application app = application();
        if (app == null) {
            fail(report, "appNotReg","Application {0} not registered",
                    appName());
            return null;
        }

        /*
         * Be helpful by announcing if the user specified a submodule but this
         * is not an EAR or if the user did NOT specify a submodule but this IS
         * an EAR.
         */
        if (app.isStandaloneModule() && appNameAndOptionalModuleName.contains("/")) {
            fail(report, "standaloneAppNoSubMods",
                    "Application {0} is a stand-alone application and contains no submodules but submodule {1} was specified",
                    appName(),
                    moduleName());
            return null;
        }

        if ( ! app.isStandaloneModule() && ! appNameAndOptionalModuleName.contains("/")) {
            fail(report, "earNoModuleSelection",
                    "Application {0} is an enterprise application; please also specify one of the web module names ({1}) as part of the command argument (for example, {0}/{2})",
                    appName(),
                    webModuleList(app),
                    app.getModule().get(0).getName());
            return null;
        }

        final Module module = app.getModule(moduleName());
        if (module == null) {
            if (app.getModule().isEmpty()) {
                fail(report, "noWebModules", "Application {0} contains no web modules",
                        appName());
            } else {
                fail(report, "noSuchModule","Application {0} contains web modules {1} but {2} is not one of them",
                        appName(),
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.