Search in sources :

Example 26 with Server

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

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

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

the class CreateJavaMailResourceTest method testExecuteSuccess.

/**
 * Test of execute method, of class CreateJavaMailResource.
 * asadmin create-javamail-resource --mailuser=test --mailhost=localhost
 * --fromaddress=test@sun.com mail/MyMailSession
 */
@Test
public void testExecuteSuccess() {
    parameters.set("mailhost", "localhost");
    parameters.set("mailuser", "test");
    parameters.set("fromaddress", "test@sun.com");
    parameters.set("jndi_name", "mail/MyMailSession");
    org.glassfish.resources.javamail.admin.cli.CreateJavaMailResource command = habitat.getService(org.glassfish.resources.javamail.admin.cli.CreateJavaMailResource.class);
    assertTrue(command != null);
    cr.getCommandInvocation("create-javamail-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(command);
    assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
    boolean isCreated = false;
    for (Resource resource : resources.getResources()) {
        if (resource instanceof MailResource) {
            MailResource r = (MailResource) resource;
            if (r.getJndiName().equals("mail/MyMailSession")) {
                assertEquals("localhost", r.getHost());
                assertEquals("test", r.getUser());
                assertEquals("test@sun.com", r.getFrom());
                assertEquals("true", r.getEnabled());
                assertEquals("false", r.getDebug());
                assertEquals("imap", r.getStoreProtocol());
                assertEquals("com.sun.mail.imap.IMAPStore", r.getStoreProtocolClass());
                assertEquals("smtp", r.getTransportProtocol());
                assertEquals("com.sun.mail.smtp.SMTPTransport", r.getTransportProtocolClass());
                isCreated = true;
                logger.fine("MailResource config bean mail/MyMailSession is created.");
                break;
            }
        }
    }
    assertTrue(isCreated);
    logger.fine("msg: " + context.getActionReport().getMessage());
    Servers servers = habitat.getService(Servers.class);
    boolean isRefCreated = false;
    for (Server server : servers.getServer()) {
        if (server.getName().equals(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME)) {
            for (ResourceRef ref : server.getResourceRef()) {
                if (ref.getRef().equals("mail/MyMailSession")) {
                    assertEquals("true", ref.getEnabled());
                    isRefCreated = true;
                    break;
                }
            }
        }
    }
    assertTrue(isRefCreated);
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) MailResource(org.glassfish.resources.javamail.config.MailResource) Resource(com.sun.enterprise.config.serverbeans.Resource) ResourceRef(com.sun.enterprise.config.serverbeans.ResourceRef) Servers(com.sun.enterprise.config.serverbeans.Servers) MailResource(org.glassfish.resources.javamail.config.MailResource) Test(org.junit.Test) ConfigApiTest(org.glassfish.tests.utils.ConfigApiTest)

Example 29 with Server

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

the class RestartHazelcast method isThisForMe.

private boolean isThisForMe() {
    boolean result = false;
    String instanceName = serverEnv.getInstanceName();
    if (instanceName.equals(target)) {
        result = true;
    }
    if (targetUtil.isCluster(target)) {
        List<Server> servers = targetUtil.getInstances(target);
        for (Server server : servers) {
            if (server.getName().equals(instanceName)) {
                result = true;
                break;
            }
        }
    } else if (target.equals("domain")) {
        result = true;
    }
    return result;
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server)

Example 30 with Server

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

the class ServerConfigSource method getValue.

@Override
public String getValue(String propertyName) {
    String result = null;
    Server config = domainConfiguration.getServerNamed(configurationName);
    if (config != null) {
        result = config.getPropertyValue(PROPERTY_PREFIX + propertyName);
    }
    return result;
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server)

Aggregations

Server (com.sun.enterprise.config.serverbeans.Server)101 ActionReport (org.glassfish.api.ActionReport)32 Cluster (com.sun.enterprise.config.serverbeans.Cluster)25 Domain (com.sun.enterprise.config.serverbeans.Domain)15 Node (com.sun.enterprise.config.serverbeans.Node)15 Config (com.sun.enterprise.config.serverbeans.Config)14 Properties (java.util.Properties)14 ArrayList (java.util.ArrayList)13 Test (org.junit.Test)12 PropertyVetoException (java.beans.PropertyVetoException)11 DeploymentGroup (fish.payara.enterprise.config.serverbeans.DeploymentGroup)9 ParameterMap (org.glassfish.api.admin.ParameterMap)9 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)8 File (java.io.File)8 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)8 Logger (java.util.logging.Logger)7 Map (java.util.Map)6 ServerContext (org.glassfish.internal.api.ServerContext)6