Search in sources :

Example 6 with ObjectParameter

use of org.exoplatform.container.xml.ObjectParameter in project kernel by exoplatform.

the class PortalContainerConfig method create.

/**
 * Create the default {@link PortalContainerDefinition} corresponding to the given parameters
 * @param params the parameter to initialize
 */
private PortalContainerDefinition create(InitParams params) {
    ObjectParameter oDpd = null;
    if (params != null) {
        oDpd = params.getObjectParam("default.portal.definition");
    }
    PortalContainerDefinition def = null;
    if (oDpd != null) {
        // A default portal definition has been found
        final Object o = oDpd.getObject();
        if (o instanceof PortalContainerDefinition) {
            // The nested object is of the right type
            def = (PortalContainerDefinition) o;
        } else {
            // The nested object is not of the right type, thus it will be ignored
            LOG.warn("The object parameter 'default.portal.definition' should be of type " + PortalContainerDefinition.class);
        }
    }
    if (def == null) {
        def = new PortalContainerDefinition();
    }
    initName(params, def);
    initRestContextName(params, def);
    initRealmName(params, def);
    initializeSettings(def, false);
    return def;
}
Also used : ObjectParameter(org.exoplatform.container.xml.ObjectParameter)

Example 7 with ObjectParameter

use of org.exoplatform.container.xml.ObjectParameter in project kernel by exoplatform.

the class TestConfigurationService method testConfigurationService.

public void testConfigurationService(InitParams params) throws Exception {
    ObjectParameter objParam = params.getObjectParam("new.user.configuration");
    objParam.getObject();
}
Also used : ObjectParameter(org.exoplatform.container.xml.ObjectParameter)

Example 8 with ObjectParameter

use of org.exoplatform.container.xml.ObjectParameter in project kernel by exoplatform.

the class TestExoCacheFactoryImpl method testArguments.

public void testArguments() throws Exception {
    try {
        new ExoCacheFactoryImpl(pc.getContext(), null);
        fail("An IllegalArgumentException should occur");
    } catch (IllegalArgumentException e) {
    // OK
    }
    try {
        new ExoCacheFactoryImpl(pc.getContext(), new InitParams());
        fail("An IllegalArgumentException should occur");
    } catch (IllegalArgumentException e) {
    // OK
    }
    InitParams params;
    try {
        params = new InitParams();
        ValueParam vp = new ValueParam();
        vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
        params.addParam(vp);
        new ExoCacheFactoryImpl(pc.getContext(), params);
        fail("An IllegalArgumentException should occur");
    } catch (IllegalArgumentException e) {
    // OK
    }
    try {
        params = new InitParams();
        ValueParam vp = new ValueParam();
        vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
        vp.setValue("");
        params.addParam(vp);
        new ExoCacheFactoryImpl(pc.getContext(), params);
        fail("An IllegalArgumentException should occur");
    } catch (IllegalArgumentException e) {
    // OK
    }
    try {
        params = new InitParams();
        ValueParam vp = new ValueParam();
        vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
        vp.setValue("localhost:11211");
        params.addParam(vp);
        new ExoCacheFactoryImpl(pc.getContext(), params);
    } catch (Exception e) {
        fail("No exception was expected");
    }
    try {
        params = new InitParams();
        ValueParam vp = new ValueParam();
        vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
        vp.setValue("localhost:11211");
        params.addParam(vp);
        ObjectParameter op = new ObjectParameter();
        op.setName(ExoCacheFactoryImpl.CONNECTION_FACTORY_CREATOR);
        op.setObject(new Object());
        params.addParam(op);
        new ExoCacheFactoryImpl(pc.getContext(), params);
        fail("An IllegalArgumentException should occur");
    } catch (IllegalArgumentException e) {
    // OK
    }
    try {
        params = new InitParams();
        ValueParam vp = new ValueParam();
        vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
        vp.setValue("localhost:11211");
        params.addParam(vp);
        ObjectParameter op = new ObjectParameter();
        op.setName(ExoCacheFactoryImpl.CONNECTION_FACTORY_CREATOR);
        op.setObject(new BinaryConnectionFactoryCreator());
        params.addParam(op);
        new ExoCacheFactoryImpl(pc.getContext(), params);
    } catch (Exception e) {
        fail("No exception was expected");
    }
    try {
        params = new InitParams();
        ValueParam vp = new ValueParam();
        vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
        vp.setValue("localhost:11211");
        params.addParam(vp);
        ObjectParameter op = new ObjectParameter();
        op.setName(ExoCacheFactoryImpl.CONNECTION_FACTORY_CREATOR);
        op.setObject(new BinaryConnectionFactoryCreator());
        params.addParam(op);
        ValueParam vp2 = new ValueParam();
        vp2.setName(ExoCacheFactoryImpl.DEFAULT_EXPIRATION_TIMEOUT);
        vp2.setValue("foo");
        params.addParam(vp2);
        new ExoCacheFactoryImpl(pc.getContext(), params);
        fail("An exception was expected");
    } catch (Exception e) {
    // OK
    }
    try {
        params = new InitParams();
        ValueParam vp = new ValueParam();
        vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
        vp.setValue("localhost:11211");
        params.addParam(vp);
        ObjectParameter op = new ObjectParameter();
        op.setName(ExoCacheFactoryImpl.CONNECTION_FACTORY_CREATOR);
        op.setObject(new BinaryConnectionFactoryCreator());
        params.addParam(op);
        ValueParam vp2 = new ValueParam();
        vp2.setName(ExoCacheFactoryImpl.DEFAULT_EXPIRATION_TIMEOUT);
        vp2.setValue("1000");
        params.addParam(vp2);
        new ExoCacheFactoryImpl(pc.getContext(), params);
    } catch (Exception e) {
        fail("No exception was expected");
    }
}
Also used : InitParams(org.exoplatform.container.xml.InitParams) ObjectParameter(org.exoplatform.container.xml.ObjectParameter) ValueParam(org.exoplatform.container.xml.ValueParam)

Example 9 with ObjectParameter

use of org.exoplatform.container.xml.ObjectParameter in project kernel by exoplatform.

the class TestField method getConfiguredCollection.

private XMLCollection getConfiguredCollection(String... profiles) throws Exception {
    Configuration config = getConfiguration("field-configuration.xml", profiles);
    Component a = config.getComponent(InitParamsHolder.class.getName());
    ObjectParameter op = a.getInitParams().getObjectParam("test.configuration");
    XMLObject o = op.getXMLObject();
    XMLField xf = o.getField("role");
    return xf.getCollection();
}
Also used : XMLField(org.exoplatform.xml.object.XMLField) Configuration(org.exoplatform.container.xml.Configuration) ObjectParameter(org.exoplatform.container.xml.ObjectParameter) XMLObject(org.exoplatform.xml.object.XMLObject) Component(org.exoplatform.container.xml.Component)

Example 10 with ObjectParameter

use of org.exoplatform.container.xml.ObjectParameter in project kernel by exoplatform.

the class TestConfigurationXML method testSystemPropertyResolving.

public void testSystemPropertyResolving() throws Exception {
    System.setProperty("c_value", "c_external_value");
    System.setProperty("d_value", "d_external_value");
    System.setProperty("false_value", "false");
    System.setProperty("true_value", "true");
    System.setProperty("FALSE_value", "FALSE");
    System.setProperty("TRUE_value", "TRUE");
    System.setProperty("integer_value", "5");
    System.setProperty("long_value", "41");
    System.setProperty("double_value", "172.5");
    // 
    IBindingFactory bfact = BindingDirectory.getFactory(XMLObject.class);
    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    URL url = TestConfigurationXML.class.getResource("../../../../test-resolved-property.xml");
    Configuration conf = (Configuration) uctx.unmarshalDocument(url.openStream(), null);
    assertNotNull(conf);
    // 
    Component component = conf.getComponent("component");
    assertNotNull(component);
    // 
    assertValueParam("a_value", component, "a");
    assertValueParam("${b_value}", component, "b");
    assertValueParam("c_external_value", component, "c");
    assertValueParam("_d_external_value_", component, "d");
    // 
    assertPropertyParam("a_value", component, "e", "e_a");
    assertPropertyParam("${b_value}", component, "e", "e_b");
    assertPropertyParam("c_external_value", component, "e", "e_c");
    assertPropertyParam("_d_external_value_", component, "e", "e_d");
    // 
    ObjectParameter o = component.getInitParams().getObjectParam("f");
    assertNotNull(o);
    Person p = (Person) o.getObject();
    assertNotNull(p);
    assertEquals("a_value", p.address_a);
    assertEquals("${b_value}", p.address_b);
    assertEquals("c_external_value", p.address_c);
    assertEquals("_d_external_value_", p.address_d);
    assertEquals(true, p.male_a);
    assertEquals(false, p.male_b);
    assertEquals(true, p.male_c);
    assertEquals(false, p.male_d);
    assertEquals(true, p.male_e);
    assertEquals(false, p.male_f);
    assertEquals(4, p.age_a);
    assertEquals(5, p.age_b);
    assertEquals(40, p.weight_a);
    assertEquals(41, p.weight_b);
    assertEquals(172.4D, p.size_a);
    assertEquals(172.5D, p.size_b);
}
Also used : IUnmarshallingContext(org.jibx.runtime.IUnmarshallingContext) Configuration(org.exoplatform.container.xml.Configuration) IBindingFactory(org.jibx.runtime.IBindingFactory) ObjectParameter(org.exoplatform.container.xml.ObjectParameter) Component(org.exoplatform.container.xml.Component) URL(java.net.URL)

Aggregations

ObjectParameter (org.exoplatform.container.xml.ObjectParameter)10 Component (org.exoplatform.container.xml.Component)4 Configuration (org.exoplatform.container.xml.Configuration)4 InitParams (org.exoplatform.container.xml.InitParams)4 RootContainer (org.exoplatform.container.RootContainer)2 XMLField (org.exoplatform.xml.object.XMLField)2 XMLObject (org.exoplatform.xml.object.XMLObject)2 IBindingFactory (org.jibx.runtime.IBindingFactory)2 IUnmarshallingContext (org.jibx.runtime.IUnmarshallingContext)2 InputStream (java.io.InputStream)1 URL (java.net.URL)1 Iterator (java.util.Iterator)1 List (java.util.List)1 ComponentLifecyclePlugin (org.exoplatform.container.xml.ComponentLifecyclePlugin)1 ComponentPlugin (org.exoplatform.container.xml.ComponentPlugin)1 ContainerLifecyclePlugin (org.exoplatform.container.xml.ContainerLifecyclePlugin)1 ExternalComponentPlugins (org.exoplatform.container.xml.ExternalComponentPlugins)1 ManageableComponents (org.exoplatform.container.xml.ManageableComponents)1 PropertiesParam (org.exoplatform.container.xml.PropertiesParam)1 ValueParam (org.exoplatform.container.xml.ValueParam)1