Search in sources :

Example 1 with AdminService

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

the class FieldsValidationTest method testNotNullField.

@Test
public void testNotNullField() {
    AdminService admin = super.getHabitat().getService(AdminService.class);
    Assert.assertNotNull(admin);
    try {
        ConfigSupport.apply(new SingleConfigCode<AdminService>() {

            @Override
            public Object run(AdminService wAdmin) throws PropertyVetoException, TransactionFailure {
                wAdmin.setDasConfig(null);
                return null;
            }
        }, admin);
        Assert.fail("Exception not raised when setting a @NotNull annotated field with null");
    } catch (TransactionFailure e) {
        if (e.getCause() != null) {
            Assert.assertTrue(e.getCause() instanceof ConstraintViolationException);
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) AdminService(com.sun.enterprise.config.serverbeans.AdminService) ConstraintViolationException(javax.validation.ConstraintViolationException) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 2 with AdminService

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

the class DirectCreationTest method doTest.

public void doTest() throws TransactionFailure {
    AdminService service = habitat.getService(AdminService.class);
    ConfigBean serviceBean = (ConfigBean) ConfigBean.unwrap(service);
    Class<?>[] subTypes = null;
    try {
        subTypes = ConfigSupport.getSubElementsTypes(serviceBean);
    } catch (ClassNotFoundException e) {
        // To change body of catch statement use File | Settings | File Templates.
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    ConfigSupport support = getBaseServiceLocator().getService(ConfigSupport.class);
    assertNotNull("ConfigSupport not found", support);
    for (Class<?> subType : subTypes) {
        // TODO:  JL force compilation error to mark this probably edit point for grizzly config
        if (subType.getName().endsWith("DasConfig")) {
            Map<String, String> configChanges = new HashMap<String, String>();
            configChanges.put("dynamic-reload-enabled", "true");
            configChanges.put("autodeploy-dir", "funky-dir");
            support.createAndSet(serviceBean, (Class<? extends ConfigBeanProxy>) subType, configChanges);
            break;
        }
    }
    support.createAndSet(serviceBean, DasConfig.class, (List) null);
    List<AttributeChanges> profilerChanges = new ArrayList<AttributeChanges>();
    String[] values = { "-Xmx512m", "-RFtrq", "-Xmw24" };
    ConfigSupport.MultipleAttributeChanges multipleChanges = new ConfigSupport.MultipleAttributeChanges("jvm-options", values);
    String[] values1 = { "profile" };
    ConfigSupport.MultipleAttributeChanges multipleChanges1 = new ConfigSupport.MultipleAttributeChanges("name", values1);
    profilerChanges.add(multipleChanges);
    profilerChanges.add(multipleChanges1);
    support.createAndSet((ConfigBean) ConfigBean.unwrap(habitat.<JavaConfig>getService(JavaConfig.class)), Profiler.class, profilerChanges);
}
Also used : AdminService(com.sun.enterprise.config.serverbeans.AdminService) ConfigSupport(org.jvnet.hk2.config.ConfigSupport) AttributeChanges(org.jvnet.hk2.config.AttributeChanges) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ConfigBean(org.jvnet.hk2.config.ConfigBean) JavaConfig(com.sun.enterprise.config.serverbeans.JavaConfig)

Example 3 with AdminService

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

the class CreateSsl method addSslToJMXConnector.

private void addSslToJMXConnector(Config config, ActionReport report) {
    AdminService adminService = config.getAdminService();
    // ensure we have the specified listener
    JmxConnector jmxConnector = null;
    for (JmxConnector jmxConn : adminService.getJmxConnector()) {
        if (jmxConn.getName().equals(listenerId)) {
            jmxConnector = jmxConn;
        }
    }
    if (jmxConnector == null) {
        report.setMessage(localStrings.getLocalString("create.ssl.jmx.notfound", "JMX Connector named {0} to which this ssl element is " + "being added does not exist.", listenerId));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    if (jmxConnector.getSsl() != null) {
        report.setMessage(localStrings.getLocalString("create.ssl.jmx.alreadyExists", "IIOP Listener named {0} to which this ssl element is " + "being added already has an ssl element.", listenerId));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    try {
        ConfigSupport.apply(new SingleConfigCode<JmxConnector>() {

            @Override
            public Object run(JmxConnector param) throws PropertyVetoException, TransactionFailure {
                Ssl newSsl = param.createChild(Ssl.class);
                populateSslElement(newSsl);
                param.setSsl(newSsl);
                return newSsl;
            }
        }, jmxConnector);
    } catch (TransactionFailure e) {
        reportError(report, e);
    }
    reportSuccess(report);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) AdminService(com.sun.enterprise.config.serverbeans.AdminService) JmxConnector(com.sun.enterprise.config.serverbeans.JmxConnector) Ssl(org.glassfish.grizzly.config.dom.Ssl)

Example 4 with AdminService

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

the class AdminEndpointDecider method setValues.

private void setValues() {
    // can't change
    asadminContextRoot = AdminAdapter.PREFIX_URI;
    // asadminHosts       = Collections.emptyList();  //asadmin is handled completely by the adapter, no VS needed
    NetworkListener nl = cfg.getAdminListener();
    ThreadPool tp = nl.findThreadPool();
    if (tp != null) {
        try {
            maxThreadPoolSize = Integer.parseInt(tp.getMaxThreadPoolSize());
        } catch (NumberFormatException ne) {
        }
    }
    String dvs = nl.findHttpProtocol().getHttp().getDefaultVirtualServer();
    guiHosts = Collections.unmodifiableList(Arrays.asList(dvs));
    // same for now
    asadminHosts = guiHosts;
    try {
        address = InetAddress.getByName(nl.getAddress());
    } catch (UnknownHostException e) {
        throw new IllegalStateException(e);
    }
    if (ServerTags.ADMIN_LISTENER_ID.equals(nl.getName())) {
        // at the root context for separate admin-listener
        guiContextRoot = "";
        try {
            port = Integer.parseInt(nl.getPort());
        } catch (NumberFormatException ne) {
            port = ADMIN_PORT;
        }
    } else {
        try {
            port = Integer.parseInt(nl.getPort());
        } catch (NumberFormatException ne) {
            // this is the last resort
            port = 8080;
        }
        // get the context root from admin-service
        AdminService as = cfg.getAdminService();
        if (as == null)
            guiContextRoot = ServerEnvironmentImpl.DEFAULT_ADMIN_CONSOLE_CONTEXT_ROOT;
        else
            setGuiContextRootFromAdminService(as);
    }
}
Also used : AdminService(com.sun.enterprise.config.serverbeans.AdminService) UnknownHostException(java.net.UnknownHostException) ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Aggregations

AdminService (com.sun.enterprise.config.serverbeans.AdminService)4 PropertyVetoException (java.beans.PropertyVetoException)2 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)2 JavaConfig (com.sun.enterprise.config.serverbeans.JavaConfig)1 JmxConnector (com.sun.enterprise.config.serverbeans.JmxConnector)1 ConfigApiTest (com.sun.enterprise.configapi.tests.ConfigApiTest)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ConstraintViolationException (javax.validation.ConstraintViolationException)1 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)1 Ssl (org.glassfish.grizzly.config.dom.Ssl)1 ThreadPool (org.glassfish.grizzly.config.dom.ThreadPool)1 Test (org.junit.Test)1 AttributeChanges (org.jvnet.hk2.config.AttributeChanges)1 ConfigBean (org.jvnet.hk2.config.ConfigBean)1 ConfigSupport (org.jvnet.hk2.config.ConfigSupport)1