Search in sources :

Example 26 with Module

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

the class ListResources method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the parameter names and the values the parameter values
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    if (appName != null) {
        if (!isValidApplication(appName)) {
            ActionReport report = context.getActionReport();
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            ActionReport.MessagePart messagePart = report.getTopMessagePart();
            messagePart.setMessage("Invalid application [" + appName + "]");
            return;
        }
    }
    if (moduleName != null) {
        if (!isValidModule(appName, moduleName)) {
            ActionReport report = context.getActionReport();
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            ActionReport.MessagePart messagePart = report.getTopMessagePart();
            messagePart.setMessage("Invalid module [" + moduleName + "] in application [" + appName + "]");
            return;
        }
    }
    if (appName != null && moduleName != null) {
        Application application = applications.getApplication(appName);
        Module module = application.getModule(moduleName);
        Resources moduleScopedResources = module.getResources();
        if (moduleScopedResources != null) {
            ActionReport report = context.getActionReport();
            ActionReport.MessagePart messagePart = report.getTopMessagePart();
            generateResourcesList(messagePart, moduleScopedResources.getResources());
        }
    } else if (appName != null) {
        Application application = applications.getApplication(appName);
        Resources appScopedResources = application.getResources();
        if (appScopedResources != null) {
            ActionReport report = context.getActionReport();
            ActionReport.MessagePart messagePart = report.getTopMessagePart();
            generateResourcesList(messagePart, appScopedResources.getResources());
        }
    }
}
Also used : ActionReport(org.glassfish.api.ActionReport) Module(com.sun.enterprise.config.serverbeans.Module)

Example 27 with Module

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

the class ResourcesDeployer method preserveResources.

private void preserveResources(Application app) {
    String appName = app.getName();
    Map<String, Resources> allResources = new HashMap<String, Resources>();
    Resources appScopedResources = app.getResources();
    if (appScopedResources != null) {
        allResources.put(appName, appScopedResources);
    }
    List<Module> modules = app.getModule();
    if (modules != null) {
        for (Module module : modules) {
            Resources moduleScopedResources = module.getResources();
            if (moduleScopedResources != null) {
                allResources.put(module.getName(), moduleScopedResources);
            }
        }
    }
    // store the resource-configuration
    ResourcesRegistry.putResources(appName, allResources);
}
Also used : Module(com.sun.enterprise.config.serverbeans.Module)

Example 28 with Module

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

the class ApplicationScopedResourcesManager method undeployResources.

/**
 * Undeploy all resources associated with a given application
 * @param applicationName
 */
public void undeployResources(String applicationName) {
    Application app = applications.getApplication(applicationName);
    if (app != null) {
        List<Module> modules = app.getModule();
        if (modules != null) {
            for (Module module : modules) {
                Resources moduleScopedResources = module.getResources();
                if (moduleScopedResources != null) {
                    undeployResources(moduleScopedResources);
                }
            }
        }
        Resources appScopedResources = app.getResources();
        if (appScopedResources != null) {
            undeployResources(appScopedResources);
        }
    }
}
Also used : Module(com.sun.enterprise.config.serverbeans.Module)

Example 29 with Module

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

the class ApplicationScopedResourcesManager method deployResources.

/**
 * deploy resources
 * @param resources list
 */
public void deployResources(Collection<Resource> resources) {
    if (resources != null) {
        String applicationName = null;
        String moduleName = null;
        for (Resource resource : resources) {
            Object parentObject = resource.getParent().getParent();
            if (parentObject instanceof Application) {
                applicationName = ((Application) parentObject).getName();
            } else if (parentObject instanceof Module) {
                moduleName = ((Module) parentObject).getName();
                applicationName = ((Application) ((Module) parentObject).getParent()).getName();
            }
            if (resource instanceof BindableResource) {
                BindableResource bindableResource = (BindableResource) resource;
                ResourceInfo resourceInfo = new ResourceInfo(bindableResource.getJndiName(), applicationName, moduleName);
                resourcesBinder.deployResource(resourceInfo, resource);
            } else if (resource instanceof ResourcePool) {
            // ignore, as they are loaded lazily
            } else {
                // only other resources left are RAC, CWSM
                try {
                    getResourceDeployer(resource).deployResource(resource, applicationName, moduleName);
                } catch (Exception e) {
                    Object[] params = { ResourceUtil.getGenericResourceInfo(resource), e };
                    _logger.log(Level.WARNING, "resources.resource-manager.deploy-resource-failed", params);
                }
            }
        }
        addListenerToResources(resources);
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) Module(com.sun.enterprise.config.serverbeans.Module)

Example 30 with Module

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

the class WebModuleConfigCommand method engine.

protected Engine engine(final ActionReport report) {
    Module module = module(report);
    if (module == null) {
        return null;
    }
    Engine e = module.getEngine(WEB_SNIFFER_TYPE);
    if (e == null) {
        fail(report, "noSuchEngine", "Application {0}/module {1} does not contain engine {2}", appName(), moduleName(), WEB_SNIFFER_TYPE);
    }
    return e;
}
Also used : Module(com.sun.enterprise.config.serverbeans.Module) Engine(com.sun.enterprise.config.serverbeans.Engine)

Aggregations

Module (com.sun.enterprise.config.serverbeans.Module)42 Application (com.sun.enterprise.config.serverbeans.Application)11 ActionReport (org.glassfish.api.ActionReport)9 PropertyVetoException (java.beans.PropertyVetoException)5 Engine (com.sun.enterprise.config.serverbeans.Engine)3 Resource (com.sun.enterprise.config.serverbeans.Resource)3 Resources (com.sun.enterprise.config.serverbeans.Resources)3 ArrayList (java.util.ArrayList)3 Property (org.jvnet.hk2.config.types.Property)3 Server (com.sun.enterprise.config.serverbeans.Server)2 ConnectorApplication (com.sun.enterprise.connectors.module.ConnectorApplication)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 ConnectorResource (org.glassfish.connectors.config.ConnectorResource)2 WorkSecurityMap (org.glassfish.connectors.config.WorkSecurityMap)2 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)2 Resource (org.glassfish.resources.api.Resource)2 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 RemoteRestAdminCommand (com.sun.enterprise.admin.remote.RemoteRestAdminCommand)1 ServerRemoteRestAdminCommand (com.sun.enterprise.admin.remote.ServerRemoteRestAdminCommand)1