use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class HandlerDescription method getHandlerInfo.
/**
* Gets handler information.
* This represent the actual state of the handler.
* @return the handler information.
*/
public Element getHandlerInfo() {
Element elem = new Element("Handler", "");
elem.addAttribute(new Attribute("name", m_handlerName));
if (isValid()) {
elem.addAttribute(new Attribute("state", "valid"));
} else {
elem.addAttribute(new Attribute("state", "invalid"));
}
return elem;
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class FieldPropertyVisitor method visitEnd.
/**
* End of the annotation.
* Create a "property" element
* @see org.objectweb.asm.AnnotationVisitor#visitEnd()
*/
public void visitEnd() {
if (m_field != null && m_name == null) {
m_name = m_field;
}
Element[] props = m_parent.getElements("property");
Element prop = null;
for (int i = 0; prop == null && props != null && i < props.length; i++) {
String name = props[i].getAttribute("name");
if (name != null && name.equals(m_name)) {
prop = props[i];
}
}
if (prop == null) {
prop = new Element("property", "");
m_parent.addElement(prop);
if (m_name != null) {
prop.addAttribute(new Attribute("name", m_name));
}
}
if (m_field != null) {
prop.addAttribute(new Attribute("field", m_field));
}
if (m_type != null) {
prop.addAttribute(new Attribute("type", m_type));
}
if (m_value != null) {
prop.addAttribute(new Attribute("value", m_value));
}
if (m_mandatory != null) {
prop.addAttribute(new Attribute("mandatory", m_mandatory));
}
if (m_immutable != null) {
prop.addAttribute(new Attribute("immutable", m_immutable));
}
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class HandlerVisitor method visitEnd.
/**
* End of the visit.
* Append to the "component" element computed attribute.
*
* @see org.objectweb.asm.AnnotationVisitor#visitEnd()
*/
public void visitEnd() {
String classname = workbench.getType().getClassName();
handler.addAttribute(new Attribute("classname", classname));
if (workbench.getRoot() == null) {
workbench.setRoot(handler);
} 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("@Handler will be ignored.");
}
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class LifecycleVisitor method visitEnd.
@Override
public void visitEnd() {
Element cb = new Element("callback", "");
cb.addAttribute(new Attribute("transition", transition.name().toLowerCase()));
cb.addAttribute(new Attribute("method", name));
workbench.getElements().put(cb, null);
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class MethodPropertyVisitor method visitEndCommon.
protected Element visitEndCommon() {
m_method = computeEffectiveMethodName(m_method);
// If neither name nor id is provided, try to extract the name
if (m_name == null && m_id == null && m_method.startsWith("set")) {
m_name = m_method.substring("set".length());
m_id = m_name;
// Else align the two values
} else if (m_name != null && m_id == null) {
m_id = m_name;
} else if (m_id != null && m_name == null) {
m_name = m_id;
}
Element prop = getPropertyElement();
if (m_value != null) {
prop.addAttribute(new Attribute("value", m_value));
}
if (m_mandatory != null) {
prop.addAttribute(new Attribute("mandatory", m_mandatory));
}
if (m_immutable != null) {
prop.addAttribute(new Attribute("immutable", m_immutable));
}
return prop;
}
Aggregations