2 * Copyright (c) 2014 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.mdsal.binding.dom.adapter.test.util;
10 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
11 import org.opendaylight.yangtools.concepts.ListenerRegistration;
12 import org.opendaylight.yangtools.util.ListenerRegistry;
13 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
14 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
15 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
17 public final class MockSchemaService implements DOMSchemaService, SchemaContextProvider {
19 private SchemaContext schemaContext;
21 ListenerRegistry<SchemaContextListener> listeners = ListenerRegistry.create();
24 public synchronized SchemaContext getGlobalContext() {
29 public synchronized SchemaContext getSessionContext() {
34 public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
35 final SchemaContextListener listener) {
36 return listeners.register(listener);
40 public synchronized SchemaContext getSchemaContext() {
44 public synchronized void changeSchema(final SchemaContext newContext) {
45 schemaContext = newContext;
46 for (ListenerRegistration<SchemaContextListener> listener : listeners) {
47 listener.getInstance().onGlobalContextUpdated(schemaContext);