2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.honeycomb.infra.distro.schema;
19 import com.google.inject.Inject;
20 import io.fd.honeycomb.binding.init.ProviderTrait;
21 import org.opendaylight.controller.sal.core.api.model.SchemaService;
22 import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
23 import org.opendaylight.yangtools.concepts.ListenerRegistration;
24 import org.opendaylight.yangtools.yang.model.api.Module;
25 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
26 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
28 public final class SchemaServiceProvider extends ProviderTrait<SchemaService> {
31 private ModuleInfoBackedContext mibCtx;
34 public StaticSchemaService create() {
35 return new StaticSchemaService(mibCtx.getSchemaContext());
39 * Static schema context provider service.
41 private static final class StaticSchemaService implements SchemaService {
42 private final SchemaContext schemaContext;
44 StaticSchemaService(SchemaContext schemaContext) {
45 this.schemaContext = schemaContext;
49 public void addModule(final Module module) {
50 throw new UnsupportedOperationException("Static service");
54 public void removeModule(final Module module) {
55 throw new UnsupportedOperationException("Static service");
59 public SchemaContext getSessionContext() {
64 public SchemaContext getGlobalContext() {
69 public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
70 final SchemaContextListener listener) {
71 listener.onGlobalContextUpdated(schemaContext);
72 return new ListenerRegistration<SchemaContextListener>() {
74 public void close() {}
77 public SchemaContextListener getInstance() {