...
Implementations of outward-facing protocols depend on the YANG runtime to serialize and deserialize their payloads and the dynamic Config subsystem will depend on the YANG runtime to serialize these objects for distribution and persistence.
1) Serializer Registry
This service is used for registering and unregistering the available data format serializers. YANG App activation registers the default XML/JSON serializers. User can override the existing registration or can register new data formats. In case of multiple registrations of same data format, last one will take into effect.
The YangSerializerRegistry interface provides 2 API's:
| Code Block | ||||
|---|---|---|---|---|
| ||||
void registerSerializer(YANGSerializer serializer) |
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
void unregisterSerializer(YANGSerializer serializer) |
2) Model Registry
This API is used by schema aware application to register YANG model. Example:L3VPN application and also live compiler.
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
void unregisterModel(ModelRegistrationParam param) |
3) Runtime Service
It is a service for encoding and decoding between internal and external model representation.
...
| Code Block | ||
|---|---|---|
| ||
CompositeStream encode(CompositeData internal, RuntimeContext context) |
4) ModelConverter Service
Model converter provides a mechanism for converting between DataNode and Model Object instances. It is capable of constructing model POJO objects from the DataNode,including any augmentations which may be present in the DataNode structure and creating immutable tree structure from a given POJO. This API mainly gives the following methods:
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
DataNode createDataNode(ModelObject) |
5) SchemaContext Provider
It returns an entity that provides schema context corresponding to a given resource identifier.
| Code Block | ||||
|---|---|---|---|---|
| ||||
SchemaContext getSchemaContext(ResourceId id) |
Helper Utils
Runtime Helper
Represents utility for runtime.These utilities can be used by the application to get the YANG model for the application and also it can be used by the runtime to get the YANG Node for the given YANG model.
Examples API's :
Code Block language java title To obtain YANG model for given generated class: YANGModel getModel(Class<?> aClass)
Code Block language java title To get YANG node for given YANG model Set<YANGNode> getNodes(YANGModel model)
Code Block language java title To get interface class name of the schema node String getInterfaceClassName(YANGSchemaNode schemaNode)
Serializer Helper
These set of utilities are used by Serializer to build the data node and resource identifier without obtaining schema.
Example API's:
Code Block language java title To add to resource identifier builder used by applications which are not aware about the schema name association with key's value.This api will also carry out necessary schema related validations. ResourceId.Builder addToResourceId(ResourceId.Builder builder, String name, String namespace, List<String> value)
Code Block language java title To add a data node to a given data node builder. This API will also carry out necessary schema related validations. Builder addDataNode(Builder builder, String name, String namespace, String value, DataNode.Type type)
Code Block language java title To get the resource identifier for a given data node. This API will be used by serializer to obtain the resource identifier in the scenario when an annotation is associated with a given data node. ResourceId getResourceId(Builder builder)
...
