Remove sal.core.api.model
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / sal / binding / test / util / MockSchemaService.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.binding.test.util;
9
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;
16
17 public final class MockSchemaService implements DOMSchemaService, SchemaContextProvider {
18
19     private SchemaContext schemaContext;
20
21     ListenerRegistry<SchemaContextListener> listeners = ListenerRegistry.create();
22
23     @Override
24     public synchronized SchemaContext getGlobalContext() {
25         return schemaContext;
26     }
27
28     @Override
29     public synchronized SchemaContext getSessionContext() {
30         return schemaContext;
31     }
32
33     @Override
34     public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
35             final SchemaContextListener listener) {
36         return listeners.register(listener);
37     }
38
39     @Override
40     public synchronized SchemaContext getSchemaContext() {
41         return schemaContext;
42     }
43
44     public synchronized void changeSchema(final SchemaContext newContext) {
45         schemaContext = newContext;
46         for (ListenerRegistration<SchemaContextListener> listener : listeners) {
47             listener.getInstance().onGlobalContextUpdated(schemaContext);
48         }
49     }
50 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.