Search in sources :

Example 1 with Engine

use of com.sun.enterprise.config.serverbeans.Engine 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 2 with Engine

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

the class ApplicationInfo method save.

/**
 * Saves its state to the configuration. this method must be called within a transaction
 * to the configured Application instance.
 *
 * @param app the application being persisted
 */
public void save(Application app) throws TransactionFailure, PropertyVetoException {
    for (EngineRef ref : engines) {
        Engine engine = app.createChild(Engine.class);
        app.getEngine().add(engine);
        ref.save(engine);
    }
    for (ModuleInfo module : modules) {
        Module modConfig = app.getModule(module.getName());
        if (modConfig == null) {
            // not a JavaEE module, create it here
            modConfig = app.createChild(Module.class);
            modConfig.setName(module.getName());
            app.getModule().add(modConfig);
        }
        module.save(modConfig);
    }
}
Also used : Module(com.sun.enterprise.config.serverbeans.Module) Engine(com.sun.enterprise.config.serverbeans.Engine)

Example 3 with Engine

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

the class ModuleInfo method save.

/**
 * Saves its state to the configuration. this method must be called within a transaction
 * to the configured module instance.
 *
 * @param module the module being persisted
 */
public void save(Module module) throws TransactionFailure, PropertyVetoException {
    // write out the module properties only for composite app
    if (Boolean.valueOf(moduleProps.getProperty(ServerTags.IS_COMPOSITE))) {
        moduleProps.remove(ServerTags.IS_COMPOSITE);
        for (Iterator itr = moduleProps.keySet().iterator(); itr.hasNext(); ) {
            String propName = (String) itr.next();
            Property prop = module.createChild(Property.class);
            module.getProperty().add(prop);
            prop.setName(propName);
            prop.setValue(moduleProps.getProperty(propName));
        }
    }
    for (EngineRef ref : _getEngineRefs()) {
        Engine engine = module.createChild(Engine.class);
        module.getEngines().add(engine);
        ref.save(engine);
    }
}
Also used : Iterator(java.util.Iterator) Property(org.jvnet.hk2.config.types.Property) Engine(com.sun.enterprise.config.serverbeans.Engine)

Example 4 with Engine

use of com.sun.enterprise.config.serverbeans.Engine 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"));
                Module 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 : Sniffer(org.glassfish.api.container.Sniffer) ActionReport(org.glassfish.api.ActionReport) EngineInfo(org.glassfish.internal.data.EngineInfo) Module(com.sun.enterprise.module.Module) Application(com.sun.enterprise.config.serverbeans.Application) Engine(com.sun.enterprise.config.serverbeans.Engine)

Example 5 with Engine

use of com.sun.enterprise.config.serverbeans.Engine 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

Engine (com.sun.enterprise.config.serverbeans.Engine)5 Module (com.sun.enterprise.config.serverbeans.Module)3 Application (com.sun.enterprise.config.serverbeans.Application)2 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)1 Server (com.sun.enterprise.config.serverbeans.Server)1 SystemApplications (com.sun.enterprise.config.serverbeans.SystemApplications)1 Module (com.sun.enterprise.module.Module)1 PropertyVetoException (java.beans.PropertyVetoException)1 Iterator (java.util.Iterator)1 ActionReport (org.glassfish.api.ActionReport)1 Sniffer (org.glassfish.api.container.Sniffer)1 EngineInfo (org.glassfish.internal.data.EngineInfo)1 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)1 ConfigCode (org.jvnet.hk2.config.ConfigCode)1 Property (org.jvnet.hk2.config.types.Property)1