本文整理了Java中org.apache.felix.ipojo.metadata.Element.addElement()
方法的一些代码示例,展示了Element.addElement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.addElement()
方法的具体详情如下:
包路径:org.apache.felix.ipojo.metadata.Element
类名称:Element
方法名:addElement
[英]Adds a sub-element.
[中]添加子元素。
代码示例来源:origin: apache/felix
/**
* End of the annotation.
* Create a "controller" element
* @see org.objectweb.asm.AnnotationVisitor#visitEnd()
*/
public void visitEnd() {
provides.addElement(controller);
}
}
代码示例来源:origin: apache/felix
public void visitClassStructure(Element structure) {
// Insert the manipulation structure in the component's metadata
m_component.addElement(structure);
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.handler.eventadmin
/**
* Gets the handler info.
* @see org.apache.felix.ipojo.architecture.HandlerDescription#getHandlerInfo()
*/
public Element getHandlerInfo() {
Element root = super.getHandlerInfo();
if (m_subscribersDescriptions != null) {
for (int i = 0; i < m_subscribersDescriptions.length; i++) {
Element description = m_subscribersDescriptions[i];
root.addElement(description);
}
}
return root;
}
}
代码示例来源:origin: apache/felix
/**
* Gets the handler info.
* @see org.apache.felix.ipojo.architecture.HandlerDescription#getHandlerInfo()
*/
public Element getHandlerInfo() {
Element root = super.getHandlerInfo();
if (m_subscribersDescriptions != null) {
for (int i = 0; i < m_subscribersDescriptions.length; i++) {
Element description = m_subscribersDescriptions[i];
root.addElement(description);
}
}
return root;
}
}
代码示例来源:origin: apache/felix
/**
* Visit a sub-annotation.
*
* @param name : attribute name.
* @param descriptor : annotation description
* @return an annotation visitor which will visit the given annotation
* @see org.objectweb.asm.AnnotationVisitor#visitAnnotation(String, String)
*/
public AnnotationVisitor visitAnnotation(String name, String descriptor) {
// Sub annotations are mapped to sub-elements
Element sub = Elements.buildElement(Type.getType(descriptor));
element.addElement(sub);
return new GenericVisitor(sub);
}
代码示例来源:origin: apache/felix
/**
* Visit an annotation element of the visited array.
*
* @param name : null
* @param desc : annotation to visit
* @return the visitor which will visit the annotation
* @see org.objectweb.asm.AnnotationVisitor#visitAnnotation(String, String)
*/
public AnnotationVisitor visitAnnotation(String name, String desc) {
// Sub annotations are map to sub-elements
Element elem = Elements.buildElement(Type.getType(desc));
m_elem.addElement(elem);
return new GenericVisitor(elem);
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.composite
/**
* Gets the instance description.
* Overridden to add created objects.
* @return the instance description
*/
public Element getDescription() {
Element elem = super.getDescription();
elem.addElement(getInternalServices());
InstanceDescription[] descs = getContainedInstances();
if (descs.length > 0) {
Element inst = new Element("ContainedInstances", "");
for (int i = 0; i < descs.length; i++) {
inst.addElement(descs[i].getDescription());
}
elem.addElement(inst);
}
return elem;
}
代码示例来源:origin: apache/felix
/**
* Gets the instance description.
* Overridden to add created objects.
* @return the instance description
*/
public Element getDescription() {
Element elem = super.getDescription();
elem.addElement(getInternalServices());
InstanceDescription[] descs = getContainedInstances();
if (descs.length > 0) {
Element inst = new Element("ContainedInstances", "");
for (int i = 0; i < descs.length; i++) {
inst.addElement(descs[i].getDescription());
}
elem.addElement(inst);
}
return elem;
}
代码示例来源:origin: apache/felix
/**
* End of an element.
* @param namespaceURI : element namespace
* @param localName : local name
* @param qName : qualified name
* @throws SAXException : occurs when the element is malformed
* @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
*/
public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
// Get the last element of the list
Element lastElement = removeLastElement();
// The name is consistent
// Add this element last element with if it is not the root
if (m_elements.length != 0) {
Element newQueue = m_elements[m_elements.length - 1];
newQueue.addElement(lastElement);
} else {
// It is the last element
addElement(lastElement);
}
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api
/**
* Gets the instance description in the Element-Attribute form.
* @return the root Element of the instance description
* @see org.apache.felix.ipojo.api.HandlerConfiguration#getElement()
*/
public Element getElement() {
ensureValidity();
Element instance = new Element("instance", "");
instance.addAttribute(new Attribute("component", m_type));
for (int i = 0; i < m_conf.size(); i++) {
Element elem = (Element) m_conf.get(i);
instance.addElement(elem);
}
return instance;
}
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api
/**
* Gets the provided element.
* @return the 'provides' element describing
* the current provided service.
*/
public Element getElement() {
ensureValidity();
Element dep = new Element("provides", "");
dep.addAttribute(new Attribute("action", "implement"));
dep.addAttribute(new Attribute("specification", m_specification));
for (int i = 0; i < m_delegation.size(); i++) {
dep.addElement((Element) m_delegation.get(i));
}
return dep;
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo
/**
* Gets the instance description.
* Overridden to add created objects.
* @return the instance description
*/
public Element getDescription() {
Element elem = super.getDescription();
// Created Object (empty is composite)
String[] objs = getCreatedObjects();
for (int i = 0; objs != null && i < objs.length; i++) {
Element obj = new Element("Object", "");
obj.addAttribute(new Attribute("name", ((Object) objs[i]).toString()));
elem.addElement(obj);
}
return elem;
}
代码示例来源:origin: apache/felix
/**
* Gets the instance description.
* Overridden to add created objects.
* @return the instance description
*/
public Element getDescription() {
Element elem = super.getDescription();
// Created Object (empty is composite)
String[] objs = getCreatedObjects();
for (int i = 0; objs != null && i < objs.length; i++) {
Element obj = new Element("Object", "");
obj.addAttribute(new Attribute("name", ((Object) objs[i]).toString()));
elem.addElement(obj);
}
return elem;
}
代码示例来源:origin: apache/felix
private Element getPropertyElement() {
// Gather all the <property> Elements
Element[] props = m_parent.getElements("property");
Element prop = null;
for (int i = 0; props != null && prop == null && i < props.length; i++) {
// Get the first one with the good name
String name = props[i].getAttribute("name");
if (name != null && name.equals(m_name)) {
prop = props[i];
}
}
// Create the Element if not present
if (prop == null) {
prop = new Element("property", "");
m_parent.addElement(prop);
if (m_name != null) {
prop.addAttribute(new Attribute("name", m_name));
}
}
return prop;
}
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api
/**
* Adds an array property.
* @param name the property name
* @param values the property value
* @return the current instantiated sub-service
*/
public InstantiatedService addProperty(String name, String[] values) {
Element elem = new Element("property", "");
elem.addAttribute(new Attribute("name", name));
elem.addAttribute(new Attribute("type", "array"));
m_conf.add(elem);
for (int i = 0; i < values.length; i++) {
Object obj = values[i];
Element e = new Element("property", "");
elem.addElement(e);
e.addAttribute(new Attribute("value", obj.toString()));
}
return this;
}
代码示例来源:origin: apache/felix
/**
* Adds the "implementation-class" attribute to the type description.
*
* @return the component type description.
* @see org.apache.felix.ipojo.architecture.ComponentTypeDescription#getDescription()
*/
public Element getDescription() {
Element elem = super.getDescription();
elem.addAttribute(new Attribute("Implementation-Class", m_factory.getClassName()));
/* Adding interfaces and super-classes of component into description */
Element inheritance = new Element("Inherited", "");
inheritance.addAttribute(new Attribute("Interfaces", m_interfaces.toString()));
inheritance.addAttribute(new Attribute("SuperClasses", m_superClasses.toString()));
elem.addElement(inheritance);
return elem;
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo
/**
* Adds the "implementation-class" attribute to the type description.
*
* @return the component type description.
* @see org.apache.felix.ipojo.architecture.ComponentTypeDescription#getDescription()
*/
public Element getDescription() {
Element elem = super.getDescription();
elem.addAttribute(new Attribute("Implementation-Class", m_factory.getClassName()));
/* Adding interfaces and super-classes of component into description */
Element inheritance = new Element("Inherited", "");
inheritance.addAttribute(new Attribute("Interfaces", m_interfaces.toString()));
inheritance.addAttribute(new Attribute("SuperClasses", m_superClasses.toString()));
elem.addElement(inheritance);
return elem;
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api
/**
* Adds an array property.
* @param name the property name
* @param values the array
* @return the current instance
*/
public Instance addProperty(String name, String[] values) {
Element elem = new Element("property", "");
elem.addAttribute(new Attribute("name", name));
elem.addAttribute(new Attribute("type", "array"));
m_conf.add(elem);
for (int i = 0; i < values.length; i++) {
Object obj = values[i];
Element e = new Element("property", "");
elem.addElement(e);
e.addAttribute(new Attribute("value", obj.toString()));
}
return this;
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api
/**
* Creates the component factory.
*/
private void createFactory() {
ensureValidity();
byte[] clazz = manipulate();
Element meta = generateComponentMetadata();
meta.addElement(m_manipulation);
try {
if (m_alreadyManipulated) { // Already manipulated
m_factory = new ComponentFactory(m_context, meta);
} else {
m_factory = new ComponentFactory(m_context, clazz, meta);
m_factory.setUseFactoryClassloader(true);
}
m_factory.start();
} catch (ConfigurationException e) {
throw new IllegalStateException("An exception occurs during factory initialization", e);
}
}
代码示例来源:origin: org.wisdom-framework/wisdom-ipojo-module
/**
* End of the visit.
* Declare the "component", "provides" and "instance" elements.
*
* @see org.objectweb.asm.AnnotationVisitor#visitEnd()
*/
public void visitEnd() {
String classname = workbench.getType().getClassName();
component.addAttribute(new Attribute("classname", classname));
// Generates the provides attribute.
component.addElement(ElementHelper.getProvidesElement(specifications));
if (workbench.getRoot() == null) {
workbench.setRoot(component);
// Add the instance
workbench.setInstance(ElementHelper.declareInstance(workbench));
} else {
// Error case: 2 component type's annotations (@Component and @Handler for example) on the same class
reporter.error("Multiple 'component type' annotations on the class '{%s}'.", classname);
reporter.warn("@Service is ignored.");
}
}
内容来源于网络,如有侵权,请联系作者删除!