diff options
Diffstat (limited to 'common/src/main/java/org/openecomp/mso/yangDecoder/base')
4 files changed, 0 insertions, 266 deletions
diff --git a/common/src/main/java/org/openecomp/mso/yangDecoder/base/DataBrokerTestCustomizer.java b/common/src/main/java/org/openecomp/mso/yangDecoder/base/DataBrokerTestCustomizer.java deleted file mode 100644 index f442372dcd..0000000000 --- a/common/src/main/java/org/openecomp/mso/yangDecoder/base/DataBrokerTestCustomizer.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.openecomp.mso.yangDecoder.base; - -import com.google.common.collect.ImmutableMap; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; -import javassist.ClassPool; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.binding.api.NotificationPublishService; -import org.opendaylight.mdsal.binding.api.NotificationService; -import org.opendaylight.mdsal.binding.dom.adapter.BindingDOMDataBrokerAdapter; -import org.opendaylight.mdsal.binding.dom.adapter.BindingDOMNotificationPublishServiceAdapter; -import org.opendaylight.mdsal.binding.dom.adapter.BindingDOMNotificationServiceAdapter; -import org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.mdsal.dom.api.DOMDataBroker; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.mdsal.dom.broker.DOMNotificationRouter; -import org.opendaylight.mdsal.dom.broker.SerializedDOMDataBroker; -import org.opendaylight.mdsal.dom.spi.store.DOMStore; -import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore; -import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator; -import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator; -import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy; -import org.opendaylight.mdsal.binding.generator.util.JavassistUtils; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class DataBrokerTestCustomizer { - - private DOMDataBroker domDataBroker; - private final DOMNotificationRouter domNotificationRouter; - private final MockSchemaService schemaService; - private ImmutableMap<LogicalDatastoreType, DOMStore> datastores; - private final BindingToNormalizedNodeCodec bindingToNormalized; - - public ImmutableMap<LogicalDatastoreType, DOMStore> createDatastores() { - return ImmutableMap.<LogicalDatastoreType, DOMStore>builder() - .put(LogicalDatastoreType.OPERATIONAL, createOperationalDatastore()) - .put(LogicalDatastoreType.CONFIGURATION,createConfigurationDatastore()) - .build(); - } - - public DataBrokerTestCustomizer() { - schemaService = new MockSchemaService(); - final ClassPool pool = ClassPool.getDefault(); - final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(pool)); - final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(generator); - final GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(); - bindingToNormalized = new BindingToNormalizedNodeCodec(loading, codecRegistry); - schemaService.registerSchemaContextListener(bindingToNormalized); - domNotificationRouter = DOMNotificationRouter.create(16); - } - - public DOMStore createConfigurationDatastore() { - final InMemoryDOMDataStore store = new InMemoryDOMDataStore("CFG", MoreExecutors.sameThreadExecutor()); - schemaService.registerSchemaContextListener(store); - return store; - } - - public DOMStore createOperationalDatastore() { - final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor()); - schemaService.registerSchemaContextListener(store); - return store; - } - - public DOMDataBroker createDOMDataBroker() { - return new SerializedDOMDataBroker(getDatastores(), getCommitCoordinatorExecutor()); - } - - public NotificationService createNotificationService() { - return new BindingDOMNotificationServiceAdapter(bindingToNormalized.getCodecRegistry(), domNotificationRouter); - } - - public NotificationPublishService createNotificationPublishService() { - return new BindingDOMNotificationPublishServiceAdapter(bindingToNormalized, domNotificationRouter); - } - - - public ListeningExecutorService getCommitCoordinatorExecutor() { - return MoreExecutors.sameThreadExecutor(); - } - - public DataBroker createDataBroker() { - return new BindingDOMDataBrokerAdapter(getDOMDataBroker(), bindingToNormalized); - } - - public BindingToNormalizedNodeCodec getBindingToNormalized() { - return bindingToNormalized; - } - - public DOMSchemaService getSchemaService() { - return schemaService; - } - - private DOMDataBroker getDOMDataBroker() { - if(domDataBroker == null) { - domDataBroker = createDOMDataBroker(); - } - return domDataBroker; - } - - private synchronized ImmutableMap<LogicalDatastoreType, DOMStore> getDatastores() { - if (datastores == null) { - datastores = createDatastores(); - } - return datastores; - } - - public void updateSchema(final SchemaContext ctx) { - schemaService.changeSchema(ctx); - } - - public DOMNotificationRouter getDomNotificationRouter() { - return domNotificationRouter; - } - public void close() - { - if(bindingToNormalized!=null)bindingToNormalized.close(); - if(domNotificationRouter!=null)domNotificationRouter.close(); - } -} 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 deleted file mode 100644 index f869a3c600..0000000000 --- a/common/src/main/java/org/openecomp/mso/yangDecoder/base/MockSchemaService.java +++ /dev/null @@ -1,42 +0,0 @@ -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); - } - } -} diff --git a/common/src/main/java/org/openecomp/mso/yangDecoder/base/TYangJsonXmlBase.java b/common/src/main/java/org/openecomp/mso/yangDecoder/base/TYangJsonXmlBase.java deleted file mode 100644 index 5167d9de8d..0000000000 --- a/common/src/main/java/org/openecomp/mso/yangDecoder/base/TYangJsonXmlBase.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.openecomp.mso.yangDecoder.base; - -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.dom.api.DOMDataBroker; -import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import org.opendaylight.yangtools.yang.binding.util.BindingReflections; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; - -//-- - -public abstract class TYangJsonXmlBase { - - private Iterable<YangModuleInfo> moduleInfos; - protected SchemaContext schemaContext; -//---------- - private DataBrokerTestCustomizer testCustomizer; - private DataBroker dataBroker; - private DOMDataBroker domBroker; - - protected Iterable<YangModuleInfo> getModuleInfos() throws Exception { - return BindingReflections.loadModuleInfos(); - } - public static void writefile(String confname, String strx) - { - final String outd="outdir"; - File dir = new File(outd); - dir.mkdir(); - String fn = outd+File.separatorChar+confname; - try(FileWriter fw = new FileWriter(fn); BufferedWriter writer = new BufferedWriter(fw)) - { - // FileWriter fw = new FileWriter(fn); - // BufferedWriter writer = new BufferedWriter(fw); - writer.write(strx); - // writer.close(); - // fw.close(); - } - catch (Exception e) - { - } - } - - public final void setup() throws Exception { - moduleInfos = getModuleInfos(); - ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create(); - moduleContext.addModuleInfos(moduleInfos); - schemaContext = moduleContext.tryToCreateSchemaContext().get(); - setupWithSchema(schemaContext); - } - - /** - * Setups test with Schema context. - * - * @param context schema context - */ - protected void setupWithSchema(SchemaContext context){ - testCustomizer = createDataBrokerTestCustomizer(); - dataBroker = testCustomizer.createDataBroker(); - domBroker = testCustomizer.createDOMDataBroker(); - testCustomizer.updateSchema(context); - setupWithDataBroker(dataBroker); - } - protected void setupWithDataBroker(final DataBroker dataBroker) { - // Intentionally left No-op, subclasses may customize it - } - - protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() { - return new DataBrokerTestCustomizer(); - } - - public DataBroker getDataBroker() { - return dataBroker; - } - - public DOMDataBroker getDomBroker() { - return domBroker; - } - public void close() - { - //domBroker. - testCustomizer.close(); - } -}
\ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/yangDecoder/base/TYangJsonXmlOSGIBase.java b/common/src/main/java/org/openecomp/mso/yangDecoder/base/TYangJsonXmlOSGIBase.java deleted file mode 100644 index 34d3735b08..0000000000 --- a/common/src/main/java/org/openecomp/mso/yangDecoder/base/TYangJsonXmlOSGIBase.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.openecomp.mso.yangDecoder.base; - -import org.openecomp.mso.yangDecoder.transform.api.ITransformJava2StringService; -import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer; - -public interface TYangJsonXmlOSGIBase { - - public abstract void init(BindingNormalizedNodeSerializer mappingService) - throws Exception; - - public abstract ITransformJava2StringService getJava2StringService( - String jsonorxml); - - public abstract void close(); - -}
\ No newline at end of file |