Package org.objectweb.celtix.configuration

Examples of org.objectweb.celtix.configuration.ConfigurationItemMetadata


                    && HANDLER_CHAIN_ELEM_NAME.equals(getNodeName(node))) {

                    String location = "schemas/configuration/jaxws-types.xsd";
                    TypeSchema ts = new TypeSchemaHelper(true).get(JAXWS_TYPES_URI, null, location);

                    ConfigurationItemMetadata mdi = new ConfigurationItemMetadata() {
                        public Object getDefaultValue() {
                            return null;
                        }

                        public LifecyclePolicy getLifecyclePolicy() {
View Full Code Here


        return cls.cast(obj);
    }

    public Object getObject(String name) {

        ConfigurationItemMetadata definition = model.getDefinition(name);
        if (null == definition) {
            throw new ConfigurationException(new Message("ITEM_NOT_DEFINED_EXC", BUNDLE, name));
        }

        Configuration holder = this;
        while (null != holder) {
            Object obj = getLocal(holder, name);
            if (null != obj) {
                return obj;
            }
            holder = holder.getParent();
        }
        return definition.getDefaultValue();
    }
View Full Code Here

    /**
     * Check if property is defined and validate the value.
     * Then try all providers in turn until one is found that accepts the change.
     */
    public boolean setObject(String name, Object value) {
        ConfigurationItemMetadata definition = model.getDefinition(name);
        if (null == definition) {
            throw new ConfigurationException(new Message("ITEM_NOT_DEFINED_EXC", BUNDLE, name));
        }

        // use model to validate value
        Object defaultValue = definition.getDefaultValue();
        if (defaultValue != null && !defaultValue.getClass().isAssignableFrom(value.getClass())) {
            QName type = model.getDefinition(name).getType();
            throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type));
        }

View Full Code Here

        ConfigurationMetadata model = buildMetadata("meta1.xml");
        assertEquals("http://celtix.objectweb.org/configuration/test/meta1",
                     model.getNamespaceURI());
        Collection<ConfigurationItemMetadata> definitions = model.getDefinitions();
        assertEquals(9, definitions.size());
        ConfigurationItemMetadata definition = null;
       
        definition = model.getDefinition("booleanItem");
        assertNotNull(definition);
        assertEquals("booleanItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "boolean"),
                     definition.getType());
        assertEquals(LifecyclePolicy.STATIC, definition.getLifecyclePolicy());
       
        definition = model.getDefinition("shortItem");
        assertNotNull(definition);
        assertEquals("shortItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "short"),
                     definition.getType());
       
        definition = model.getDefinition("intItem");
        assertNotNull(definition);
        assertEquals("intItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "int"),
                     definition.getType());
       
        definition = model.getDefinition("integerItem");
        assertNotNull(definition);
        assertEquals("integerItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "integer"),
                     definition.getType());
        // assertNull(definition.getDescription());
        assertEquals(LifecyclePolicy.PROCESS, definition.getLifecyclePolicy());
       
        definition = model.getDefinition("longItem");
        assertNotNull(definition);
        assertEquals("longItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "long"),
                     definition.getType());
        // assertEquals(definition.getName() + " description", definition.getDescription());
        assertEquals(LifecyclePolicy.BUS, definition.getLifecyclePolicy());
       
        definition = model.getDefinition("floatItem");
        assertNotNull(definition);
        assertEquals("floatItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "float"),
                     definition.getType());
       
        definition = model.getDefinition("doubleItem");
        assertNotNull(definition);
        assertEquals("doubleItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "double"),
                     definition.getType());
        // assertEquals(definition.getName() + " description", definition.getDescription());
        assertEquals(LifecyclePolicy.DYNAMIC, definition.getLifecyclePolicy());
       
        definition = model.getDefinition("stringItem");
        assertNotNull(definition);
        assertEquals("stringItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "string"),
                     definition.getType());
       
        definition = model.getDefinition("stringListItem");
        assertNotNull(definition);
        assertEquals("stringListItem", definition.getName());
        assertEquals(new QName(TYPES_NAMESPACE_URI, "stringListType"),
                     definition.getType());
        assertEquals(LifecyclePolicy.STATIC, definition.getLifecyclePolicy());
        assertNull(definition.getDefaultValue());
    }
View Full Code Here

    public void testDefaultValue() {       
        ConfigurationMetadata model = buildMetadata("meta8.xml");
        Collection<ConfigurationItemMetadata> definitions = model.getDefinitions();
        assertEquals(9, definitions.size());
       
        ConfigurationItemMetadata definition = null
        Object defaultValue = null;
      
        definition = model.getDefinition("booleanItem");
        defaultValue = definition.getDefaultValue();
        assertNotNull(defaultValue);
        assertEquals("java.lang.Boolean", defaultValue.getClass().getName());
        assertEquals(true, ((Boolean)defaultValue).booleanValue());
       
        definition = model.getDefinition("integerItem");
        defaultValue = definition.getDefaultValue();
        assertNotNull(defaultValue);
        assertEquals("java.math.BigInteger", defaultValue.getClass().getName());
        assertEquals(44959, ((BigInteger)defaultValue).intValue());
       
        definition = model.getDefinition("longItem");
        defaultValue = definition.getDefaultValue();
        assertNotNull(defaultValue);
        assertEquals("java.lang.Long", defaultValue.getClass().getName());
        assertEquals(-99, ((Long)defaultValue).longValue());
       
        definition = model.getDefinition("doubleItem");
        defaultValue = definition.getDefaultValue();
        assertNotNull(defaultValue);
        assertEquals("java.lang.Double", defaultValue.getClass().getName());
        assertTrue(Math.abs(1234.5678 - ((Double)defaultValue).doubleValue()) < 0.5E-5);
       
        definition = model.getDefinition("stringItem");
        defaultValue = definition.getDefaultValue();
        assertNotNull(defaultValue);
        assertEquals("java.lang.String", defaultValue.getClass().getName());
        assertEquals("\"Hello World!\"", (String)defaultValue);
       
        definition = model.getDefinition("stringListItem");
        defaultValue = definition.getDefaultValue();
        assertNotNull(defaultValue);

        assertEquals("org.objectweb.celtix.configuration.types.StringListType",
                     defaultValue.getClass().getName());
        List<String> l = ((StringListType)defaultValue).getItem();
View Full Code Here

TOP

Related Classes of org.objectweb.celtix.configuration.ConfigurationItemMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.