+ legacyToNormalized = new DataNormalizer (arg0);
+ runtimeContext = BindingRuntimeContext.create(classLoadingStrategy, arg0);
+ codecRegistry.onBindingRuntimeContextUpdated(runtimeContext);
+ }
+
+ public <T extends DataObject> Function<Optional<NormalizedNode<?, ?>>, Optional<T>> deserializeFunction(final InstanceIdentifier<T> path) {
+ return codecRegistry.deserializeFunction(path);
+ }
+
+ /**
+ * Returns an default object according to YANG schema for supplied path.
+ *
+ * @param path DOM Path
+ * @return Node with defaults set on.
+ */
+ public NormalizedNode<?, ?> getDefaultNodeFor(final YangInstanceIdentifier path) {
+ final Iterator<PathArgument> iterator = path.getPathArguments().iterator();
+ DataNormalizationOperation<?> currentOp = legacyToNormalized.getRootOperation();
+ while (iterator.hasNext()) {
+ final PathArgument currentArg = iterator.next();
+ try {
+ currentOp = currentOp.getChild(currentArg);
+ } catch (final DataNormalizationException e) {
+ throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e);
+ }
+ }
+ return currentOp.createDefault(path.getLastPathArgument());
+ }
+
+ public BindingNormalizedNodeCodecRegistry getCodecRegistry() {
+ return codecRegistry;
+ }
+
+ @Override
+ public void close() {
+ // NOOP Intentionally
+ }
+
+ public BindingNormalizedNodeCodecRegistry getCodecFactory() {
+ return codecRegistry;
+ }
+
+ // FIXME: This should be probably part of Binding Runtime context
+ public ImmutableBiMap<Method, SchemaPath> getRpcMethodToSchemaPath(final Class<? extends RpcService> key) {
+ final QNameModule moduleName = BindingReflections.getQNameModule(key);
+ final Module module = runtimeContext.getSchemaContext().findModuleByNamespaceAndRevision(moduleName.getNamespace(), moduleName.getRevision());
+ final ImmutableBiMap.Builder<Method, SchemaPath> ret = ImmutableBiMap.<Method, SchemaPath>builder();
+ try {
+ for (final RpcDefinition rpcDef : module.getRpcs()) {
+ final Method method = findRpcMethod(key, rpcDef);
+ ret.put(method, rpcDef.getPath());
+ }
+ } catch (final NoSuchMethodException e) {
+ throw new IllegalStateException("Rpc defined in model does not have representation in generated class.", e);
+ }
+ return ret.build();
+ }
+
+ private Method findRpcMethod(final Class<? extends RpcService> key, final RpcDefinition rpcDef) throws NoSuchMethodException {
+ final String methodName = BindingMapping.getMethodName(rpcDef.getQName());
+ if(rpcDef.getInput() != null) {
+ final Class<?> inputClz = runtimeContext.getClassForSchema(rpcDef.getInput());
+ return key.getMethod(methodName, inputClz);
+ }
+ return key.getMethod(methodName);
+ }
+
+ @Override
+ public BindingCodecTree create(BindingRuntimeContext context) {
+ return codecRegistry.create(context);
+ }
+
+ @Override
+ public BindingCodecTree create(SchemaContext context, Class<?>... bindingClasses) {
+ return codecRegistry.create(context, bindingClasses);