Search in sources :

Example 11 with Module

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

the class ResourcesDeployer method deployResourcesFromConfiguration.

public void deployResourcesFromConfiguration(String appName, boolean embedded) throws Exception {
    Application application = applications.getApplication(appName);
    ApplicationInfo appInfo = appRegistry.get(appName);
    if (application != null && appInfo != null) {
        Resources appScopedResources = application.getResources();
        if (appScopedResources != null) {
            deployResources(appName, null, appScopedResources.getResources(), embedded);
        }
        List<Module> modules = application.getModule();
        if (modules != null) {
            for (Module module : modules) {
                Resources moduleScopedResources = module.getResources();
                String moduleName = module.getName();
                if (moduleScopedResources != null) {
                    deployResources(appName, moduleName, moduleScopedResources.getResources(), embedded);
                }
            }
        }
    }
}
Also used : ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) Module(com.sun.enterprise.config.serverbeans.Module)

Example 12 with Module

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

the class ConnectorsRecoveryResourceHandler method getAllConnectorResources.

private Collection<ConnectorResource> getAllConnectorResources() {
    Collection<ConnectorResource> allResources = new ArrayList<ConnectorResource>();
    Collection<ConnectorResource> connectorResources = domain.getResources().getResources(ConnectorResource.class);
    allResources.addAll(connectorResources);
    for (Application app : applications.getApplications()) {
        if (ResourcesUtil.createInstance().isEnabled(app)) {
            Resources appScopedResources = app.getResources();
            if (appScopedResources != null && appScopedResources.getResources() != null) {
                allResources.addAll(appScopedResources.getResources(ConnectorResource.class));
            }
            List<Module> modules = app.getModule();
            if (modules != null) {
                for (Module module : modules) {
                    Resources msr = module.getResources();
                    if (msr != null && msr.getResources() != null) {
                        allResources.addAll(msr.getResources(ConnectorResource.class));
                    }
                }
            }
        }
    }
    return allResources;
}
Also used : Module(com.sun.enterprise.config.serverbeans.Module) ConnectorResource(org.glassfish.connectors.config.ConnectorResource)

Example 13 with Module

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

the class RestMonitoringLoader method createAndRegisterApplication.

/**
 * Create the system application entry and register the application
 * @throws Exception
 */
private void createAndRegisterApplication() throws Exception {
    LOGGER.log(Level.FINE, "Registering the Rest Monitoring Application...");
    // Create the system application entry and application-ref in the config
    ConfigCode code = new ConfigCode() {

        @Override
        public Object run(ConfigBeanProxy... proxies) throws PropertyVetoException, TransactionFailure {
            // Create the system application
            SystemApplications systemApplications = (SystemApplications) proxies[0];
            Application application = systemApplications.createChild(Application.class);
            // Check if the application name is valid, generating a new one if it isn't
            checkAndResolveApplicationName(systemApplications);
            systemApplications.getModules().add(application);
            application.setName(applicationName);
            application.setEnabled(Boolean.TRUE.toString());
            application.setObjectType("system-admin");
            application.setDirectoryDeployed("true");
            application.setContextRoot(contextRoot);
            try {
                application.setLocation("${com.sun.aas.installRootURI}/lib/install/applications/" + RestMonitoringService.DEFAULT_REST_MONITORING_APP_NAME);
            } catch (Exception me) {
                throw new RuntimeException(me);
            }
            // Set the engine types
            Module singleModule = application.createChild(Module.class);
            application.getModule().add(singleModule);
            singleModule.setName(applicationName);
            Engine webEngine = singleModule.createChild(Engine.class);
            webEngine.setSniffer("web");
            Engine weldEngine = singleModule.createChild(Engine.class);
            weldEngine.setSniffer("cdi");
            Engine securityEngine = singleModule.createChild(Engine.class);
            securityEngine.setSniffer("security");
            singleModule.getEngines().add(webEngine);
            singleModule.getEngines().add(weldEngine);
            singleModule.getEngines().add(securityEngine);
            // Create the application-ref
            Server s = (Server) proxies[1];
            List<ApplicationRef> arefs = s.getApplicationRef();
            ApplicationRef aref = s.createChild(ApplicationRef.class);
            aref.setRef(application.getName());
            aref.setEnabled(Boolean.TRUE.toString());
            aref.setVirtualServers(getVirtualServerListAsString());
            arefs.add(aref);
            return true;
        }
    };
    Server server = domain.getServerNamed(serverEnv.getInstanceName());
    ConfigSupport.apply(code, domain.getSystemApplications(), server);
    LOGGER.log(Level.FINE, "Rest Monitoring Application Registered.");
}
Also used : ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) Server(com.sun.enterprise.config.serverbeans.Server) ConfigCode(org.jvnet.hk2.config.ConfigCode) SystemApplications(com.sun.enterprise.config.serverbeans.SystemApplications) Module(com.sun.enterprise.config.serverbeans.Module) Application(com.sun.enterprise.config.serverbeans.Application) ApplicationRef(com.sun.enterprise.config.serverbeans.ApplicationRef) PropertyVetoException(java.beans.PropertyVetoException) Engine(com.sun.enterprise.config.serverbeans.Engine)

Example 14 with Module

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

the class ConnectionPoolUtil method isValidModule.

public boolean isValidModule(String applicationName, String moduleName, String poolName, ActionReport report) {
    boolean isValid = false;
    Application application = applications.getApplication(applicationName);
    if (!isValidApplication(applicationName, poolName, report)) {
        return false;
    }
    Module module = application.getModule(moduleName);
    if (module != null) {
        isValid = true;
    } else {
        setModuleNotFoundErrorMessage(report, moduleName, applicationName);
    }
    return isValid;
}
Also used : Module(com.sun.enterprise.config.serverbeans.Module)

Example 15 with Module

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

the class CreateResourceAdapterConfig method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the paramter names and the values the parameter values
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    HashMap attrList = new HashMap();
    attrList.put(RESOURCE_ADAPTER_CONFIG_NAME, raName);
    // attrList.put("name", name);
    attrList.put(THREAD_POOL_IDS, threadPoolIds);
    attrList.put(ServerTags.OBJECT_TYPE, objectType);
    ResourceStatus rs;
    // TODO ASR : need similar validation while creating app-scoped-resource of resource-adapter-config
    String appName = raName;
    if (!ConnectorsUtil.isStandAloneRA(raName)) {
        appName = ConnectorsUtil.getApplicationNameOfEmbeddedRar(raName);
        Application application = applications.getApplication(appName);
        if (application != null) {
            // embedded RAR
            String resourceAdapterName = ConnectorsUtil.getRarNameFromApplication(raName);
            Module module = application.getModule(resourceAdapterName);
            if (module != null) {
                Resources msr = module.getResources();
                if (msr != null) {
                    if (hasDuplicate(msr, report))
                        return;
                }
            }
        }
    } else {
        // standalone RAR
        Application application = applications.getApplication(appName);
        if (application != null) {
            Resources appScopedResources = application.getResources();
            if (appScopedResources != null) {
                if (hasDuplicate(appScopedResources, report))
                    return;
            }
        }
    }
    ResourceAdapterConfigManager resAdapterConfigMgr = new ResourceAdapterConfigManager();
    try {
        rs = resAdapterConfigMgr.create(domain.getResources(), attrList, properties, target);
    } catch (Exception ex) {
        Logger.getLogger(CreateResourceAdapterConfig.class.getName()).log(Level.SEVERE, "Unable to create resource adapter config for " + raName, ex);
        String def = "Resource adapter config: {0} could not be created, reason: {1}";
        report.setMessage(localStrings.getLocalString("create.resource.adapter.config.fail", def, raName) + " " + ex.getLocalizedMessage());
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(ex);
        return;
    }
    ActionReport.ExitCode ec = ActionReport.ExitCode.SUCCESS;
    if (rs.getStatus() == ResourceStatus.FAILURE) {
        ec = ActionReport.ExitCode.FAILURE;
        if (rs.getMessage() != null) {
            report.setMessage(rs.getMessage());
        } else {
            report.setMessage(localStrings.getLocalString("create.resource.adapter.config.fail", "Resource adapter config {0} creation failed", raName, ""));
        }
        if (rs.getException() != null)
            report.setFailureCause(rs.getException());
    }
    report.setActionExitCode(ec);
}
Also used : HashMap(java.util.HashMap) ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) ActionReport(org.glassfish.api.ActionReport) Module(com.sun.enterprise.config.serverbeans.Module)

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