2 * Copyright (c) 2013 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.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
12 import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
13 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
16 * Creates and initializes {@link BindingRuntimeContext}, which is used to resolve Identity classes from QName.
17 * An instance of {@link BindingRuntimeContext} is available only after first schema context was successfully built.
19 // TODO move to yang runtime
20 public class BindingContextProvider implements AutoCloseable {
22 private BindingRuntimeContext current;
24 public synchronized void update(final ClassLoadingStrategy classLoadingStrategy, final SchemaContextProvider ctxProvider) {
25 this.current = BindingRuntimeContext.create(classLoadingStrategy, ctxProvider.getSchemaContext());
28 public synchronized BindingRuntimeContext getBindingContext() {
29 Preconditions.checkState(this.current != null, "Binding context not yet initialized");
34 public synchronized void close() throws Exception {