use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class MetadataRendererTestCase method testRenderElementWithNamespaceAttribute.
public void testRenderElementWithNamespaceAttribute() throws Exception {
Element main = new Element("test", null);
main.addAttribute(new Attribute("name", "ns-uri", "attribute"));
String rendered = renderer.render(main);
Assert.assertEquals("test { $ns-uri:name=\"attribute\" }", rendered);
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class CheckFieldConsistencyResultVisitorTestCase method newComponentElement.
private Element newComponentElement() {
Element component = new Element("component", null);
Element requires = new Element("requires", null);
requires.addAttribute(new Attribute("field", "property"));
component.addElement(requires);
return component;
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class Dependency method getElement.
/**
* Gets the dependency metadata.
* @return the 'requires' element describing
* the current dependency.
*/
public Element getElement() {
ensureValidity();
Element dep = new Element("requires", "");
if (m_specification != null) {
dep.addAttribute(new Attribute("specification", m_specification));
}
if (m_filter != null) {
dep.addAttribute(new Attribute("filter", m_filter));
}
if (m_field != null) {
dep.addAttribute(new Attribute("field", m_field));
}
if (m_parameterIndex != -1) {
dep.addAttribute(new Attribute("constructor-parameter", Integer.toString(m_parameterIndex)));
}
if (m_bind != null) {
Element cb = new Element("callback", "");
cb.addAttribute(new Attribute("type", "bind"));
cb.addAttribute(new Attribute("method", m_bind));
dep.addElement(cb);
}
if (m_unbind != null) {
Element cb = new Element("callback", "");
cb.addAttribute(new Attribute("type", "unbind"));
cb.addAttribute(new Attribute("method", m_unbind));
dep.addElement(cb);
}
if (m_modified != null) {
Element cb = new Element("callback", "");
cb.addAttribute(new Attribute("type", "modified"));
cb.addAttribute(new Attribute("method", m_modified));
dep.addElement(cb);
}
if (m_comparator != null) {
dep.addAttribute(new Attribute("comparator", m_comparator));
}
if (m_di != null) {
dep.addAttribute(new Attribute("default-implementation", m_di));
}
if (m_from != null) {
dep.addAttribute(new Attribute("from", m_from));
}
if (m_id != null) {
dep.addAttribute(new Attribute("id", m_id));
}
if (!m_nullable) {
dep.addAttribute(new Attribute("nullable", "false"));
}
if (m_optional) {
dep.addAttribute(new Attribute("optional", "true"));
}
if (m_aggregate) {
dep.addAttribute(new Attribute("aggregate", "true"));
}
if (!m_proxy) {
dep.addAttribute(new Attribute("proxy", "false"));
}
if (m_policy != -1) {
if (m_policy == DYNAMIC) {
dep.addAttribute(new Attribute("policy", "dynamic"));
} else if (m_policy == STATIC) {
dep.addAttribute(new Attribute("policy", "static"));
} else if (m_policy == DYNAMIC_PRIORITY) {
dep.addAttribute(new Attribute("policy", "dynamic-priority"));
}
// No other possibilities.
}
return dep;
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class PrimitiveComponentType method generateComponentMetadata.
/**
* Generates the component description.
* @return the component type description of
* the current component type
*/
private Element generateComponentMetadata() {
Element element = new Element("component", "");
element.addAttribute(new Attribute("classname", m_classname));
if (m_name != null) {
element.addAttribute(new Attribute("name", m_name));
}
if (m_version != null) {
element.addAttribute(new Attribute("version", m_version));
}
if (m_factoryMethod != null) {
element.addAttribute(new Attribute("factory-method", m_factoryMethod));
}
if (!m_public) {
element.addAttribute(new Attribute("public", "false"));
}
if (m_immediate) {
element.addAttribute(new Attribute("immediate", "true"));
}
for (Service svc : m_services) {
element.addElement(svc.getElement());
}
for (Dependency dep : m_dependencies) {
element.addElement(dep.getElement());
}
for (TemporalDependency dep : m_temporals) {
element.addElement(dep.getElement());
}
if (m_validate != null) {
Element callback = new Element("callback", "");
callback.addAttribute(new Attribute("transition", "validate"));
callback.addAttribute(new Attribute("method", m_validate));
element.addElement(callback);
}
if (m_invalidate != null) {
Element callback = new Element("callback", "");
callback.addAttribute(new Attribute("transition", "invalidate"));
callback.addAttribute(new Attribute("method", m_invalidate));
element.addElement(callback);
}
// First determine if we need the properties element
if (m_propagation || m_msPID != null || !m_properties.isEmpty()) {
Element properties = new Element("properties", "");
if (m_propagation) {
properties.addAttribute(new Attribute("propagation", "true"));
}
if (m_msPID != null) {
properties.addAttribute(new Attribute("pid", m_msPID));
}
if (m_updated != null) {
properties.addAttribute(new Attribute("updated", m_updated));
}
for (Property prop : m_properties) {
properties.addElement(prop.getElement());
}
element.addElement(properties);
}
// External handlers
for (HandlerConfiguration hc : m_handlers) {
element.addElement(hc.getElement());
}
return element;
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class Property method getElement.
/**
* Gets the property element.
* @return the property element.
*/
public Element getElement() {
ensureValidity();
Element element = new Element("property", "");
if (m_name != null) {
element.addAttribute(new Attribute("name", m_name));
}
if (m_method != null) {
element.addAttribute(new Attribute("method", m_method));
}
if (m_parameterIndex != -1) {
element.addAttribute(new Attribute("constructor-parameter", Integer.toString(m_parameterIndex)));
}
if (m_value != null) {
element.addAttribute(new Attribute("value", m_value));
}
if (m_field != null) {
element.addAttribute(new Attribute("field", m_field));
}
if (m_mandatory) {
element.addAttribute(new Attribute("mandatory", new Boolean(m_mandatory).toString()));
}
if (m_immutable) {
element.addAttribute(new Attribute("immutable", new Boolean(m_immutable).toString()));
}
return element;
}
Aggregations