org.apache.felix.ipojo.metadata.Element.addElement()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(600)

本文整理了Java中org.apache.felix.ipojo.metadata.Element.addElement()方法的一些代码示例,展示了Element.addElement()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.addElement()方法的具体详情如下:
包路径:org.apache.felix.ipojo.metadata.Element
类名称:Element
方法名:addElement

Element.addElement介绍

[英]Adds a sub-element.
[中]添加子元素。

代码示例

代码示例来源:origin: apache/felix

  1. /**
  2. * End of the annotation.
  3. * Create a "controller" element
  4. * @see org.objectweb.asm.AnnotationVisitor#visitEnd()
  5. */
  6. public void visitEnd() {
  7. provides.addElement(controller);
  8. }
  9. }

代码示例来源:origin: apache/felix

  1. public void visitClassStructure(Element structure) {
  2. // Insert the manipulation structure in the component's metadata
  3. m_component.addElement(structure);
  4. }

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.handler.eventadmin

  1. /**
  2. * Gets the handler info.
  3. * @see org.apache.felix.ipojo.architecture.HandlerDescription#getHandlerInfo()
  4. */
  5. public Element getHandlerInfo() {
  6. Element root = super.getHandlerInfo();
  7. if (m_subscribersDescriptions != null) {
  8. for (int i = 0; i < m_subscribersDescriptions.length; i++) {
  9. Element description = m_subscribersDescriptions[i];
  10. root.addElement(description);
  11. }
  12. }
  13. return root;
  14. }
  15. }

代码示例来源:origin: apache/felix

  1. /**
  2. * Gets the handler info.
  3. * @see org.apache.felix.ipojo.architecture.HandlerDescription#getHandlerInfo()
  4. */
  5. public Element getHandlerInfo() {
  6. Element root = super.getHandlerInfo();
  7. if (m_subscribersDescriptions != null) {
  8. for (int i = 0; i < m_subscribersDescriptions.length; i++) {
  9. Element description = m_subscribersDescriptions[i];
  10. root.addElement(description);
  11. }
  12. }
  13. return root;
  14. }
  15. }

代码示例来源:origin: apache/felix

  1. /**
  2. * Visit a sub-annotation.
  3. *
  4. * @param name : attribute name.
  5. * @param descriptor : annotation description
  6. * @return an annotation visitor which will visit the given annotation
  7. * @see org.objectweb.asm.AnnotationVisitor#visitAnnotation(String, String)
  8. */
  9. public AnnotationVisitor visitAnnotation(String name, String descriptor) {
  10. // Sub annotations are mapped to sub-elements
  11. Element sub = Elements.buildElement(Type.getType(descriptor));
  12. element.addElement(sub);
  13. return new GenericVisitor(sub);
  14. }

代码示例来源:origin: apache/felix

  1. /**
  2. * Visit an annotation element of the visited array.
  3. *
  4. * @param name : null
  5. * @param desc : annotation to visit
  6. * @return the visitor which will visit the annotation
  7. * @see org.objectweb.asm.AnnotationVisitor#visitAnnotation(String, String)
  8. */
  9. public AnnotationVisitor visitAnnotation(String name, String desc) {
  10. // Sub annotations are map to sub-elements
  11. Element elem = Elements.buildElement(Type.getType(desc));
  12. m_elem.addElement(elem);
  13. return new GenericVisitor(elem);
  14. }

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.composite

  1. /**
  2. * Gets the instance description.
  3. * Overridden to add created objects.
  4. * @return the instance description
  5. */
  6. public Element getDescription() {
  7. Element elem = super.getDescription();
  8. elem.addElement(getInternalServices());
  9. InstanceDescription[] descs = getContainedInstances();
  10. if (descs.length > 0) {
  11. Element inst = new Element("ContainedInstances", "");
  12. for (int i = 0; i < descs.length; i++) {
  13. inst.addElement(descs[i].getDescription());
  14. }
  15. elem.addElement(inst);
  16. }
  17. return elem;
  18. }

代码示例来源:origin: apache/felix

  1. /**
  2. * Gets the instance description.
  3. * Overridden to add created objects.
  4. * @return the instance description
  5. */
  6. public Element getDescription() {
  7. Element elem = super.getDescription();
  8. elem.addElement(getInternalServices());
  9. InstanceDescription[] descs = getContainedInstances();
  10. if (descs.length > 0) {
  11. Element inst = new Element("ContainedInstances", "");
  12. for (int i = 0; i < descs.length; i++) {
  13. inst.addElement(descs[i].getDescription());
  14. }
  15. elem.addElement(inst);
  16. }
  17. return elem;
  18. }

代码示例来源:origin: apache/felix

  1. /**
  2. * End of an element.
  3. * @param namespaceURI : element namespace
  4. * @param localName : local name
  5. * @param qName : qualified name
  6. * @throws SAXException : occurs when the element is malformed
  7. * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
  8. */
  9. public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
  10. // Get the last element of the list
  11. Element lastElement = removeLastElement();
  12. // The name is consistent
  13. // Add this element last element with if it is not the root
  14. if (m_elements.length != 0) {
  15. Element newQueue = m_elements[m_elements.length - 1];
  16. newQueue.addElement(lastElement);
  17. } else {
  18. // It is the last element
  19. addElement(lastElement);
  20. }
  21. }

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api

  1. /**
  2. * Gets the instance description in the Element-Attribute form.
  3. * @return the root Element of the instance description
  4. * @see org.apache.felix.ipojo.api.HandlerConfiguration#getElement()
  5. */
  6. public Element getElement() {
  7. ensureValidity();
  8. Element instance = new Element("instance", "");
  9. instance.addAttribute(new Attribute("component", m_type));
  10. for (int i = 0; i < m_conf.size(); i++) {
  11. Element elem = (Element) m_conf.get(i);
  12. instance.addElement(elem);
  13. }
  14. return instance;
  15. }
  16. }

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api

  1. /**
  2. * Gets the provided element.
  3. * @return the 'provides' element describing
  4. * the current provided service.
  5. */
  6. public Element getElement() {
  7. ensureValidity();
  8. Element dep = new Element("provides", "");
  9. dep.addAttribute(new Attribute("action", "implement"));
  10. dep.addAttribute(new Attribute("specification", m_specification));
  11. for (int i = 0; i < m_delegation.size(); i++) {
  12. dep.addElement((Element) m_delegation.get(i));
  13. }
  14. return dep;
  15. }

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo

  1. /**
  2. * Gets the instance description.
  3. * Overridden to add created objects.
  4. * @return the instance description
  5. */
  6. public Element getDescription() {
  7. Element elem = super.getDescription();
  8. // Created Object (empty is composite)
  9. String[] objs = getCreatedObjects();
  10. for (int i = 0; objs != null && i < objs.length; i++) {
  11. Element obj = new Element("Object", "");
  12. obj.addAttribute(new Attribute("name", ((Object) objs[i]).toString()));
  13. elem.addElement(obj);
  14. }
  15. return elem;
  16. }

代码示例来源:origin: apache/felix

  1. /**
  2. * Gets the instance description.
  3. * Overridden to add created objects.
  4. * @return the instance description
  5. */
  6. public Element getDescription() {
  7. Element elem = super.getDescription();
  8. // Created Object (empty is composite)
  9. String[] objs = getCreatedObjects();
  10. for (int i = 0; objs != null && i < objs.length; i++) {
  11. Element obj = new Element("Object", "");
  12. obj.addAttribute(new Attribute("name", ((Object) objs[i]).toString()));
  13. elem.addElement(obj);
  14. }
  15. return elem;
  16. }

代码示例来源:origin: apache/felix

  1. private Element getPropertyElement() {
  2. // Gather all the <property> Elements
  3. Element[] props = m_parent.getElements("property");
  4. Element prop = null;
  5. for (int i = 0; props != null && prop == null && i < props.length; i++) {
  6. // Get the first one with the good name
  7. String name = props[i].getAttribute("name");
  8. if (name != null && name.equals(m_name)) {
  9. prop = props[i];
  10. }
  11. }
  12. // Create the Element if not present
  13. if (prop == null) {
  14. prop = new Element("property", "");
  15. m_parent.addElement(prop);
  16. if (m_name != null) {
  17. prop.addAttribute(new Attribute("name", m_name));
  18. }
  19. }
  20. return prop;
  21. }
  22. }

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api

  1. /**
  2. * Adds an array property.
  3. * @param name the property name
  4. * @param values the property value
  5. * @return the current instantiated sub-service
  6. */
  7. public InstantiatedService addProperty(String name, String[] values) {
  8. Element elem = new Element("property", "");
  9. elem.addAttribute(new Attribute("name", name));
  10. elem.addAttribute(new Attribute("type", "array"));
  11. m_conf.add(elem);
  12. for (int i = 0; i < values.length; i++) {
  13. Object obj = values[i];
  14. Element e = new Element("property", "");
  15. elem.addElement(e);
  16. e.addAttribute(new Attribute("value", obj.toString()));
  17. }
  18. return this;
  19. }

代码示例来源:origin: apache/felix

  1. /**
  2. * Adds the "implementation-class" attribute to the type description.
  3. *
  4. * @return the component type description.
  5. * @see org.apache.felix.ipojo.architecture.ComponentTypeDescription#getDescription()
  6. */
  7. public Element getDescription() {
  8. Element elem = super.getDescription();
  9. elem.addAttribute(new Attribute("Implementation-Class", m_factory.getClassName()));
  10. /* Adding interfaces and super-classes of component into description */
  11. Element inheritance = new Element("Inherited", "");
  12. inheritance.addAttribute(new Attribute("Interfaces", m_interfaces.toString()));
  13. inheritance.addAttribute(new Attribute("SuperClasses", m_superClasses.toString()));
  14. elem.addElement(inheritance);
  15. return elem;
  16. }

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo

  1. /**
  2. * Adds the "implementation-class" attribute to the type description.
  3. *
  4. * @return the component type description.
  5. * @see org.apache.felix.ipojo.architecture.ComponentTypeDescription#getDescription()
  6. */
  7. public Element getDescription() {
  8. Element elem = super.getDescription();
  9. elem.addAttribute(new Attribute("Implementation-Class", m_factory.getClassName()));
  10. /* Adding interfaces and super-classes of component into description */
  11. Element inheritance = new Element("Inherited", "");
  12. inheritance.addAttribute(new Attribute("Interfaces", m_interfaces.toString()));
  13. inheritance.addAttribute(new Attribute("SuperClasses", m_superClasses.toString()));
  14. elem.addElement(inheritance);
  15. return elem;
  16. }

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api

  1. /**
  2. * Adds an array property.
  3. * @param name the property name
  4. * @param values the array
  5. * @return the current instance
  6. */
  7. public Instance addProperty(String name, String[] values) {
  8. Element elem = new Element("property", "");
  9. elem.addAttribute(new Attribute("name", name));
  10. elem.addAttribute(new Attribute("type", "array"));
  11. m_conf.add(elem);
  12. for (int i = 0; i < values.length; i++) {
  13. Object obj = values[i];
  14. Element e = new Element("property", "");
  15. elem.addElement(e);
  16. e.addAttribute(new Attribute("value", obj.toString()));
  17. }
  18. return this;
  19. }

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api

  1. /**
  2. * Creates the component factory.
  3. */
  4. private void createFactory() {
  5. ensureValidity();
  6. byte[] clazz = manipulate();
  7. Element meta = generateComponentMetadata();
  8. meta.addElement(m_manipulation);
  9. try {
  10. if (m_alreadyManipulated) { // Already manipulated
  11. m_factory = new ComponentFactory(m_context, meta);
  12. } else {
  13. m_factory = new ComponentFactory(m_context, clazz, meta);
  14. m_factory.setUseFactoryClassloader(true);
  15. }
  16. m_factory.start();
  17. } catch (ConfigurationException e) {
  18. throw new IllegalStateException("An exception occurs during factory initialization", e);
  19. }
  20. }

代码示例来源:origin: org.wisdom-framework/wisdom-ipojo-module

  1. /**
  2. * End of the visit.
  3. * Declare the "component", "provides" and "instance" elements.
  4. *
  5. * @see org.objectweb.asm.AnnotationVisitor#visitEnd()
  6. */
  7. public void visitEnd() {
  8. String classname = workbench.getType().getClassName();
  9. component.addAttribute(new Attribute("classname", classname));
  10. // Generates the provides attribute.
  11. component.addElement(ElementHelper.getProvidesElement(specifications));
  12. if (workbench.getRoot() == null) {
  13. workbench.setRoot(component);
  14. // Add the instance
  15. workbench.setInstance(ElementHelper.declareInstance(workbench));
  16. } else {
  17. // Error case: 2 component type's annotations (@Component and @Handler for example) on the same class
  18. reporter.error("Multiple 'component type' annotations on the class '{%s}'.", classname);
  19. reporter.warn("@Service is ignored.");
  20. }
  21. }

相关文章