use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class ServiceProperty method getElement.
/**
* Gets the 'property' element.
* @return the element describing the current property.
*/
public Element getElement() {
ensureValidity();
Element element = new Element("property", "");
if (m_name != null) {
element.addAttribute(new Attribute("name", m_name));
}
if (m_type != null) {
element.addAttribute(new Attribute("type", m_type));
}
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;
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class CompositeComponentType method generateComponentMetadata.
/**
* Generates the component description.
* @return the component type description of
* the current component type
*/
private Element generateComponentMetadata() {
Element element = new Element("composite", "");
if (m_name != null) {
element.addAttribute(new Attribute("name", m_name));
}
if (m_version != null) {
element.addAttribute(new Attribute("version", m_version));
}
if (!m_public) {
element.addAttribute(new Attribute("public", "false"));
}
for (int i = 0; i < m_contained.size(); i++) {
Instance inst = (Instance) m_contained.get(i);
element.addElement(inst.getElement());
}
for (int i = 0; i < m_imported.size(); i++) {
ImportedService inst = (ImportedService) m_imported.get(i);
element.addElement(inst.getElement());
}
for (int i = 0; i < m_instantiated.size(); i++) {
InstantiatedService inst = (InstantiatedService) m_instantiated.get(i);
element.addElement(inst.getElement());
}
for (int i = 0; i < m_exported.size(); i++) {
ExportedService inst = (ExportedService) m_exported.get(i);
element.addElement(inst.getElement());
}
for (int i = 0; i < m_provided.size(); i++) {
ProvidedService inst = (ProvidedService) m_provided.get(i);
element.addElement(inst.getElement());
}
// External handlers
for (int i = 0; i < m_handlers.size(); i++) {
HandlerConfiguration hc = (HandlerConfiguration) m_handlers.get(i);
element.addElement(hc.getElement());
}
return element;
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class ExportedService method getElement.
/**
* Gets the exported service metadata.
* @return the 'provides' element describing
* the current dependency.
*/
public Element getElement() {
ensureValidity();
Element dep = new Element("provides", "");
dep.addAttribute(new Attribute("action", "export"));
dep.addAttribute(new Attribute("specification", m_specification));
if (m_filter != null) {
dep.addAttribute(new Attribute("filter", m_filter));
}
if (m_comparator != null) {
dep.addAttribute(new Attribute("comparator", m_comparator));
}
if (m_optional) {
dep.addAttribute(new Attribute("optional", "true"));
}
if (m_aggregate) {
dep.addAttribute(new Attribute("aggregate", "true"));
}
if (m_policy == DependencyModel.DYNAMIC_BINDING_POLICY) {
dep.addAttribute(new Attribute("policy", "dynamic"));
} else if (m_policy == DependencyModel.STATIC_BINDING_POLICY) {
dep.addAttribute(new Attribute("policy", "static"));
} else if (m_policy == DependencyModel.DYNAMIC_PRIORITY_BINDING_POLICY) {
dep.addAttribute(new Attribute("policy", "dynamic-priority"));
}
return dep;
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class Instance method addProperty.
/**
* Adds a list property.
* @param name property name
* @param values the list
* @return the current instance
*/
public Instance addProperty(String name, List values) {
Element elem = new Element("property", "");
elem.addAttribute(new Attribute("name", name));
elem.addAttribute(new Attribute("type", "list"));
m_conf.add(elem);
for (int i = 0; i < values.size(); i++) {
Object obj = values.get(i);
Element e = new Element("property", "");
elem.addElement(e);
if (obj instanceof String) {
e.addAttribute(new Attribute("value", obj.toString()));
} else {
// TODO
throw new UnsupportedOperationException("Complex properties are not supported yet");
}
}
return this;
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class Instance method addProperty.
/**
* Adds a vector property.
* @param name the property name
* @param values the vector
* @return the current instance
*/
public Instance addProperty(String name, Vector values) {
Element elem = new Element("property", "");
elem.addAttribute(new Attribute("name", name));
elem.addAttribute(new Attribute("type", "vector"));
m_conf.add(elem);
for (int i = 0; i < values.size(); i++) {
Object obj = values.get(i);
Element e = new Element("property", "");
elem.addElement(e);
if (obj instanceof String) {
e.addAttribute(new Attribute("value", obj.toString()));
} else {
// TODO
throw new UnsupportedOperationException("Complex properties are not supported yet");
}
}
return this;
}
Aggregations