* @param name : name of the future instance (used to avoid cycle)
* @return Component Type metadata.
*/
protected Element buildMetadata(String name) {
Element elem = new Element("component", "");
Attribute className = new Attribute("classname", m_name);
Attribute factory = new Attribute("public", "false");
elem.addAttribute(className);
elem.addAttribute(factory);
// Add architecture for debug
elem.addAttribute(new Attribute("architecture", "true"));
// Provides
Element provides = new Element("provides", "");
provides.addAttribute(new Attribute("specification", m_specification.getName()));
elem.addElement(provides);
// Dependencies
List fields = getFieldList();
for (int i = 0; i < fields.size(); i++) {
FieldMetadata field = (FieldMetadata) fields.get(i);
if (field.isUseful() && field.getSpecification().isInterface()) {
Element dep = new Element("requires", "");
dep.addAttribute(new Attribute("field", field.getName()));
dep.addAttribute(new Attribute("scope", "composite"));
dep.addAttribute(new Attribute("proxy", "false"));
if (field.getSpecification().isOptional()) {
dep.addAttribute(new Attribute("optional", "true"));
}
dep.addAttribute(new Attribute("filter", "(!(instance.name=" + name + "))"));
elem.addElement(dep);
}
}
Element properties = new Element("properties", "");
for (int i = 0; i < fields.size(); i++) {
FieldMetadata field = (FieldMetadata) fields.get(i);
if (field.isUseful() && !field.getSpecification().isInterface()) {
Element prop = new Element("Property", "");
prop.addAttribute(new Attribute("field", field.getName()));
properties.addElement(prop);
}
}
if (properties.getElements().length != 0) {
elem.addElement(properties);