Search in sources :

Example 1 with Application

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

the class EjbComponentProvider method getApplicationInfo.

private ApplicationInfo getApplicationInfo(EjbContainerUtil ejbUtil) throws NamingException {
    ApplicationRegistry appRegistry = ejbUtil.getServices().getService(ApplicationRegistry.class);
    Applications applications = ejbUtil.getServices().getService(Applications.class);
    String appNamePrefix = (String) initialContext.lookup("java:app/AppName");
    Set<String> appNames = appRegistry.getAllApplicationNames();
    Set<String> disabledApps = new TreeSet<>();
    for (String appName : appNames) {
        if (appName.startsWith(appNamePrefix)) {
            Application appDesc = applications.getApplication(appName);
            if (appDesc != null && !ejbUtil.getDeployment().isAppEnabled(appDesc)) {
                // skip disabled version of the app
                disabledApps.add(appName);
            } else {
                return ejbUtil.getDeployment().get(appName);
            }
        }
    }
    // grab the latest one, there is no way to make
    // sure which one the user is actually enabling,
    // so use the best case, i.e. upgrade
    Iterator<String> it = disabledApps.iterator();
    String lastDisabledApp = null;
    while (it.hasNext()) {
        lastDisabledApp = it.next();
    }
    if (lastDisabledApp != null) {
        return ejbUtil.getDeployment().get(lastDisabledApp);
    }
    throw new NamingException("Application Information Not Found");
}
Also used : ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) Applications(com.sun.enterprise.config.serverbeans.Applications) TreeSet(java.util.TreeSet) NamingException(javax.naming.NamingException) Application(com.sun.enterprise.config.serverbeans.Application)

Example 2 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 3 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.admin.report.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 4 with Application

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

the class ListContainersCommand method execute.

public void execute(AdminCommandContext context) {
    ActionReport report = context.getActionReport();
    report.setActionDescription(localStrings.getLocalString("list.containers.command", "List of Containers"));
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    ActionReport.MessagePart top = report.getTopMessagePart();
    top.setMessage(localStrings.getLocalString("list.containers.command", "List of Containers"));
    top.setChildrenType(localStrings.getLocalString("container", "Container"));
    Iterable<? extends Sniffer> sniffers = habitat.getAllServices(Sniffer.class);
    if (sniffers == null) {
        top.setMessage(localStrings.getLocalString("list.containers.nocontainer", "No container currently configured"));
    } else {
        for (Sniffer sniffer : sniffers) {
            ActionReport.MessagePart container = top.addChild();
            container.setMessage(sniffer.getModuleType());
            container.addProperty(localStrings.getLocalString("contractprovider", "ContractProvider"), sniffer.getModuleType());
            EngineInfo engineInfo = containerRegistry.getContainer(sniffer.getModuleType());
            if (engineInfo != null) {
                container.addProperty(localStrings.getLocalString("status", "Status"), localStrings.getLocalString("started", "Started"));
                HK2Module connectorModule = modulesRegistry.find(engineInfo.getSniffer().getClass());
                container.addProperty(localStrings.getLocalString("connector", "Connector"), connectorModule.getModuleDefinition().getName() + ":" + connectorModule.getModuleDefinition().getVersion());
                container.addProperty(localStrings.getLocalString("implementation", "Implementation"), engineInfo.getContainer().getClass().toString());
                boolean atLeastOne = false;
                for (Application app : applications.getApplications()) {
                    for (com.sun.enterprise.config.serverbeans.Module module : app.getModule()) {
                        Engine engine = module.getEngine(engineInfo.getSniffer().getModuleType());
                        if (engine != null) {
                            if (!atLeastOne) {
                                atLeastOne = true;
                                container.setChildrenType(localStrings.getLocalString("list.containers.listapps", "Applications deployed"));
                            }
                            container.addChild().setMessage(app.getName());
                        }
                    }
                }
                if (!atLeastOne) {
                    container.addProperty("Status", "Not Started");
                }
            }
        }
    }
}
Also used : HK2Module(com.sun.enterprise.module.HK2Module) Sniffer(org.glassfish.api.container.Sniffer) ActionReport(org.glassfish.api.ActionReport) EngineInfo(org.glassfish.internal.data.EngineInfo) Application(com.sun.enterprise.config.serverbeans.Application) Engine(com.sun.enterprise.config.serverbeans.Engine)

Example 5 with Application

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

the class CreateLifecycleModuleCommand method validateTarget.

private void validateTarget(String target, String name) {
    List<String> referencedTargets = domain.getAllReferencedTargetsForApplication(name);
    Application app = apps.getApplication(name);
    if (app != null && !app.isLifecycleModule()) {
        throw new IllegalArgumentException(localStrings.getLocalString("application_withsamename_exists", "Application with same name {0} already exists, please pick a different name for the lifecycle module.", name));
    }
    if (referencedTargets.isEmpty()) {
        if (deployment.isRegistered(name)) {
            throw new IllegalArgumentException(localStrings.getLocalString("lifecycle.use.create_app_ref_2", "Lifecycle module {0} is already created in this domain. Please use create application ref to create application reference on target {1}", name, target));
        }
    } else {
        if (referencedTargets.contains(target)) {
            throw new IllegalArgumentException(localStrings.getLocalString("lifecycle.alreadyreg", "Lifecycle module {0} is already created on this target {1}", name, target));
        } else {
            throw new IllegalArgumentException(localStrings.getLocalString("lifecycle.use.create_app_ref", "Lifecycle module {0} is already referenced by other target(s). Please use create application ref to create application reference on target {1}", name, target));
        }
    }
}
Also used : Application(com.sun.enterprise.config.serverbeans.Application)

Aggregations

Application (com.sun.enterprise.config.serverbeans.Application)46 Module (com.sun.enterprise.config.serverbeans.Module)11 ActionReport (org.glassfish.api.ActionReport)10 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)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 Server (com.sun.enterprise.config.serverbeans.Server)4 Test (org.junit.Test)4 SystemApplications (com.sun.enterprise.config.serverbeans.SystemApplications)3 File (java.io.File)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