diff options
author | Zhuoyao Huang <10112215@zte.com.cn> | 2017-09-23 14:43:23 +0800 |
---|---|---|
committer | Zhuoyao Huang <10112215@zte.com.cn> | 2017-09-23 14:45:49 +0800 |
commit | 8de219f6b04458d40d4229c7ec2beda7e3f262b3 (patch) | |
tree | 74f770787244837a56924e1d5307cfd9be287e85 /common/src/main/java/org/openecomp/mso/yangDecoder/base/MockSchemaService.java | |
parent | 3069884affc18e293686692c291fcb21f2ddf024 (diff) |
Yang decoder
Change-Id: I4e264c33915969f883ebc3721e7020fb1256682c
Issue-ID: SO-88
Signed-off-by: Zhuoyao Huang <10112215@zte.com.cn>
description: It could help SO to use the restconf interface which is generated by yang-tools in SDN-C directly.
Diffstat (limited to 'common/src/main/java/org/openecomp/mso/yangDecoder/base/MockSchemaService.java')
-rw-r--r-- | common/src/main/java/org/openecomp/mso/yangDecoder/base/MockSchemaService.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/common/src/main/java/org/openecomp/mso/yangDecoder/base/MockSchemaService.java b/common/src/main/java/org/openecomp/mso/yangDecoder/base/MockSchemaService.java new file mode 100644 index 0000000000..f869a3c600 --- /dev/null +++ b/common/src/main/java/org/openecomp/mso/yangDecoder/base/MockSchemaService.java @@ -0,0 +1,42 @@ +package org.openecomp.mso.yangDecoder.base; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.util.ListenerRegistry; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; +import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; + +public final class MockSchemaService implements DOMSchemaService, SchemaContextProvider { + + private SchemaContext schemaContext; + + ListenerRegistry<SchemaContextListener> listeners = ListenerRegistry.create(); + + @Override + public synchronized SchemaContext getGlobalContext() { + return schemaContext; + } + + @Override + public synchronized SchemaContext getSessionContext() { + return schemaContext; + } + + @Override + public ListenerRegistration<SchemaContextListener> registerSchemaContextListener( + final SchemaContextListener listener) { + return listeners.register(listener); + } + + @Override + public synchronized SchemaContext getSchemaContext() { + return schemaContext; + } + + public synchronized void changeSchema(final SchemaContext newContext) { + schemaContext = newContext; + for (ListenerRegistration<SchemaContextListener> listener : listeners) { + listener.getInstance().onGlobalContextUpdated(schemaContext); + } + } +} |