Package org.apache.felix.ipojo.metadata

Examples of org.apache.felix.ipojo.metadata.Element


        Assert.assertTrue(filter.accept(main));
    }

    public void testDoNotFilterOthers() throws Exception {
        Element main = new Element("test", null);
        main.addAttribute(new Attribute("name", "setPropertyName"));

        Assert.assertFalse(filter.accept(main));
    }
View Full Code Here


            public boolean accept(Element element) {
                return element.getNameSpace() != null;
            }
        });

        Element main = new Element("test", null);
        Element child = new Element("child", "uri");
        main.addElement(child);
        String rendered = renderer.render(main);
        Assert.assertEquals("test { }", rendered);

    }
View Full Code Here

        Assert.assertEquals("test { }", rendered);

    }

    public void testRenderElementWithNoNamespace() throws Exception {
        Element main = new Element("test", null);
        String rendered = renderer.render(main);
        Assert.assertEquals("test { }", rendered);
    }
View Full Code Here

        String rendered = renderer.render(main);
        Assert.assertEquals("test { }", rendered);
    }

    public void testRenderElementWithEmptyNamespace() throws Exception {
        Element main = new Element("test", "");
        String rendered = renderer.render(main);
        Assert.assertEquals("test { }", rendered);
    }
View Full Code Here

        Assert.assertEquals("test { }", rendered);
    }

    public void testRenderElementWithDefaultNamespace() throws Exception {
        // TODO Do we need to strip off default namespace ?
        Element main = new Element("test", "org.apache.felix.ipojo");
        String rendered = renderer.render(main);
        Assert.assertEquals("org.apache.felix.ipojo:test { }", rendered);
    }
View Full Code Here

        String rendered = renderer.render(main);
        Assert.assertEquals("org.apache.felix.ipojo:test { }", rendered);
    }

    public void testRenderElementWithNamespace() throws Exception {
        Element main = new Element("test", "http://felix.apache.org/ipojo/testing");
        String rendered = renderer.render(main);
        Assert.assertEquals("http://felix.apache.org/ipojo/testing:test { }", rendered);
    }
View Full Code Here

        String rendered = renderer.render(main);
        Assert.assertEquals("http://felix.apache.org/ipojo/testing:test { }", rendered);
    }

    public void testRenderElementWithNoNamespaceAttribute() throws Exception {
        Element main = new Element("test", null);
        main.addAttribute(new Attribute("name", "attribute"));
        String rendered = renderer.render(main);
        Assert.assertEquals("test { $name=\"attribute\" }", rendered);
    }
View Full Code Here

        String rendered = renderer.render(main);
        Assert.assertEquals("test { $name=\"attribute\" }", rendered);
    }

    public void testRenderElementWithNamespaceAttribute() throws Exception {
        Element main = new Element("test", null);
        main.addAttribute(new Attribute("name", "ns-uri", "attribute"));
        String rendered = renderer.render(main);
        Assert.assertEquals("test { $ns-uri:name=\"attribute\" }", rendered);
    }
View Full Code Here

        String rendered = renderer.render(main);
        Assert.assertEquals("test { $ns-uri:name=\"attribute\" }", rendered);
    }

    public void testRenderElementWithChildren() throws Exception {
        Element main = new Element("test", null);
        Element child = new Element("child", null);
        main.addElement(child);
        String rendered = renderer.render(main);
        Assert.assertEquals("test { child { }}", rendered);
    }
View Full Code Here

            error("A component must have exactly one " + JMX_CONFIG_ELT + " or " + JMX_CONFIG_ALT_ELT + " element.");
            error("The JMX handler configuration is ignored.");
            return;
        }

        Element mbean = mbeans[0];

        // retrieve kind of MBeanServer to use
        m_usesMOSGi = Boolean.parseBoolean(mbean.getAttribute(JMX_USES_MOSGI_ELT));

        // retrieve object name
        m_completeObjNameElt = mbean.getAttribute(JMX_OBJ_NAME_ELT);
        m_domainElt = mbean.getAttribute(JMX_OBJ_NAME_DOMAIN_ELT);
        m_objNameWODomainElt = mbean.getAttribute(JMX_OBJ_NAME_WO_DOMAIN_ELT);

        // test if Pojo is interested in registration callbacks
        m_registerCallbacks = manipulation
            .isInterfaceImplemented(MBeanRegistration.class.getName());
        if (m_registerCallbacks) {
            // don't need to check that methods exist, the pojo implements
            // MBeanRegistration interface
            String[] preRegisterParams = { MBeanServer.class.getName(),
                    ObjectName.class.getName() };
            m_preRegisterMeth = manipulation.getMethod(PRE_REGISTER_METH_NAME,
                preRegisterParams);

            String[] postRegisterParams = { Boolean.class.getName() };
            m_postRegisterMeth = manipulation.getMethod(
                POST_REGISTER_METH_NAME, postRegisterParams);

            m_preDeregisterMeth = manipulation.getMethod(
                PRE_DEREGISTER_METH_NAME, new String[0]);

            m_postDeregisterMeth = manipulation.getMethod(
                POST_DEREGISTER_METH_NAME, new String[0]);
        }

        // set property
        Element[] attributes = mbean.getElements(JMX_PROPERTY_ELT, m_namespace);
        Element[] attributesAlt = mbean.getElements(JMX_PROPERTY_ELT_ALT, m_namespace);
        List<Element> listOfAttributes = new ArrayList<Element>();
        if (attributes != null) {
          listOfAttributes.addAll(Arrays.asList(attributes));
        }
        if (attributesAlt != null) {
          listOfAttributes.addAll(Arrays.asList(attributesAlt));
        }

        Element[] attributesOld = mbeans[0].getElements(JMX_PROPERTY_ELT);
        if (attributesOld != null) {
            warn("The JMX property element should use the '" + m_namespace + "' namespace.");
            listOfAttributes.addAll(Arrays.asList(attributesOld));
        }

        for (Element attribute : listOfAttributes) {
            boolean notif = false;
            String rights;
            String name;
            String field = attribute.getAttribute(JMX_FIELD_ELT);

            if (attribute.containsAttribute(JMX_NAME_ELT)) {
                name = attribute.getAttribute(JMX_NAME_ELT);
            } else {
                name = field;
            }
            if (attribute.containsAttribute(JMX_RIGHTS_ELT)) {
                rights = attribute.getAttribute(JMX_RIGHTS_ELT);
            } else {
                rights = "r";
            }

            PropertyField property = new PropertyField(name, field, rights,
                getTypeFromAttributeField(field, manipulation));

            if (attribute.containsAttribute(JMX_NOTIFICATION_ELT)) {
                notif = Boolean.parseBoolean(attribute
                    .getAttribute(JMX_NOTIFICATION_ELT));
            }

            property.setNotifiable(notif);

            if (notif) {
                // add the new notifiable property in structure
                NotificationField notification = new NotificationField(
                    name, this.getClass().getName() + "." + field, null);
                m_jmxConfigFieldMap.addNotificationFromName(name,
                    notification);
            }
            m_jmxConfigFieldMap.addPropertyFromName(name, property);
            getInstanceManager().register(manipulation.getField(field),
                this);
            info("property exposed:" + name + " " + field + ":"
                    + getTypeFromAttributeField(field, manipulation) + " "
                    + rights + ", Notif=" + notif);
        }

        // set methods
        Element[] methods = mbean.getElements(JMX_METHOD_ELT, m_namespace);
        Element[] methodsAlt = mbean.getElements(JMX_METHOD_ELT_ALT, m_namespace);
        List<Element> listOfMethods = new ArrayList<Element>();
        if (methods != null) {
          listOfMethods.addAll(Arrays.asList(methods));
        }
        if (methodsAlt != null) {
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.metadata.Element

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.