Search in sources :

Example 36 with Module

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

the class InstallerThread method install.

/**
 * <p> Install the admingui.war file.</p>
 */
private void install() throws Exception {
    if (domain.getSystemApplicationReferencedFrom(env.getInstanceName(), AdminConsoleAdapter.ADMIN_APP_NAME) != null) {
        // Application is already installed
        adapter.setStateMsg(AdapterState.APPLICATION_INSTALLED_BUT_NOT_LOADED);
        return;
    }
    // Set the adapter state
    adapter.setStateMsg(AdapterState.INSTALLING);
    if (log.isLoggable(Level.FINE)) {
        log.log(Level.FINE, "Installing the Admin Console Application...");
    }
    // create the application entry in domain.xml
    ConfigCode code = new ConfigCode() {

        @Override
        public Object run(ConfigBeanProxy... proxies) throws PropertyVetoException, TransactionFailure {
            SystemApplications sa = (SystemApplications) proxies[0];
            Application app = sa.createChild(Application.class);
            sa.getModules().add(app);
            app.setName(AdminConsoleAdapter.ADMIN_APP_NAME);
            app.setEnabled(Boolean.TRUE.toString());
            // TODO
            app.setObjectType("system-admin");
            app.setDirectoryDeployed("true");
            app.setContextRoot(contextRoot);
            try {
                app.setLocation("${com.sun.aas.installRootURI}/lib/install/applications/" + AdminConsoleAdapter.ADMIN_APP_NAME);
            } catch (Exception me) {
                // can't do anything
                throw new RuntimeException(me);
            }
            Module singleModule = app.createChild(Module.class);
            app.getModule().add(singleModule);
            singleModule.setName(app.getName());
            Engine webe = singleModule.createChild(Engine.class);
            webe.setSniffer("web");
            Engine sece = singleModule.createChild(Engine.class);
            sece.setSniffer("security");
            singleModule.getEngines().add(webe);
            singleModule.getEngines().add(sece);
            Server s = (Server) proxies[1];
            List<ApplicationRef> arefs = s.getApplicationRef();
            ApplicationRef aref = s.createChild(ApplicationRef.class);
            aref.setRef(app.getName());
            aref.setEnabled(Boolean.TRUE.toString());
            // TODO
            aref.setVirtualServers(getVirtualServerList());
            arefs.add(aref);
            return true;
        }
    };
    Server server = domain.getServerNamed(env.getInstanceName());
    ConfigSupport.apply(code, domain.getSystemApplications(), server);
    // Set the adapter state
    adapter.setStateMsg(AdapterState.APPLICATION_INSTALLED_BUT_NOT_LOADED);
    if (log.isLoggable(Level.FINE)) {
        log.log(Level.FINE, "Admin Console Application Installed.");
    }
}
Also used : ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) ConfigCode(org.jvnet.hk2.config.ConfigCode) Module(com.sun.enterprise.config.serverbeans.Module) PropertyVetoException(java.beans.PropertyVetoException)

Example 37 with Module

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

the class ConnectorRuntime method getResources.

public Resources getResources(ResourceInfo resourceInfo) {
    if (ConnectorsUtil.isModuleScopedResource(resourceInfo)) {
        Application application = getApplications().getApplication(resourceInfo.getApplicationName());
        Module module = application.getModule(resourceInfo.getModuleName());
        return module.getResources();
    } else if (ConnectorsUtil.isApplicationScopedResource(resourceInfo)) {
        Application application = getApplications().getApplication(resourceInfo.getApplicationName());
        return application.getResources();
    }
    return getResources();
}
Also used : Module(com.sun.enterprise.config.serverbeans.Module) ConnectorApplication(com.sun.enterprise.connectors.module.ConnectorApplication)

Example 38 with Module

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

the class ConnectorRuntime method getWorkSecurityMap.

/**
 * {@inheritDoc}
 */
public List<WorkSecurityMap> getWorkSecurityMap(String raName) {
    List<WorkSecurityMap> workSecurityMap = ConnectorsUtil.getWorkSecurityMaps(raName, getResources());
    List<WorkSecurityMap> appScopedMap = null;
    String appName = raName;
    if (!ConnectorsUtil.isStandAloneRA(raName)) {
        appName = ConnectorsUtil.getApplicationNameOfEmbeddedRar(raName);
        Application application = getApplications().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) {
                    appScopedMap = ConnectorsUtil.getWorkSecurityMaps(raName, msr);
                }
            }
        }
    } else {
        Application app = getApplications().getApplication(appName);
        if (app != null) {
            Resources asc = app.getResources();
            if (asc != null) {
                appScopedMap = ConnectorsUtil.getWorkSecurityMaps(raName, asc);
            }
        }
    }
    if (appScopedMap != null) {
        workSecurityMap.addAll(appScopedMap);
    }
    return workSecurityMap;
}
Also used : WorkSecurityMap(org.glassfish.connectors.config.WorkSecurityMap) Module(com.sun.enterprise.config.serverbeans.Module) ConnectorApplication(com.sun.enterprise.connectors.module.ConnectorApplication)

Example 39 with Module

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

the class JdbcRecoveryResourceHandler method getAllJdbcResources.

private Collection<JdbcResource> getAllJdbcResources() {
    Collection<JdbcResource> allResources = new ArrayList<JdbcResource>();
    Collection<JdbcResource> jdbcResources = domain.getResources().getResources(JdbcResource.class);
    allResources.addAll(jdbcResources);
    for (Application app : applications.getApplications()) {
        if (ResourcesUtil.createInstance().isEnabled(app)) {
            Resources appScopedResources = app.getResources();
            if (appScopedResources != null && appScopedResources.getResources() != null) {
                allResources.addAll(appScopedResources.getResources(JdbcResource.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(JdbcResource.class));
                    }
                }
            }
        }
    }
    return allResources;
}
Also used : JdbcResource(org.glassfish.jdbc.config.JdbcResource) ArrayList(java.util.ArrayList) Resources(com.sun.enterprise.config.serverbeans.Resources) Module(com.sun.enterprise.config.serverbeans.Module) Application(com.sun.enterprise.config.serverbeans.Application)

Example 40 with Module

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

the class AbstractConnectorResourceDeployer method validatePreservedResource.

/**
 * {@inheritDoc}
 */
public void validatePreservedResource(Application oldApp, Application newApp, Resource resource, Resources allResources) throws ResourceConflictException {
    // check whether old app has any RAR
    List<Module> oldRARModules = new ArrayList<Module>();
    List<Module> oldModules = oldApp.getModule();
    for (Module oldModule : oldModules) {
        if (oldModule.getEngine(ConnectorConstants.CONNECTOR_MODULE) != null) {
            oldRARModules.add(oldModule);
        }
    }
    /*
       //check whether new app has any RAR
       //TODO ASR : <sniffer> info is not available during initial phase of deployment. Hence doing "module-name" check.
       List<Module> newRARModules = new ArrayList<Module>();
        List<Module> newModules = newApp.getModule();
        for (Module newModule : newModules) {
            if (newModule.getEngine(ResourceConstants.CONNECTOR_MODULE) != null) {
                newRARModules.add(newModule);
            }
        }
*/
    List<Module> newRARModules = newApp.getModule();
    // check whether all old RARs are present in new RARs list.
    List<Module> staleRars = new ArrayList<Module>();
    for (Module oldRARModule : oldRARModules) {
        String oldRARModuleName = oldRARModule.getName();
        boolean found = false;
        for (Module newRARModule : newRARModules) {
            String newRARModuleName = newRARModule.getName();
            if (newRARModuleName.equals(oldRARModuleName)) {
                found = true;
            }
        }
        if (!found) {
            staleRars.add(oldRARModule);
        }
    }
    String appName = newApp.getName();
    if (staleRars.size() > 0) {
        validateResourcesForStaleReference(appName, staleRars, allResources);
    }
}
Also used : ArrayList(java.util.ArrayList) 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