use of aQute.bnd.xmlattribute.Namespaces in project bnd by bndtools.
the class DesignateDef method getOuterTag.
Tag getOuterTag() {
Tag metadata = new Tag("metatype:MetaData").addAttribute("xmlns:metatype", MetatypeVersion.VERSION_1_3.getNamespace());
Namespaces namespaces = new Namespaces();
String xmlns = MetatypeVersion.VERSION_1_3.getNamespace();
namespaces.registerNamespace("metatype", xmlns);
addNamespaces(namespaces, xmlns);
namespaces.addNamespaces(metadata);
metadata.addContent(getInnerTag(namespaces));
return metadata;
}
use of aQute.bnd.xmlattribute.Namespaces in project bnd by bndtools.
the class ComponentDef method getTag.
/**
* Returns a tag describing the component element.
*
* @return a component element
*/
Tag getTag() {
String xmlns = this.xmlns;
if (xmlns == null && !version.equals(AnnotationReader.V1_0))
xmlns = NAMESPACE_STEM + "/v" + version;
Tag component = new Tag(xmlns == null ? "component" : "scr:component");
Namespaces namespaces = null;
if (xmlns != null) {
namespaces = new Namespaces();
namespaces.registerNamespace("scr", xmlns);
addNamespaces(namespaces, xmlns);
for (ReferenceDef ref : references.values()) ref.addNamespaces(namespaces, xmlns);
namespaces.addNamespaces(component);
}
component.addAttribute("name", name);
if (configurationPolicy != null)
component.addAttribute("configuration-policy", configurationPolicy.toString().toLowerCase());
if (enabled != null)
component.addAttribute("enabled", enabled);
if (immediate != null)
component.addAttribute("immediate", immediate);
if (factory != null)
component.addAttribute("factory", factory);
if (activate != null && !version.equals(AnnotationReader.V1_0))
component.addAttribute("activate", activate);
if (deactivate != null && !version.equals(AnnotationReader.V1_0))
component.addAttribute("deactivate", deactivate);
if (modified != null)
component.addAttribute("modified", modified);
if (configurationPid != null) {
StringBuilder b = new StringBuilder();
String space = "";
for (String pid : configurationPid) {
if ("$".equals(pid))
pid = name;
b.append(space).append(pid);
space = " ";
}
component.addAttribute("configuration-pid", b.toString());
}
addAttributes(component, namespaces);
Tag impl = new Tag(component, "implementation");
impl.addAttribute("class", implementation.getFQN());
if (service != null && service.length != 0) {
Tag s = new Tag(component, "service");
if (scope != null) {
// TODO check for DEFAULT???
if (AnnotationReader.V1_3.compareTo(version) > 0) {
if (scope == ServiceScope.PROTOTYPE) {
throw new IllegalStateException("verification failed, pre 1.3 component with scope PROTOTYPE");
}
s.addAttribute("servicefactory", scope == ServiceScope.BUNDLE);
} else {
s.addAttribute("scope", scope.toString().toLowerCase());
}
}
for (TypeRef ss : service) {
Tag provide = new Tag(s, "provide");
provide.addAttribute("interface", ss.getFQN());
}
}
for (ReferenceDef ref : references.values()) {
Tag refTag = ref.getTag(namespaces);
component.addContent(refTag);
}
for (Tag tag : propertyTags) component.addContent(tag);
for (String entry : properties) {
Tag properties = new Tag(component, "properties");
properties.addAttribute("entry", entry);
}
return component;
}
use of aQute.bnd.xmlattribute.Namespaces in project bnd by bndtools.
the class OCDDef method getTag.
Tag getTag() {
Tag metadata = new Tag("metatype:MetaData");
// .addAttribute("xmlns:metatype",
// MetatypeVersion.VERSION_1_3.getNamespace());
Namespaces namespaces = new Namespaces();
String xmlns = version.getNamespace();
namespaces.registerNamespace("metatype", xmlns);
addNamespaces(namespaces, xmlns);
for (ADDef ad : attributes) ad.addNamespaces(namespaces, xmlns);
for (DesignateDef dd : designates) dd.addNamespaces(namespaces, xmlns);
namespaces.addNamespaces(metadata);
if (localization != null) {
metadata.addAttribute("localization", localization);
}
Tag ocd = new Tag(metadata, "OCD").addAttribute("id", id);
if (name != null) {
ocd.addAttribute("name", name);
}
if (description != null) {
ocd.addAttribute("description", description);
}
addAttributes(ocd, namespaces);
for (ADDef ad : attributes) {
ocd.addContent(ad.getTag(namespaces));
}
for (IconDef icon : icons) {
ocd.addContent(icon.getTag());
}
for (DesignateDef designate : designates) {
metadata.addContent(designate.getInnerTag(namespaces));
}
return metadata;
}
Aggregations