public interface NamespaceHandler
osgi.service.blueprint.namespace
service property denoting the namespace URIs this
handler can process. The service property value can be either a single String
or URI
,
or a Collection
respectively array of String
or URI
.
During parsing when the blueprint extender encounters an element from a non-blueprint namespace it will search
for a namespace handler for the namespace that is compatible with blueprint bundle being processed. Then
for a stand-alone component the parser will invoke the parse
method
to create the Metadata
for the xml element while for an element that is part
of an existing component the parser will invoke the decorated
method to augment
the enclosing ComponentMetadata
instance. Various utilities to interact with
the blueprint parser are available to a namespace handler via the ParserContext
argument
passed to parse
and decorate
.
Recommended behaviour:
ParserContext.createMetadata(..)
and
casting the returned object to the appropriate MutableComponentMetadata
interface.
This method ensures that the metadata object implements the interfaces necessary for other namespace handlers
to be able to use the metadata object.ParserContext.generateId()
.
decorate
method if
the same result could also be achieved by operating on a MutableComponentMetadata
instance.
blueprintBundle
or blueprintBundleContext
. In the case of a dry
parse (i.e. a parse of the blueprint xml files without a backing OSGi bundle), these values will not be
available
Modifier and Type | Method and Description |
---|---|
org.osgi.service.blueprint.reflect.ComponentMetadata |
decorate(Node node,
org.osgi.service.blueprint.reflect.ComponentMetadata component,
ParserContext context)
Process a child node of an enclosing blueprint component.
|
Set<Class> |
getManagedClasses()
Specify a set of classes that must be consistent between a blueprint bundle and this namespace handler
The blueprint extender will not invoke a namespace handler if any of the managed classes are inconsistent
with the class space of the blueprint bundle (i.e.
|
URL |
getSchemaLocation(String namespace)
Retrieve a URL from where the schema for a given namespace can be retrieved
|
org.osgi.service.blueprint.reflect.Metadata |
parse(Element element,
ParserContext context)
Parse a stand-alone blueprint component
Given an
Element node as a root, this method parses the stand-alone component and returns its
metadata. |
URL getSchemaLocation(String namespace)
namespace
- The schema's namespaceSet<Class> getManagedClasses()
Set
of classes that must be compatible with any blueprint bundle for which this namespace
handler is to apply or null
if no compatibility checks are to be performedorg.osgi.service.blueprint.reflect.Metadata parse(Element element, ParserContext context)
Element
node as a root, this method parses the stand-alone component and returns its
metadata. The supplied ParserContext
should be used to parse embedded blueprint elements as well
as creating metadata.element
- The DOM element representing the custom componentcontext
- The ParserContext
for parsing sub-components and creating metadata objectsMutableMetadata
type to enable further decoration by other namespace handlersorg.osgi.service.blueprint.reflect.ComponentMetadata decorate(Node node, org.osgi.service.blueprint.reflect.ComponentMetadata component, ParserContext context)
ComponentMetadata
instance, this will replace the argument
ComponentMetadata
in subsequent parsing and namespace handler invocations. A namespace
handler that elects to return a new ComponentMetadata
instance should
ensure that existing interceptors are registered against the new instance if appropriate.
Due to the interaction with interceptors, a namespace handler should prefer to change a component metadata
instead of returning a new instance wherever possible. This can be achieved by casting a
ComponentMetadata
to its corresponding MutabableComponentMetadata
instance.
Note however that a given ComponentMetadata
instance cannot be guaranteed to implement
the mutable interface if it was constructed by an agent other than the blueprint extender.node
- The node associated with this NamespaceHandler that should be used to decorate the enclosing
componentcomponent
- The enclosing blueprint componentcontext
- The parser contextCopyright © 2016. All rights reserved.