Search in sources :

Example 16 with Application

use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.

the class ListLifecycleModulesCommand method execute.

public void execute(AdminCommandContext context) {
    ActionReport report = context.getActionReport();
    ActionReport.MessagePart part = report.getTopMessagePart();
    boolean found = false;
    for (Application app : domain.getApplicationsInTarget(target)) {
        if (app.isLifecycleModule()) {
            ActionReport.MessagePart childPart = part.addChild();
            childPart.setMessage(app.getName());
            found = true;
        }
    }
    if (!found && !terse) {
        part.setMessage(localStrings.getLocalString("list.components.no.elements.to.list", "Nothing to List."));
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : ActionReport(org.glassfish.api.ActionReport) Application(com.sun.enterprise.config.serverbeans.Application)

Example 17 with Application

use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.

the class ApplicationConfigListener method handleOtherAppConfigChanges.

private void handleOtherAppConfigChanges(Object parent, String appName) {
    Application application = applications.getApplication(appName);
    if (application.isLifecycleModule()) {
        return;
    }
    // config changes if the application is in enabled state
    if (isCurrentInstanceMatchingTarget(parent) && deployment.isAppEnabled(application)) {
        disableApplication(appName);
        enableApplication(appName);
    }
}
Also used : Application(com.sun.enterprise.config.serverbeans.Application)

Example 18 with Application

use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.

the class ApplicationConfigListener method disableApplication.

private void disableApplication(String appName) {
    Application app = applications.getApplication(appName);
    ApplicationRef appRef = domain.getApplicationRefInServer(server.getName(), appName);
    // by the current server instance, do not unload
    if (app == null || appRef == null) {
        return;
    }
    ApplicationInfo appInfo = appRegistry.get(appName);
    if (appInfo == null || !appInfo.isLoaded()) {
        return;
    }
    try {
        ActionReport report = new HTMLActionReporter();
        UndeployCommandParameters commandParams = new UndeployCommandParameters();
        commandParams.name = appName;
        commandParams.target = server.getName();
        commandParams.origin = UndeployCommandParameters.Origin.unload;
        commandParams.command = UndeployCommandParameters.Command.disable;
        deployment.disable(commandParams, app, appInfo, report, logger);
        if (report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) {
            throw new Exception(report.getMessage());
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE, KernelLoggerInfo.loadingApplicationErrorDisable, e);
        throw new RuntimeException(e);
    }
}
Also used : UndeployCommandParameters(org.glassfish.api.deployment.UndeployCommandParameters) HTMLActionReporter(com.sun.enterprise.v3.common.HTMLActionReporter) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) ActionReport(org.glassfish.api.ActionReport) Application(com.sun.enterprise.config.serverbeans.Application) ApplicationRef(com.sun.enterprise.config.serverbeans.ApplicationRef)

Example 19 with Application

use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.

the class DynamicReloader method chooseAppsToReload.

private synchronized List<AppReloadInfo> chooseAppsToReload() throws URISyntaxException {
    List<AppReloadInfo> result = new ArrayList<AppReloadInfo>();
    /*
         * The collectionof AppReloadInfo might not contain entries for all
         * current apps (for example, if an app has been deployed since the
         * previous run of the reloader).  Use the current list of all known
         * apps, and for each of those try to find an AppReloadInfo entry for
         * it.
         */
    Set<AppReloadInfo> possiblyUndeployedApps = new HashSet<AppReloadInfo>(appReloadInfo.values());
    for (ApplicationName m : applications.getModules()) {
        if (m instanceof Application) {
            Application app = (Application) m;
            if (app.getLocation() == null || Boolean.valueOf(app.getDeployProperties().getProperty(ServerTags.IS_LIFECYCLE))) {
                // skip lifecycle modules
                continue;
            }
            AppReloadInfo reloadInfo = findOrCreateAppReloadInfo(app);
            if (reloadInfo.needsReload()) {
                logger.fine("[Reloader] Selecting app " + reloadInfo.getApplication().getName() + " to reload");
                result.add(reloadInfo);
            }
            possiblyUndeployedApps.remove(reloadInfo);
        }
    }
    /*
         * Remove any apps from the reload info that are no longer present.
         */
    for (AppReloadInfo info : possiblyUndeployedApps) {
        logger.fine("[Reloader] Removing undeployed app " + info.getApplication().getName() + " from reload info");
        appReloadInfo.remove(info.getApplication().getName());
    }
    return result;
}
Also used : ApplicationName(org.glassfish.api.admin.config.ApplicationName) ArrayList(java.util.ArrayList) Application(com.sun.enterprise.config.serverbeans.Application) HashSet(java.util.HashSet)

Example 20 with Application

use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.

the class DynamicReloader method initAppReloadInfo.

/**
 * Records reload information about the currently-known applications.
 *
 * @param applications
 */
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());
        }
    }
}
Also used : ApplicationName(org.glassfish.api.admin.config.ApplicationName) Application(com.sun.enterprise.config.serverbeans.Application)

Aggregations

Application (com.sun.enterprise.config.serverbeans.Application)44 Module (com.sun.enterprise.config.serverbeans.Module)10 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)9 ActionReport (org.glassfish.api.ActionReport)9 ArrayList (java.util.ArrayList)8 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)7 Property (org.jvnet.hk2.config.types.Property)7 Applications (com.sun.enterprise.config.serverbeans.Applications)6 PropertyVetoException (java.beans.PropertyVetoException)6 HashMap (java.util.HashMap)5 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)5 Test (org.junit.Test)4 Server (com.sun.enterprise.config.serverbeans.Server)3 SystemApplications (com.sun.enterprise.config.serverbeans.SystemApplications)3 HashSet (java.util.HashSet)3 Iterator (java.util.Iterator)3 List (java.util.List)3 Logger (java.util.logging.Logger)3 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)3 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)3