use of org.apache.felix.ipojo.metadata.Element in project felix by apache.
the class HandlerDeclarationVisitor method visitEnd.
/**
* End of the visit.
* Builds the XML document.
* @see org.objectweb.asm.AnnotationVisitor#visitEnd()
*/
public void visitEnd() {
// The value is an XML document
InputStream is = new ByteArrayInputStream(m_value.getBytes());
Document document = null;
try {
document = builder.parse(is);
Element e = convertDOMElements(document.getDocumentElement());
workbench.getElements().put(e, null);
} catch (Exception e) {
reporter.warn("Cannot convert {} to iPOJO Elements.", m_value, e);
} finally {
try {
is.close();
} catch (IOException e) {
reporter.trace("Cannot close correctly the value input stream ({}).", m_value, e);
}
}
}
use of org.apache.felix.ipojo.metadata.Element in project felix by apache.
the class PostRegistrationVisitor method visitEnd.
@Override
public void visitEnd() {
Element provides;
if (workbench.getIds().containsKey("provides")) {
provides = workbench.getIds().get("provides");
provides.addAttribute(new Attribute("post-registration", name));
}
// Else ignore annotation ...
}
use of org.apache.felix.ipojo.metadata.Element in project felix by apache.
the class PostUnregistrationVisitor method visitEnd.
@Override
public void visitEnd() {
Element provides;
if (workbench.getIds().containsKey("provides")) {
provides = workbench.getIds().get("provides");
provides.addAttribute(new Attribute("post-unregistration", name));
}
// Else ignore annotation ...
}
use of org.apache.felix.ipojo.metadata.Element in project felix by apache.
the class RequiresVisitor method visitEnd.
/**
* End of the annotation.
* Create a "requires" element
* @see org.objectweb.asm.AnnotationVisitor#visitEnd()
*/
public void visitEnd() {
Element requires;
if (m_id == null) {
requires = workbench.getIds().get(m_field);
} else {
requires = workbench.getIds().get(m_id);
}
if (requires == null) {
requires = new Element("requires", "");
}
requires.addAttribute(new Attribute("field", m_field));
if (m_specification != null) {
requires.addAttribute(new Attribute("specification", m_specification));
}
if (m_filter != null) {
requires.addAttribute(new Attribute("filter", m_filter));
}
if (m_optional != null) {
requires.addAttribute(new Attribute("optional", m_optional));
}
if (m_nullable != null) {
requires.addAttribute(new Attribute("nullable", m_nullable));
}
if (m_defaultImplementation != null) {
requires.addAttribute(new Attribute("default-implementation", m_defaultImplementation));
}
if (m_exception != null) {
requires.addAttribute(new Attribute("exception", m_exception));
}
if (m_policy != null) {
requires.addAttribute(new Attribute("policy", m_policy));
}
if (m_id != null) {
requires.addAttribute(new Attribute("id", m_id));
}
if (m_comparator != null) {
requires.addAttribute(new Attribute("comparator", m_comparator));
}
if (m_from != null) {
requires.addAttribute(new Attribute("from", m_from));
}
if (m_proxy != null) {
requires.addAttribute(new Attribute("proxy", m_proxy));
}
if (m_timeout != null) {
requires.addAttribute(new Attribute("timeout", m_timeout));
}
if (m_id != null) {
workbench.getIds().put(m_id, requires);
} else {
workbench.getIds().put(m_field, requires);
}
workbench.getElements().put(requires, null);
}
use of org.apache.felix.ipojo.metadata.Element in project felix by apache.
the class MethodBindVisitor method visitEnd.
/**
* End of the visit.
* Create or append the requirement info to a created or already existing "requires" element.
*
* @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
*/
public void visitEnd() {
if (m_id == null) {
String identifier = Names.getMethodIdentifier(m_node);
if (identifier != null) {
m_id = identifier;
} else {
if (m_specification != null) {
m_id = m_specification;
} else {
m_reporter.error("Cannot determine the requires identifier for the (%s) %s method: %s", computeEffectiveMethodName(m_node.name), action.name(), "Either 'id' attribute is missing or method name do not follow the bind/set/add/modified " + "naming pattern, or no specification (service interface) can be found in method signature " + "or specified in annotation. Dependency will be ignored (would cause an Exception at runtime)");
return;
}
}
}
Element requires = getRequiresElement();
Element callback = new Element("callback", "");
callback.addAttribute(new Attribute("method", computeEffectiveMethodName(m_node.name)));
callback.addAttribute(new Attribute("type", action.name().toLowerCase()));
requires.addElement(callback);
workbench.getIds().put(m_id, requires);
workbench.getElements().put(requires, null);
}
Aggregations