2 * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.config.manager.impl.osgi.mapping;
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
12 import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
13 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
16 * Creates and initializes {@link BindingRuntimeContext}, which is used to
17 * resolve Identity classes from QName. An instance of
18 * {@link BindingRuntimeContext} is available only after first schema context
19 * was successfully built.
21 // TODO move to yang runtime
22 public class BindingContextProvider implements AutoCloseable {
24 private BindingRuntimeContext current;
26 public synchronized void update(final ClassLoadingStrategy classLoadingStrategy,
27 final SchemaContextProvider ctxProvider) {
28 this.current = BindingRuntimeContext.create(classLoadingStrategy, ctxProvider.getSchemaContext());
31 public synchronized BindingRuntimeContext getBindingContext() {
32 Preconditions.checkState(this.current != null, "Binding context not yet initialized");
37 public synchronized void close() throws Exception {