use of org.osgi.service.blueprint.container.ComponentDefinitionException in project aries by apache.
the class Parser method parseReference.
private void parseReference(Element element, ServiceReferenceMetadataImpl reference, boolean topElement) {
// Parse attributes
if (topElement) {
reference.setActivation(parseActivation(element));
} else {
reference.setActivation(ComponentMetadata.ACTIVATION_LAZY);
}
if (element.hasAttribute(DEPENDS_ON_ATTRIBUTE)) {
reference.setDependsOn(parseList(element.getAttribute(DEPENDS_ON_ATTRIBUTE)));
}
if (element.hasAttribute(INTERFACE_ATTRIBUTE)) {
reference.setInterface(element.getAttribute(INTERFACE_ATTRIBUTE));
}
if (element.hasAttribute(FILTER_ATTRIBUTE)) {
reference.setFilter(element.getAttribute(FILTER_ATTRIBUTE));
}
if (element.hasAttribute(COMPONENT_NAME_ATTRIBUTE)) {
reference.setComponentName(element.getAttribute(COMPONENT_NAME_ATTRIBUTE));
}
String availability = element.hasAttribute(AVAILABILITY_ATTRIBUTE) ? element.getAttribute(AVAILABILITY_ATTRIBUTE) : defaultAvailability;
if (AVAILABILITY_MANDATORY.equals(availability)) {
reference.setAvailability(ServiceReferenceMetadata.AVAILABILITY_MANDATORY);
} else if (AVAILABILITY_OPTIONAL.equals(availability)) {
reference.setAvailability(ServiceReferenceMetadata.AVAILABILITY_OPTIONAL);
} else {
throw new ComponentDefinitionException("Illegal value for " + AVAILABILITY_ATTRIBUTE + " attribute: " + availability);
}
// Parse elements
NodeList nl = element.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
Node node = nl.item(i);
if (node instanceof Element) {
Element e = (Element) node;
if (isBlueprintNamespace(e.getNamespaceURI())) {
if (nodeNameEquals(e, REFERENCE_LISTENER_ELEMENT)) {
reference.addServiceListener(parseServiceListener(e, reference));
}
}
}
}
}
use of org.osgi.service.blueprint.container.ComponentDefinitionException in project aries by apache.
the class Parser method handleCustomScope.
/**
* Tests if a scope attribute value is a custom scope, and if so invokes
* the appropriate namespace handler, passing the blueprint scope node.
* <p>
* Currently this tests for custom scope by looking for the presence of
* a ':' char within the scope attribute value. This is valid as long as
* the blueprint schema continues to restrict that custom scopes should
* require that characters presence.
* <p>
*
* @param scope Value of scope attribute
* @param bean DOM element for bean associated to this scope
* @return Metadata as processed by NS Handler.
* @throws ComponentDefinitionException if an undeclared prefix is used,
* if a namespace handler is unavailable for a resolved prefix,
* or if the resolved prefix results as the blueprint namespace.
*/
private ComponentMetadata handleCustomScope(Node scope, Element bean, ComponentMetadata metadata) {
URI scopeNS = getNamespaceForAttributeValue(scope);
if (scopeNS != null && !BLUEPRINT_NAMESPACE.equals(scopeNS.toString())) {
NamespaceHandler nsHandler = getNamespaceHandler(scopeNS);
ParserContextImpl context = new ParserContextImpl(this, registry, metadata, scope);
metadata = nsHandler.decorate(scope, metadata, context);
} else if (scopeNS != null) {
throw new ComponentDefinitionException("Custom scopes cannot use the blueprint namespace " + scope);
}
return metadata;
}
Aggregations