Search in sources :

Example 6 with Application

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

the class WebModuleConfigCommand method module.

private Module module(final ActionReport report) {
    final Application app = application();
    if (app == null) {
        fail(report, "appNotReg", "Application {0} not registered", appName());
        return null;
    }
    /*
         * Be helpful by announcing if the user specified a submodule but this
         * is not an EAR or if the user did NOT specify a submodule but this IS
         * an EAR.
         */
    if (app.isStandaloneModule() && appNameAndOptionalModuleName.contains("/")) {
        fail(report, "standaloneAppNoSubMods", "Application {0} is a stand-alone application and contains no submodules but submodule {1} was specified", appName(), moduleName());
        return null;
    }
    if (!app.isStandaloneModule() && !appNameAndOptionalModuleName.contains("/")) {
        fail(report, "earNoModuleSelection", "Application {0} is an enterprise application; please also specify one of the web module names ({1}) as part of the command argument (for example, {0}/{2})", appName(), webModuleList(app), app.getModule().get(0).getName());
        return null;
    }
    final Module module = app.getModule(moduleName());
    if (module == null) {
        if (app.getModule().isEmpty()) {
            fail(report, "noWebModules", "Application {0} contains no web modules", appName());
        } else {
            fail(report, "noSuchModule", "Application {0} contains web modules {1} but {2} is not one of them", appName(), webModuleList(app), moduleName());
        }
    }
    return module;
}
Also used : Module(com.sun.enterprise.config.serverbeans.Module) Application(com.sun.enterprise.config.serverbeans.Application)

Example 7 with Application

use of com.sun.enterprise.config.serverbeans.Application 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("weld");
            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 8 with Application

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

the class RestMonitoringLoader method registerApplication.

private void registerApplication() throws Exception {
    LOGGER.log(Level.FINE, "Registering the Rest Monitoring Application...");
    // Create the application-ref entry in the domain.xml
    ConfigCode code = new ConfigCode() {

        @Override
        public Object run(ConfigBeanProxy... proxies) throws PropertyVetoException, TransactionFailure {
            // Get the system application config
            SystemApplications systemApplications = (SystemApplications) proxies[0];
            Application application = null;
            for (Application systemApplication : systemApplications.getApplications()) {
                if (systemApplication.getName().equals(applicationName)) {
                    application = systemApplication;
                    break;
                }
            }
            if (application == null) {
                throw new IllegalStateException("The Rest Monitoring application has no system app entry!");
            }
            // 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);
    // Update the adapter state
    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) Application(com.sun.enterprise.config.serverbeans.Application) ApplicationRef(com.sun.enterprise.config.serverbeans.ApplicationRef)

Example 9 with Application

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

the class RestMonitoringLoader method reconfigureSystemApplication.

private void reconfigureSystemApplication() throws Exception {
    Application systemApplication = restMonitoringAdapter.getSystemApplicationConfig();
    LOGGER.log(Level.FINE, "Reconfiguring the Rest Monitoring Application...");
    // Reconfigure the system-application entry in the domain.xml
    ConfigCode code = new ConfigCode() {

        @Override
        public Object run(ConfigBeanProxy... proxies) throws PropertyVetoException, TransactionFailure {
            Application systemApplication = (Application) proxies[0];
            systemApplication.setContextRoot(contextRoot);
            return true;
        }
    };
    ConfigSupport.apply(code, systemApplication);
    LOGGER.log(Level.FINE, "Rest Monitoring Application Reconfigured.");
}
Also used : ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) ConfigCode(org.jvnet.hk2.config.ConfigCode) Application(com.sun.enterprise.config.serverbeans.Application)

Example 10 with Application

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

the class RestMonitoringLoader method loadApplication.

/**
 * Loads the application
 */
private void loadApplication() {
    ApplicationRegistry appRegistry = habitat.getService(ApplicationRegistry.class);
    ApplicationInfo appInfo = appRegistry.get(applicationName);
    if (appInfo != null && appInfo.isLoaded()) {
        LOGGER.log(Level.FINE, "Rest Monitoring Application already loaded.");
        return;
    }
    Application config = null;
    if (dynamicStart) {
        config = restMonitoringAdapter.getSystemApplicationConfig(contextRoot);
    } else {
        config = restMonitoringAdapter.getSystemApplicationConfig();
    }
    if (config == null) {
        throw new IllegalStateException("The Rest Monitoring application has no system app entry!");
    }
    // Load the Rest Monitoring Application
    String instanceName = serverEnv.getInstanceName();
    ApplicationRef ref = domain.getApplicationRefInServer(instanceName, applicationName);
    habitat.getService(ApplicationLoaderService.class).processApplication(config, ref);
    // Mark as registered
    restMonitoringAdapter.setAppRegistered(true);
    LOGGER.log(Level.FINE, "Rest Monitoring Application Loaded.");
}
Also used : ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) Application(com.sun.enterprise.config.serverbeans.Application) ApplicationRef(com.sun.enterprise.config.serverbeans.ApplicationRef) ApplicationLoaderService(com.sun.enterprise.v3.server.ApplicationLoaderService)

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