Search in sources :

Example 1 with ObjectParameter

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

the class TestCollectionValue method getCollection.

private List getCollection(String... profiles) throws Exception {
    RootContainer config = getKernel("collection-configuration.xml", profiles);
    InitParamsHolder holder = (InitParamsHolder) config.getComponentInstanceOfType(InitParamsHolder.class);
    InitParams params = holder.getParams();
    ObjectParameter op = params.getObjectParam("test.configuration");
    ConfigParam cp = (ConfigParam) op.getObject();
    return cp.getRole();
}
Also used : InitParams(org.exoplatform.container.xml.InitParams) ObjectParameter(org.exoplatform.container.xml.ObjectParameter) RootContainer(org.exoplatform.container.RootContainer)

Example 2 with ObjectParameter

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

the class TestCollectionValue method getConfiguredCollection.

private XMLCollection getConfiguredCollection(String... profiles) throws Exception {
    Configuration config = getConfiguration("collection-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 3 with ObjectParameter

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

the class TestCacheService method testCacheFactory.

public void testCacheFactory() throws Exception {
    InitParams params = new InitParams();
    ObjectParameter param = new ObjectParameter();
    param.setName("NoImpl");
    ExoCacheConfig config = new ExoCacheConfig();
    config.setName(param.getName());
    param.setObject(config);
    params.addParameter(param);
    param = new ObjectParameter();
    param.setName("KnownImpl");
    config = new ExoCacheConfig();
    config.setName(param.getName());
    config.setImplementation("org.exoplatform.services.cache.concurrent.ConcurrentFIFOExoCache");
    param.setObject(config);
    params.addParameter(param);
    param = new ObjectParameter();
    param.setName("UnKnownImpl");
    config = new ExoCacheConfig();
    config.setName(param.getName());
    config.setImplementation("fakeImpl");
    param.setObject(config);
    params.addParameter(param);
    param = new ObjectParameter();
    param.setName("UnKnownImplButCorrectFQN");
    config = new ExoCacheConfig();
    config.setName(param.getName());
    config.setImplementation("java.lang.String");
    param.setObject(config);
    params.addParameter(param);
    param = new ObjectParameter();
    param.setName("NoImpl-MyExoCacheConfig");
    config = new MyExoCacheConfig();
    config.setName(param.getName());
    param.setObject(config);
    params.addParameter(param);
    param = new ObjectParameter();
    param.setName("KnownImpl-MyExoCacheConfig");
    config = new MyExoCacheConfig();
    config.setName(param.getName());
    config.setImplementation("org.exoplatform.services.cache.FIFOExoCache");
    param.setObject(config);
    params.addParameter(param);
    param = new ObjectParameter();
    param.setName("UnKnownImpl-MyExoCacheConfig");
    config = new MyExoCacheConfig();
    config.setName(param.getName());
    config.setImplementation("fakeImpl");
    param.setObject(config);
    params.addParameter(param);
    param = new ObjectParameter();
    param.setName("UnKnownImplButCorrectFQN-MyExoCacheConfig");
    config = new MyExoCacheConfig();
    config.setName(param.getName());
    config.setImplementation("java.lang.String");
    param.setObject(config);
    params.addParameter(param);
    CacheService cs = new CacheServiceImpl(params, new MyExoCacheFactory());
    assertTrue("Expected type MyExoCache found " + cs.getCacheInstance("NoImpl").getClass(), cs.getCacheInstance("NoImpl") instanceof MyExoCache);
    assertTrue("Expected type ConcurrentFIFOExoCache found " + cs.getCacheInstance("KnownImpl").getClass(), cs.getCacheInstance("KnownImpl") instanceof ConcurrentFIFOExoCache);
    assertTrue("Expected type MyExoCache found " + cs.getCacheInstance("UnKnownImpl").getClass(), cs.getCacheInstance("UnKnownImpl") instanceof MyExoCache);
    assertTrue("Expected type MyExoCache found " + cs.getCacheInstance("UnKnownImplButCorrectFQN").getClass(), cs.getCacheInstance("UnKnownImplButCorrectFQN") instanceof MyExoCache);
    assertTrue("Expected type MyExoCache found " + cs.getCacheInstance("NoImpl-MyExoCacheConfig").getClass(), cs.getCacheInstance("NoImpl-MyExoCacheConfig") instanceof MyExoCache);
    assertTrue("Expected type MyExoCache found " + cs.getCacheInstance("KnownImpl-MyExoCacheConfig").getClass(), cs.getCacheInstance("KnownImpl-MyExoCacheConfig") instanceof MyExoCache);
    assertTrue("Expected type MyExoCache found " + cs.getCacheInstance("UnKnownImpl-MyExoCacheConfig").getClass(), cs.getCacheInstance("UnKnownImpl-MyExoCacheConfig") instanceof MyExoCache);
    assertTrue("Expected type MyExoCache found " + cs.getCacheInstance("UnKnownImplButCorrectFQN-MyExoCacheConfig").getClass(), cs.getCacheInstance("UnKnownImplButCorrectFQN-MyExoCacheConfig") instanceof MyExoCache);
}
Also used : InitParams(org.exoplatform.container.xml.InitParams) ObjectParameter(org.exoplatform.container.xml.ObjectParameter) CacheServiceImpl(org.exoplatform.services.cache.impl.CacheServiceImpl) ExoCacheConfig(org.exoplatform.services.cache.ExoCacheConfig) ConcurrentFIFOExoCache(org.exoplatform.services.cache.concurrent.ConcurrentFIFOExoCache) CacheService(org.exoplatform.services.cache.CacheService)

Example 4 with ObjectParameter

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

the class TestField method getCollection.

private List getCollection(String... profiles) throws Exception {
    RootContainer config = getKernel("field-configuration.xml", profiles);
    InitParamsHolder holder = (InitParamsHolder) config.getComponentInstanceOfType(InitParamsHolder.class);
    InitParams params = holder.getParams();
    ObjectParameter op = params.getObjectParam("test.configuration");
    ConfigParam cp = (ConfigParam) op.getObject();
    return cp.getRole();
}
Also used : InitParams(org.exoplatform.container.xml.InitParams) ObjectParameter(org.exoplatform.container.xml.ObjectParameter) RootContainer(org.exoplatform.container.RootContainer)

Example 5 with ObjectParameter

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

the class TestConfigurationXML method testTrimValue.

@SuppressWarnings("unchecked")
public void testTrimValue() throws Exception {
    InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("test-trim-value.xml");
    assertNotNull(is);
    try {
        IBindingFactory bfact = BindingDirectory.getFactory(XMLObject.class);
        IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
        Configuration conf = (Configuration) uctx.unmarshalDocument(is, null);
        assertNotNull(conf);
        Iterator it = conf.getContainerLifecyclePluginIterator();
        assertNotNull(it);
        assertTrue(it.hasNext());
        ContainerLifecyclePlugin conlp = (ContainerLifecyclePlugin) it.next();
        assertEquals("container-lifecycle-plugin-type", conlp.getType());
        assertNotNull(conlp.getInitParams());
        assertEquals("container-lifecycle-plugin-value-param-value", (conlp.getInitParams().getValueParam("container-lifecycle-plugin-value-param-name")).getValue());
        it = conf.getComponentLifecyclePluginIterator();
        assertNotNull(it);
        assertTrue(it.hasNext());
        ComponentLifecyclePlugin comlp = (ComponentLifecyclePlugin) it.next();
        assertEquals("component-lifecycle-plugin", comlp.getType());
        ManageableComponents mc = comlp.getManageableComponents();
        assertNotNull(mc);
        assertEquals("manageable-components-component-type", mc.getComponentsType().get(0));
        ValuesParam valuesParam = comlp.getInitParams().getValuesParam("component-lifecycle-plugin-values-param-name");
        assertNotNull(valuesParam);
        assertNotNull(valuesParam.getValues());
        assertTrue(valuesParam.getValues().contains("component-lifecycle-plugin-values-param-value1"));
        assertTrue(valuesParam.getValues().contains("component-lifecycle-plugin-values-param-value2"));
        Component c = conf.getComponent("component-key1");
        assertNotNull(c);
        assertEquals("component-type1", c.getType());
        PropertiesParam propertiesParam = c.getInitParams().getPropertiesParam("component-key1-properties-param-name");
        assertNotNull(propertiesParam);
        assertEquals("component-key1-properties-param-prop-value", propertiesParam.getProperty("component-key1-properties-param-prop-name"));
        c = conf.getComponent("component-type2");
        assertNotNull(c);
        ObjectParameter objectParameter = c.getInitParams().getObjectParam("component-key2-object-param-name");
        assertNotNull(objectParameter);
        MyObject o = (MyObject) objectParameter.getObject();
        assertNotNull(o);
        assertEquals("string-value", o.field1);
        assertEquals(1, o.field2);
        assertEquals(1l, o.field3);
        assertEquals(1d, o.field4);
        assertEquals(true, o.field5);
        assertNotNull(o.field6);
        assertEquals("entry-value", o.field6.get("entry-name"));
        assertNotNull(o.field7);
        assertTrue(o.field7.contains("string-value"));
        assertNotNull(o.field8);
        assertEquals(1, o.field8[0]);
        List list = c.getComponentPlugins();
        assertNotNull(list);
        assertFalse(list.isEmpty());
        ComponentPlugin cp = (ComponentPlugin) list.get(0);
        assertEquals("component-plugins-name", cp.getName());
        assertEquals("set-method-name", cp.getSetMethod());
        assertEquals("component-plugins-type", cp.getType());
        assertEquals(1, cp.getPriority());
        it = conf.getExternalComponentPluginsIterator();
        assertNotNull(it);
        assertTrue(it.hasNext());
        ExternalComponentPlugins ecps = (ExternalComponentPlugins) it.next();
        assertEquals("target-component-name", ecps.getTargetComponent());
        list = ecps.getComponentPlugins();
        assertNotNull(list);
        assertFalse(list.isEmpty());
        cp = (ComponentPlugin) list.get(0);
        assertEquals("component-plugins-name", cp.getName());
        assertEquals("set-method-name", cp.getSetMethod());
        assertEquals("component-plugins-type", cp.getType());
        assertEquals(1, cp.getPriority());
        list = conf.getImports();
        assertNotNull(list);
        assertFalse(list.isEmpty());
        assertEquals("import-value", list.get(0));
        list = conf.getRemoveConfiguration();
        assertNotNull(list);
        assertFalse(list.isEmpty());
        assertEquals("remove-configuration-value", list.get(0));
    } finally {
        try {
            is.close();
        } catch (Exception e) {
        // ignore me
        }
    }
}
Also used : ComponentPlugin(org.exoplatform.container.xml.ComponentPlugin) Configuration(org.exoplatform.container.xml.Configuration) IBindingFactory(org.jibx.runtime.IBindingFactory) InputStream(java.io.InputStream) PropertiesParam(org.exoplatform.container.xml.PropertiesParam) ContainerLifecyclePlugin(org.exoplatform.container.xml.ContainerLifecyclePlugin) IUnmarshallingContext(org.jibx.runtime.IUnmarshallingContext) ComponentLifecyclePlugin(org.exoplatform.container.xml.ComponentLifecyclePlugin) ValuesParam(org.exoplatform.container.xml.ValuesParam) ExternalComponentPlugins(org.exoplatform.container.xml.ExternalComponentPlugins) ObjectParameter(org.exoplatform.container.xml.ObjectParameter) Iterator(java.util.Iterator) List(java.util.List) ManageableComponents(org.exoplatform.container.xml.ManageableComponents) Component(org.exoplatform.container.xml.Component)

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