Package org.apache.felix.ipojo.manipulation.annotations

Examples of org.apache.felix.ipojo.manipulation.annotations.MetadataCollector$ComponentVisitor


     * Parse the content of the class to detect annotated classes.
     * @param inC the class to inspect.
     */
    private void computeAnnotations(byte[] inC) {
        ClassReader cr = new ClassReader(inC);
        MetadataCollector collector = new MetadataCollector();
        cr.accept(collector, 0);

        if (collector.isIgnoredBecauseOfMissingComponent()) {
          // No @Component, just skip.
            //warn("Annotation processing ignored in " + collector.getClassName() + " - @Component missing");
        } else if (collector.isComponentType()) {
            boolean toskip = false;
            for (int i = 0; !toskip && i < m_metadata.size(); i++) {
                Element meta = (Elementm_metadata.get(i);
                if (! meta.getName().equals("instance") // Only if its a component type definition,
                                                        // so skip instance declaration
                        && meta.containsAttribute("name")
                        && meta.getAttribute("name").equalsIgnoreCase(collector.getComponentTypeDeclaration().getAttribute("name"))) {
                    toskip = true;
                    warn("The component type " + collector.getComponentTypeDeclaration().getAttribute("name") + " is overriden by the metadata file");
                }
            }
            if (!toskip) {
                // if no metadata or empty one, create a new array.
                Element elem = collector.getComponentTypeDeclaration();
                m_metadata.add(elem);

                String name = elem.getAttribute("classname");
                name = name.replace('.', '/');
                name += ".class";

                // Creates the ComponentInfo and store bytecode
                ComponentInfo info = new ComponentInfo(name, elem);
                info.m_bytecode = inC;
                m_components.add(info);

                // Instantiate ?
                if (collector.getInstanceDeclaration() != null) {
                    //warn("Declaring an empty instance of " + elem.getAttribute("classname"));
                    m_metadata.add(collector.getInstanceDeclaration());
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.manipulation.annotations.MetadataCollector$ComponentVisitor

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.