Search in sources :

Example 21 with ConfigBean

use of org.jvnet.hk2.config.ConfigBean in project Payara by payara.

the class ConfigConfigSource method deleteValue.

public boolean deleteValue(String propertyName) throws TransactionFailure {
    boolean result = false;
    Config config = domainConfiguration.getConfigs().getConfigByName(configurationName);
    if (config != null) {
        for (Property object : config.getProperty()) {
            if ((PROPERTY_PREFIX + propertyName).equals(object.getName())) {
                ConfigSupport.deleteChild((ConfigBean) ConfigBean.unwrap(config), (ConfigBean) ConfigBean.unwrap(object));
                result = true;
            }
        }
    }
    return result;
}
Also used : Config(com.sun.enterprise.config.serverbeans.Config) Property(org.jvnet.hk2.config.types.Property)

Example 22 with ConfigBean

use of org.jvnet.hk2.config.ConfigBean in project Payara by payara.

the class SimpleDocument method make.

@Override
public ConfigBean make(final ServiceLocator habitat, XMLStreamReader xmlStreamReader, ConfigBean dom, ConfigModel configModel) {
    ConfigBean configBean = new ConfigBean(habitat, this, dom, configModel, xmlStreamReader);
    configBean.addInterceptor(Object.class, new OnDeleteCascade());
    return configBean;
}
Also used : OnDeleteCascade(org.jvnet.hk2.config.OnDeleteCascade) ConfigBean(org.jvnet.hk2.config.ConfigBean)

Example 23 with ConfigBean

use of org.jvnet.hk2.config.ConfigBean in project Payara by payara.

the class ReferenceConstrainTest method doChangeToInValidPool.

@Test
public void doChangeToInValidPool() throws TransactionFailure {
    Domain domain = habitat.getService(Domain.class);
    // Find JdbcResource to chenge its values
    Iterator<JdbcResource> iterator = domain.getResources().getResources(JdbcResource.class).iterator();
    JdbcResource jdbc = null;
    while (iterator.hasNext()) {
        JdbcResource res = iterator.next();
        if ("H2Pool".equals(res.getPoolName())) {
            jdbc = res;
            break;
        }
    }
    assertNotNull(jdbc);
    ConfigBean poolConfig = (ConfigBean) ConfigBean.unwrap(jdbc);
    Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
    Map<String, String> configChanges = new HashMap<String, String>();
    configChanges.put("pool-name", "WrongPointer");
    changes.put(poolConfig, configChanges);
    try {
        ConfigSupport cs = getHabitat().getService(ConfigSupport.class);
        cs.apply(changes);
        fail("Can not reach this point");
    } catch (TransactionFailure tf) {
        ConstraintViolationException cv = findConstrViolation(tf);
        // cv.printStackTrace(System.out);
        assertNotNull(cv);
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) JdbcResource(org.glassfish.jdbc.config.JdbcResource) ConfigSupport(org.jvnet.hk2.config.ConfigSupport) HashMap(java.util.HashMap) ConstraintViolationException(javax.validation.ConstraintViolationException) ConfigBean(org.jvnet.hk2.config.ConfigBean) Domain(com.sun.enterprise.config.serverbeans.Domain) HashMap(java.util.HashMap) Map(java.util.Map) ConfigApiTest(org.glassfish.jdbcruntime.config.ConfigApiTest) Test(org.junit.Test)

Example 24 with ConfigBean

use of org.jvnet.hk2.config.ConfigBean in project Payara by payara.

the class DynamicWebServletRegistrationImpl method configureMiscSettings.

/**
 * Configure miscellaneous settings such as the pool size for
 * single threaded servlets, specifying a temporary directory other
 * than the default etc.
 *
 * Since the work directory is used when configuring the session manager
 * persistence settings, this method must be invoked prior to
 * <code>configureSessionSettings</code>.
 *
 * Properties are inherited from VirtualServer and may be overridden by configuration from sun-web.xml
 */
void configureMiscSettings(final VirtualServer vs, final String contextPath) {
    for (final Property prop : vs.getProperties()) {
        final String name = prop.getName();
        final String value = prop.getValue();
        configureProperty(vs, contextPath, name, value);
    }
    // sen-web.xml preserved for backward compatibility
    final SunWebAppImpl configBean = getIasWebAppConfigBean();
    if (configBean != null && configBean.sizeWebProperty() > 0) {
        for (final WebProperty webProperty : configBean.getWebProperty()) {
            final String name = webProperty.getAttributeValue("name");
            final String value = webProperty.getAttributeValue("value");
            configureProperty(vs, contextPath, name, value);
        }
    }
}
Also used : SunWebAppImpl(org.glassfish.web.deployment.runtime.SunWebAppImpl) WebProperty(org.glassfish.web.deployment.runtime.WebProperty) Property(org.jvnet.hk2.config.types.Property) WebProperty(org.glassfish.web.deployment.runtime.WebProperty)

Example 25 with ConfigBean

use of org.jvnet.hk2.config.ConfigBean in project Payara by payara.

the class ReferenceConstrainTest method doChangeToValidPool.

// @Ignore
@Test
public void doChangeToValidPool() throws TransactionFailure {
    Domain domain = habitat.getService(Domain.class);
    // Find JdbcResource to chenge its values
    Iterator<JdbcResource> iterator = domain.getResources().getResources(JdbcResource.class).iterator();
    JdbcResource jdbc = null;
    while (iterator.hasNext()) {
        JdbcResource res = iterator.next();
        if ("__TimerPool".equals(res.getPoolName())) {
            jdbc = res;
            break;
        }
    }
    assertNotNull(jdbc);
    ConfigBean poolConfig = (ConfigBean) ConfigBean.unwrap(jdbc);
    Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
    Map<String, String> configChanges = new HashMap<String, String>();
    configChanges.put("pool-name", "H2Pool");
    changes.put(poolConfig, configChanges);
    try {
        ConfigSupport cs = getHabitat().getService(ConfigSupport.class);
        cs.apply(changes);
    } catch (TransactionFailure tf) {
        fail();
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) JdbcResource(org.glassfish.jdbc.config.JdbcResource) ConfigSupport(org.jvnet.hk2.config.ConfigSupport) HashMap(java.util.HashMap) ConfigBean(org.jvnet.hk2.config.ConfigBean) Domain(com.sun.enterprise.config.serverbeans.Domain) HashMap(java.util.HashMap) Map(java.util.Map) ConfigApiTest(org.glassfish.jdbcruntime.config.ConfigApiTest) Test(org.junit.Test)

Aggregations

ConfigBean (org.jvnet.hk2.config.ConfigBean)28 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)21 HashMap (java.util.HashMap)18 Map (java.util.Map)15 ConfigSupport (org.jvnet.hk2.config.ConfigSupport)12 Test (org.junit.Test)11 ConfigApiTest (com.sun.enterprise.configapi.tests.ConfigApiTest)8 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)8 Property (org.jvnet.hk2.config.types.Property)8 PropertyVetoException (java.beans.PropertyVetoException)7 Method (java.lang.reflect.Method)5 ConstraintViolationException (javax.validation.ConstraintViolationException)5 Dom (org.jvnet.hk2.config.Dom)5 Cluster (com.sun.enterprise.config.serverbeans.Cluster)4 Domain (com.sun.enterprise.config.serverbeans.Domain)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 RestActionReporter (org.glassfish.admin.rest.utils.xml.RestActionReporter)4 MultiException (org.glassfish.hk2.api.MultiException)4