import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* NOTE: this class is non-final to allow controller adapter migration without duplicated code.
*/
@Singleton
-public class BindingToNormalizedNodeCodec implements BindingNormalizedNodeSerializer, SchemaContextListener,
+public class BindingToNormalizedNodeCodec implements BindingNormalizedNodeSerializer, EffectiveModelContextListener,
AutoCloseable {
private static final long WAIT_DURATION_SEC = 5;
}
@Override
- public void onGlobalContextUpdated(final SchemaContext context) {
+ public void onModelContextUpdated(final EffectiveModelContext newModelContext) {
final BindingRuntimeContext runtimeContext = DefaultBindingRuntimeContext.create(
- generator.generateTypeMapping(context), classLoadingStrategy);
+ generator.generateTypeMapping(newModelContext), classLoadingStrategy);
codecRegistry.onBindingRuntimeContextUpdated(runtimeContext);
futureSchema.onRuntimeContextUpdated(runtimeContext);
}
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
import org.opendaylight.yangtools.yang.model.util.AbstractSchemaContext;
public class BindingNormalizedCodecTest extends AbstractSchemaAwareTest {
.node(TopLevelList.QNAME).nodeWithKey(TopLevelList.QNAME, NAME_QNAME, TOP_FOO_KEY.getName()).build();
private BindingToNormalizedNodeCodec codec;
- private SchemaContext context;
+ private EffectiveModelContext context;
@Override
- protected void setupWithSchema(final SchemaContext schemaContext) {
+ protected void setupWithSchema(final EffectiveModelContext schemaContext) {
this.context = schemaContext;
this.codec = new BindingToNormalizedNodeCodec(new DefaultBindingRuntimeGenerator(),
GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), new BindingNormalizedNodeCodecRegistry(),
@Test
public void testComplexAugmentationSerialization() {
- this.codec.onGlobalContextUpdated(this.context);
+ this.codec.onModelContextUpdated(this.context);
final PathArgument lastArg = this.codec.toYangInstanceIdentifier(BA_TREE_COMPLEX_USES).getLastPathArgument();
assertTrue(lastArg instanceof AugmentationIdentifier);
}
@Test
public void testLeafOnlyAugmentationSerialization() {
- this.codec.onGlobalContextUpdated(this.context);
+ this.codec.onModelContextUpdated(this.context);
final PathArgument leafOnlyLastArg = this.codec.toYangInstanceIdentifier(BA_TREE_LEAF_ONLY)
.getLastPathArgument();
assertTrue(leafOnlyLastArg instanceof AugmentationIdentifier);
@Test
@SuppressWarnings("checkstyle:illegalCatch")
public void testToYangInstanceIdentifierBlocking() {
- this.codec.onGlobalContextUpdated(new EmptySchemaContext());
+ this.codec.onModelContextUpdated(new EmptyEffectiveModelContext());
final CountDownLatch done = new CountDownLatch(1);
final AtomicReference<YangInstanceIdentifier> yangId = new AtomicReference<>();
}).start();
Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
- this.codec.onGlobalContextUpdated(this.context);
+ this.codec.onModelContextUpdated(this.context);
assertTrue("toYangInstanceIdentifierBlocking completed",
Uninterruptibles.awaitUninterruptibly(done, 3, TimeUnit.SECONDS));
@Test
public void testGetRpcMethodToSchemaPathBlocking() {
- this.codec.onGlobalContextUpdated(new EmptySchemaContext());
+ this.codec.onModelContextUpdated(new EmptyEffectiveModelContext());
testGetRpcMethodToSchemaPath();
}
}).start();
Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
- this.codec.onGlobalContextUpdated(this.context);
+ this.codec.onModelContextUpdated(this.context);
assertTrue("getRpcMethodToSchemaPath completed",
Uninterruptibles.awaitUninterruptibly(done, 3, TimeUnit.SECONDS));
fail("rockTheHouse RPC method not found");
}
- static class EmptySchemaContext extends AbstractSchemaContext {
+ static class EmptyEffectiveModelContext extends AbstractSchemaContext implements EffectiveModelContext {
@Override
public Set<Module> getModules() {
return ImmutableSet.of();
protected SetMultimap<String, Module> getNameToModules() {
return ImmutableSetMultimap.of();
}
+
+ @Override
+ public Map<QNameModule, ModuleEffectiveStatement> getModuleStatements() {
+ return ImmutableMap.of();
+ }
}
}
import java.util.concurrent.TimeoutException;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public abstract class AbstractBaseDataBrokerTest extends AbstractSchemaAwareTest {
-
private static final int ASSERT_COMMIT_DEFAULT_TIMEOUT = 5000;
private AbstractDataBrokerTestCustomizer testCustomizer;
}
@Override
- protected void setupWithSchema(final SchemaContext context) {
+ protected void setupWithSchema(final EffectiveModelContext context) {
testCustomizer = createDataBrokerTestCustomizer();
dataBroker = testCustomizer.createDataBroker();
domBroker = testCustomizer.getDOMDataBroker();
assertCommit(commit, ASSERT_COMMIT_DEFAULT_TIMEOUT);
}
- protected static final void assertCommit(final ListenableFuture<?> commit, long timeoutInMS) {
+ protected static final void assertCommit(final ListenableFuture<?> commit, final long timeoutInMS) {
try {
commit.get(timeoutInMS, TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
package org.opendaylight.mdsal.binding.dom.adapter.test;
import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
/**
* Abstract base for DataBroker tests. Note that it performs synchronous commits via a direct executor which can cause
}
@Override
- protected void setupWithSchema(SchemaContext context) {
+ protected void setupWithSchema(final EffectiveModelContext context) {
super.setupWithSchema(context);
setupWithDataBroker(getDataBroker());
}
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.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public abstract class AbstractDataBrokerTestCustomizer {
return this.datastores;
}
- public void updateSchema(final SchemaContext ctx) {
+ public void updateSchema(final EffectiveModelContext ctx) {
this.schemaService.changeSchema(ctx);
}
import org.opendaylight.mdsal.binding.api.NotificationService;
import org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec;
import org.opendaylight.mdsal.dom.broker.DOMNotificationRouter;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class AbstractNotificationBrokerTest extends AbstractSchemaAwareTest {
private BindingToNormalizedNodeCodec bindingToNormalizedNodeCodec;
@Override
- protected void setupWithSchema(final SchemaContext context) {
+ protected void setupWithSchema(final EffectiveModelContext context) {
final DataBrokerTestCustomizer testCustomizer = createDataBrokerTestCustomizer();
domNotificationRouter = testCustomizer.getDomNotificationRouter();
notificationService = testCustomizer.createNotificationService();
import org.opendaylight.binding.runtime.spi.ModuleInfoBackedContext;
import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public abstract class AbstractSchemaAwareTest {
- private static final LoadingCache<Set<YangModuleInfo>, SchemaContext> SCHEMA_CONTEXT_CACHE =
- CacheBuilder.newBuilder().weakValues().build(new CacheLoader<Set<YangModuleInfo>, SchemaContext>() {
- @Override
- public SchemaContext load(final Set<YangModuleInfo> key) {
- return ModuleInfoBackedContext.cacheContext(
- GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), ImmutableSet.copyOf(key))
- .tryToCreateModelContext().get();
- }
- });
+ private static final LoadingCache<Set<YangModuleInfo>, EffectiveModelContext> SCHEMA_CONTEXT_CACHE =
+ CacheBuilder.newBuilder().weakValues().build(
+ new CacheLoader<Set<YangModuleInfo>, EffectiveModelContext>() {
+ @Override
+ public EffectiveModelContext load(final Set<YangModuleInfo> key) {
+ return ModuleInfoBackedContext.cacheContext(
+ GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), ImmutableSet.copyOf(key))
+ .tryToCreateModelContext().get();
+ }
+ });
@Before
public final void setup() throws Exception {
return BindingReflections.cacheModuleInfos(Thread.currentThread().getContextClassLoader());
}
- protected SchemaContext getSchemaContext() throws Exception {
+ protected EffectiveModelContext getSchemaContext() throws Exception {
return SCHEMA_CONTEXT_CACHE.getUnchecked(getModuleInfos());
}
*
* @param context schema context
*/
- protected abstract void setupWithSchema(SchemaContext context);
+ protected abstract void setupWithSchema(EffectiveModelContext context);
}
import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension;
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;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
-public final class MockSchemaService implements DOMSchemaService, SchemaContextProvider {
+public final class MockSchemaService implements DOMSchemaService, EffectiveModelContextProvider {
- private SchemaContext schemaContext;
+ private EffectiveModelContext schemaContext;
- final ListenerRegistry<SchemaContextListener> listeners = ListenerRegistry.create();
+ final ListenerRegistry<EffectiveModelContextListener> listeners = ListenerRegistry.create();
@Override
- public synchronized SchemaContext getGlobalContext() {
+ public synchronized EffectiveModelContext getGlobalContext() {
return schemaContext;
}
@Override
- public synchronized SchemaContext getSessionContext() {
- return schemaContext;
- }
-
- @Override
- public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
- final SchemaContextListener listener) {
+ public ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
+ final EffectiveModelContextListener listener) {
return listeners.register(listener);
}
@Override
- public synchronized SchemaContext getSchemaContext() {
+ public synchronized EffectiveModelContext getEffectiveModelContext() {
return schemaContext;
}
return ImmutableClassToInstanceMap.of();
}
- public synchronized void changeSchema(final SchemaContext newContext) {
+ public synchronized void changeSchema(final EffectiveModelContext newContext) {
schemaContext = newContext;
- listeners.streamListeners().forEach(listener -> listener.onGlobalContextUpdated(schemaContext));
+ listeners.streamListeners().forEach(listener -> listener.onModelContextUpdated(schemaContext));
}
}
package org.opendaylight.mdsal.dom.api;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
public interface DOMSchemaService extends DOMExtensibleService<DOMSchemaService, DOMSchemaServiceExtension> {
/**
* Returns session specific YANG schema context.
*
* @return schemaContext
+ * @deprecated This method never fully materialized, use {@link #getGlobalContext()} instead.
*/
- SchemaContext getSessionContext();
+ @Deprecated
+ default EffectiveModelContext getSessionContext() {
+ throw new UnsupportedOperationException("getSessionContext() is not specified nor implemented");
+ }
/**
* Returns global schema context.
*
* @return schemaContext
*/
- SchemaContext getGlobalContext();
+ EffectiveModelContext getGlobalContext();
/**
* Register a listener for changes in schema context.
* @param listener Listener which should be registered
* @return Listener registration handle
*/
- ListenerRegistration<SchemaContextListener> registerSchemaContextListener(SchemaContextListener listener);
+ ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
+ EffectiveModelContextListener listener);
}
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
/**
abstract class AbstractDOMRoutingTable<I, D, M, L extends EventListener,
E extends AbstractDOMRoutingTableEntry<D, M, L>> {
private final Map<SchemaPath, E> operations;
- private final SchemaContext schemaContext;
+ private final EffectiveModelContext schemaContext;
- AbstractDOMRoutingTable(final Map<SchemaPath, E> operations,
- final SchemaContext schemaContext) {
+ AbstractDOMRoutingTable(final Map<SchemaPath, E> operations, final EffectiveModelContext schemaContext) {
this.operations = requireNonNull(operations);
this.schemaContext = schemaContext;
}
- AbstractDOMRoutingTable<I, D, M, L, E> setSchemaContext(final SchemaContext context) {
+ AbstractDOMRoutingTable<I, D, M, L, E> setSchemaContext(final EffectiveModelContext context) {
final Builder<SchemaPath, E> b = ImmutableMap.builder();
for (Entry<SchemaPath, E> e : operations.entrySet()) {
}
protected abstract AbstractDOMRoutingTable<I, D, M, L, E> newInstance(Map<SchemaPath, E> operations,
- SchemaContext schemaContext);
+ EffectiveModelContext schemaContext);
abstract ListMultimap<SchemaPath, D> decomposeIdentifiers(Set<I> instances);
- abstract E createOperationEntry(SchemaContext context, SchemaPath key, Map<D, List<M>> implementations);
+ abstract E createOperationEntry(EffectiveModelContext context, SchemaPath key, Map<D, List<M>> implementations);
}
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
import org.opendaylight.yangtools.yang.model.api.ActionNodeContainer;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
static final DOMActionRoutingTable EMPTY = new DOMActionRoutingTable(ImmutableMap.of(), null);
private DOMActionRoutingTable(final Map<SchemaPath, DOMActionRoutingTableEntry> actions,
- final SchemaContext schemaContext) {
+ final EffectiveModelContext schemaContext) {
super(actions, schemaContext);
}
@Override
protected DOMActionRoutingTable newInstance(final Map<SchemaPath, DOMActionRoutingTableEntry> operations,
- final SchemaContext schemaContext) {
+ final EffectiveModelContext schemaContext) {
return new DOMActionRoutingTable(operations, schemaContext);
}
}
@Override
- protected DOMActionRoutingTableEntry createOperationEntry(final SchemaContext context, final SchemaPath type,
- final Map<DOMDataTreeIdentifier, List<DOMActionImplementation>> implementations) {
+ protected DOMActionRoutingTableEntry createOperationEntry(final EffectiveModelContext context,
+ final SchemaPath type, final Map<DOMDataTreeIdentifier, List<DOMActionImplementation>> implementations) {
final ActionDefinition actionDef = findActionDefinition(context, type);
if (actionDef == null) {
//FIXME: return null directly instead of providing kind of unknown entry.
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public final class DOMRpcRouter extends AbstractRegistration implements SchemaContextListener {
+public final class DOMRpcRouter extends AbstractRegistration implements EffectiveModelContextListener {
private static final ThreadFactory THREAD_FACTORY = new ThreadFactoryBuilder().setNameFormat(
"DOMRpcRouter-listener-%s").setDaemon(true).build();
}
@Override
- public synchronized void onGlobalContextUpdated(final SchemaContext context) {
+ public synchronized void onModelContextUpdated(final EffectiveModelContext newModelContext) {
final DOMRpcRoutingTable oldTable = routingTable;
- final DOMRpcRoutingTable newTable = (DOMRpcRoutingTable) oldTable.setSchemaContext(context);
+ final DOMRpcRoutingTable newTable = (DOMRpcRoutingTable) oldTable.setSchemaContext(newModelContext);
routingTable = newTable;
final DOMActionRoutingTable oldActionTable = actionRoutingTable;
- final DOMActionRoutingTable newActionTable = (DOMActionRoutingTable) oldActionTable.setSchemaContext(context);
+ final DOMActionRoutingTable newActionTable =
+ (DOMActionRoutingTable) oldActionTable.setSchemaContext(newModelContext);
actionRoutingTable = newActionTable;
}
import org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
static final DOMRpcRoutingTable EMPTY = new DOMRpcRoutingTable(ImmutableMap.of(), null);
private DOMRpcRoutingTable(final Map<SchemaPath, AbstractDOMRpcRoutingTableEntry> rpcs,
- final SchemaContext schemaContext) {
+ final EffectiveModelContext schemaContext) {
super(rpcs, schemaContext);
}
@Override
protected DOMRpcRoutingTable newInstance(final Map<SchemaPath, AbstractDOMRpcRoutingTableEntry> operations,
- final SchemaContext schemaContext) {
+ final EffectiveModelContext schemaContext) {
return new DOMRpcRoutingTable(operations, schemaContext);
}
}
@Override
- AbstractDOMRpcRoutingTableEntry createOperationEntry(final SchemaContext context, final SchemaPath key,
+ AbstractDOMRpcRoutingTableEntry createOperationEntry(final EffectiveModelContext context, final SchemaPath key,
final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> implementations) {
final RpcDefinition rpcDef = findRpcDefinition(context, key);
if (rpcDef == null) {
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.Registration;
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.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
private final YangTextSchemaContextResolver contextResolver = YangTextSchemaContextResolver.create("global-bundle");
@GuardedBy("lock")
- private final ListenerRegistry<SchemaContextListener> listeners = ListenerRegistry.create();
+ private final ListenerRegistry<EffectiveModelContextListener> listeners = ListenerRegistry.create();
private final Object lock = new Object();
public void tryToUpdateSchemaContext() {
synchronized (lock) {
- final Optional<? extends SchemaContext> optSchema = contextResolver.getSchemaContext();
+ final Optional<? extends EffectiveModelContext> optSchema = contextResolver.getEffectiveModelContext();
optSchema.ifPresent(schema -> {
if (LOG.isDebugEnabled()) {
LOG.debug("Got new SchemaContext: # of modules {}", schema.getModules().size());
@VisibleForTesting
@SuppressWarnings("checkstyle:IllegalCatch")
- public void notifyListeners(final SchemaContext schemaContext) {
+ public void notifyListeners(final EffectiveModelContext schemaContext) {
synchronized (lock) {
listeners.streamListeners().forEach(listener -> {
try {
- listener.onGlobalContextUpdated(schemaContext);
+ listener.onModelContextUpdated(schemaContext);
} catch (final Exception e) {
LOG.error("Exception occured during invoking listener {}", listener, e);
}
}
@Override
- public SchemaContext getGlobalContext() {
- return contextResolver.getSchemaContext().orElse(null);
+ public EffectiveModelContext getGlobalContext() {
+ return contextResolver.getEffectiveModelContext().orElse(null);
}
@Override
- public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
- final SchemaContextListener listener) {
+ public ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
+ final EffectiveModelContextListener listener) {
synchronized (lock) {
- contextResolver.getSchemaContext().ifPresent(listener::onGlobalContextUpdated);
+ contextResolver.getEffectiveModelContext().ifPresent(listener::onModelContextUpdated);
return listeners.register(listener);
}
}
final InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG",
MoreExecutors.newDirectExecutorService());
- operStore.onGlobalContextUpdated(SCHEMA_CONTEXT);
- configStore.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ operStore.onModelContextUpdated(SCHEMA_CONTEXT);
+ configStore.onModelContextUpdated(SCHEMA_CONTEXT);
final ImmutableMap<LogicalDatastoreType, DOMStore> stores =
ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
@Before
public void setUp() {
domStore = new InMemoryDOMDataStore("Mdsal217", MoreExecutors.newDirectExecutorService());
- domStore.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ domStore.onModelContextUpdated(SCHEMA_CONTEXT);
}
@Test
final InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG",
MoreExecutors.newDirectExecutorService());
- operStore.onGlobalContextUpdated(SCHEMA_CONTEXT);
- configStore.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ operStore.onModelContextUpdated(SCHEMA_CONTEXT);
+ configStore.onModelContextUpdated(SCHEMA_CONTEXT);
final ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType,
DOMStore>builder()
final DOMRpcRoutingTable routingTableOriginal = rpcRouter.routingTable();
- rpcRouter.onGlobalContextUpdated(TestModel.createTestContext());
+ rpcRouter.onModelContextUpdated(TestModel.createTestContext());
final DOMRpcRoutingTable routingTableChanged = rpcRouter.routingTable();
assertNotEquals(routingTableOriginal, routingTableChanged);
final InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG",
MoreExecutors.newDirectExecutorService());
- operStore.onGlobalContextUpdated(SCHEMA_CONTEXT);
- configStore.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ operStore.onModelContextUpdated(SCHEMA_CONTEXT);
+ configStore.onModelContextUpdated(SCHEMA_CONTEXT);
final ImmutableMap<LogicalDatastoreType, DOMStore> stores =
ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
MockitoAnnotations.initMocks(this);
rootShard = InMemoryDOMDataTreeShard.create(ROOT_ID, executor, 1);
- rootShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ rootShard.onModelContextUpdated(SCHEMA_CONTEXT);
final ShardedDOMDataTree dataTree = new ShardedDOMDataTree();
final DOMDataTreeProducer shardRegProducer = dataTree.createProducer(Collections.singletonList(ROOT_ID));
doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap());
final InMemoryDOMDataTreeShard innerShard = InMemoryDOMDataTreeShard.create(INNER_CONTAINER_ID, executor, 1);
- innerShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ innerShard.onModelContextUpdated(SCHEMA_CONTEXT);
final DOMDataTreeProducer shardRegProducer =
dataTreeService.createProducer(Collections.singletonList(INNER_CONTAINER_ID));
innerShardReg = dataTreeService.registerDataTreeShard(INNER_CONTAINER_ID, innerShard, shardRegProducer);
@Test
public void testMultipleShardsProducerClose() throws Exception {
final InMemoryDOMDataTreeShard innerShard = InMemoryDOMDataTreeShard.create(INNER_CONTAINER_ID, executor, 1);
- innerShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ innerShard.onModelContextUpdated(SCHEMA_CONTEXT);
assertTrue(rootShard.getProducers().isEmpty());
@Test
public void testMultipleShardsChildProducerClose() throws Exception {
final InMemoryDOMDataTreeShard innerShard = InMemoryDOMDataTreeShard.create(INNER_CONTAINER_ID, executor, 1);
- innerShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ innerShard.onModelContextUpdated(SCHEMA_CONTEXT);
final DOMDataTreeProducer innerShardRegProducer =
dataTreeService.createProducer(Collections.singletonList(INNER_CONTAINER_ID));
@Test
public void testMultipleShardsProducerCloseForSubshardAttached() throws Exception {
final InMemoryDOMDataTreeShard innerShard = InMemoryDOMDataTreeShard.create(INNER_CONTAINER_ID, executor, 1);
- innerShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ innerShard.onModelContextUpdated(SCHEMA_CONTEXT);
final DOMDataTreeProducer innerShardRegProducer =
dataTreeService.createProducer(Collections.singletonList(INNER_CONTAINER_ID));
Collections.singletonList(INNER_CONTAINER_ID).toString());
final InMemoryDOMDataTreeShard test2Shard = InMemoryDOMDataTreeShard.create(TEST2_ID, executor, 1);
- innerShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ innerShard.onModelContextUpdated(SCHEMA_CONTEXT);
final DOMDataTreeProducer test2ShardRegProducer =
dataTreeService.createProducer(Collections.singletonList(TEST2_ID));
MockitoAnnotations.initMocks(this);
rootShard = InMemoryDOMDataTreeShard.create(ROOT_ID, executor, 1);
- rootShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ rootShard.onModelContextUpdated(SCHEMA_CONTEXT);
final ShardedDOMDataTree dataTree = new ShardedDOMDataTree();
final DOMDataTreeProducer shardRegProducer = dataTree.createProducer(Collections.singletonList(ROOT_ID));
rootShardReg.close();
final InMemoryDOMDataTreeShard newRootShard = InMemoryDOMDataTreeShard.create(ROOT_ID, executor, 1);
- newRootShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ newRootShard.onModelContextUpdated(SCHEMA_CONTEXT);
final DOMDataTreeProducer shardRegProducer = dataTreeService.createProducer(Collections.singletonList(ROOT_ID));
final ListenerRegistration<InMemoryDOMDataTreeShard> newRootShardReg =
shardRegProducer.close();
final InMemoryDOMDataTreeShard innerShard = InMemoryDOMDataTreeShard.create(INNER_CONTAINER_ID, executor, 1);
- innerShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ innerShard.onModelContextUpdated(SCHEMA_CONTEXT);
final DOMDataTreeProducer shardRegProducer2 =
dataTreeService.createProducer(Collections.singletonList(INNER_CONTAINER_ID));
ListenerRegistration<InMemoryDOMDataTreeShard> innerShardReg =
doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap());
InMemoryDOMDataTreeShard testShard = InMemoryDOMDataTreeShard.create(TEST_ID, executor, 1);
- testShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ testShard.onModelContextUpdated(SCHEMA_CONTEXT);
final DOMDataTreeProducer regProducer = dataTreeService.createProducer(Collections.singleton(TEST_ID));
dataTreeService.registerDataTreeShard(TEST_ID, testShard, regProducer);
final DOMDataTreeProducer shardProducer = dataTreeService.createProducer(
Collections.singletonList(outerListPath));
final InMemoryDOMDataTreeShard outerListShard = InMemoryDOMDataTreeShard.create(outerListPath, executor, 1000);
- outerListShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ outerListShard.onModelContextUpdated(SCHEMA_CONTEXT);
final ListenerRegistration<InMemoryDOMDataTreeShard> oid1ShardRegistration =
dataTreeService.registerDataTreeShard(outerListPath, outerListShard, shardProducer);
public void testLargerSubshardSpace() throws Exception {
final InMemoryDOMDataTreeShard outerListShard = InMemoryDOMDataTreeShard.create(OUTER_LIST_ID, executor, 1, 1);
- outerListShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ outerListShard.onModelContextUpdated(SCHEMA_CONTEXT);
try (DOMDataTreeProducer producer =
dataTreeService.createProducer(Collections.singletonList(OUTER_LIST_ID))) {
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
assertFalse(schemaService.hasListeners());
final SchemaContextHolder actualSchemaCtx = new SchemaContextHolder();
- final SchemaContextListener listener = actualSchemaCtx::setSchemaContext;
- final ListenerRegistration<SchemaContextListener> registerSchemaContextListener =
+ final EffectiveModelContextListener listener = actualSchemaCtx::setSchemaContext;
+ final ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener =
schemaService.registerSchemaContextListener(listener);
assertEquals(registerSchemaContextListener.getInstance(), listener);
assertEquals(schemaService.getSchemaContext(), actualSchemaCtx.getSchemaContext());
@Test
public void notifyListenersTest() {
- final SchemaContext baseSchemaCtx = schemaService.getGlobalContext();
+ final EffectiveModelContext baseSchemaCtx = schemaService.getGlobalContext();
assertNotNull(baseSchemaCtx);
assertTrue(baseSchemaCtx.getModules().size() == 1);
final SchemaContextHolder actualSchemaCtx = new SchemaContextHolder();
- final SchemaContextListener schemaCtxListener = actualSchemaCtx::setSchemaContext;
- final ListenerRegistration<SchemaContextListener> registerSchemaContextListener =
+ final EffectiveModelContextListener schemaCtxListener = actualSchemaCtx::setSchemaContext;
+ final ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener =
schemaService.registerSchemaContextListener(schemaCtxListener);
assertEquals(registerSchemaContextListener.getInstance(), schemaCtxListener);
assertNotNull(actualSchemaCtx.getSchemaContext());
addYang("/empty-test1.yang");
addYangs(schemaService);
- final SchemaContext nextSchemaCtx = schemaService.getGlobalContext();
+ final EffectiveModelContext nextSchemaCtx = schemaService.getGlobalContext();
assertNotNull(nextSchemaCtx);
assertTrue(nextSchemaCtx.getModules().size() == 2);
addYang("/empty-test2.yang");
addYangs(schemaService);
- final SchemaContext unregistredListenerSchemaCtx = schemaService.getGlobalContext();
+ final EffectiveModelContext unregistredListenerSchemaCtx = schemaService.getGlobalContext();
assertNotNull(unregistredListenerSchemaCtx);
assertTrue(unregistredListenerSchemaCtx.getModules().size() == 3);
private class SchemaContextHolder {
- private SchemaContext schemaCtx;
+ private EffectiveModelContext schemaCtx;
- public void setSchemaContext(final SchemaContext ctx) {
+ public void setSchemaContext(final EffectiveModelContext ctx) {
schemaCtx = ctx;
}
- public SchemaContext getSchemaContext() {
+ public EffectiveModelContext getSchemaContext() {
return schemaCtx;
}
}
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * In-memory DOM Data Store.
- *
- *<p>
- * Implementation of {@link DOMStore} which uses {@link DataTree} and other
- * classes such as {@link SnapshotBackedWriteTransaction}.
- * {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedReadTransaction} to implement {@link DOMStore}
- * contract.
- *
+ * In-memory DOM Data Store. Implementation of {@link DOMStore} which uses {@link DataTree} and other classes such as
+ * {@link SnapshotBackedWriteTransaction}.
+ * {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedReadTransaction} to implement {@link DOMStore} contract.
*/
public class InMemoryDOMDataStore extends TransactionReadyPrototype<String> implements DOMStore,
- Identifiable<String>, SchemaContextListener, AutoCloseable, DOMStoreTreeChangePublisher {
+ Identifiable<String>, EffectiveModelContextListener, AutoCloseable, DOMStoreTreeChangePublisher {
private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataStore.class);
private final AtomicLong txCounter = new AtomicLong(0);
}
@Override
- public synchronized void onGlobalContextUpdated(final SchemaContext ctx) {
- dataTree.setSchemaContext(ctx);
+ public synchronized void onModelContextUpdated(final EffectiveModelContext newModelContext) {
+ dataTree.setEffectiveModelContext(newModelContext);
}
@SuppressWarnings("checkstyle:IllegalCatch")
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Beta
-public class InMemoryDOMDataTreeShard implements ReadableWriteableDOMDataTreeShard, SchemaContextListener {
+public class InMemoryDOMDataTreeShard implements ReadableWriteableDOMDataTreeShard, EffectiveModelContextListener {
private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataTreeShard.class);
private static final int DEFAULT_SUBMIT_QUEUE_SIZE = 1000;
}
@Override
- public void onGlobalContextUpdated(final SchemaContext context) {
- dataTree.setSchemaContext(context);
+ public void onModelContextUpdated(final EffectiveModelContext newModelContext) {
+ dataTree.setEffectiveModelContext(newModelContext);
}
@Override
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
public class InMemoryDOMDataStoreFactoryTest {
public void basicTest() throws Exception {
final String testStoreName = "TestStore";
final DOMSchemaService domSchemaService = mock(DOMSchemaService.class);
- doReturn(null).when(domSchemaService).registerSchemaContextListener(any(SchemaContextListener.class));
+ doReturn(null).when(domSchemaService).registerSchemaContextListener(any(EffectiveModelContextListener.class));
final InMemoryDOMDataStore inMemoryDOMDataStore =
InMemoryDOMDataStoreFactory.create(testStoreName, domSchemaService);
doReturn("testListener").when(domDataTreeChangeListener).toString();
doNothing().when(domDataTreeChangeListener).onDataTreeChanged(any());
doNothing().when(domDataTreeChangeListener).onInitialData();
- inMemoryDOMDataStore.onGlobalContextUpdated(TestModel.createTestContext());
+ inMemoryDOMDataStore.onModelContextUpdated(TestModel.createTestContext());
inMemoryDOMDataStore.registerTreeChangeListener(YangInstanceIdentifier.empty(), domDataTreeChangeListener);
final AutoCloseable autoCloseable = mock(AutoCloseable.class);
doReturn(inMemoryDOMDataTreeShard.createModificationFactory(prefixes))
.when(mockProducer).getModificationFactory();
- inMemoryDOMDataTreeShard.onGlobalContextUpdated(createTestContext());
+ inMemoryDOMDataTreeShard.onModelContextUpdated(createTestContext());
inMemoryDOMDataTreeShard.createTransaction("", mockProducer, mock(CursorAwareDataTreeSnapshot.class));
final DOMDataTreeChangeListener domDataTreeChangeListener = mock(DOMDataTreeChangeListener.class);
import com.google.common.util.concurrent.MoreExecutors;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
+import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class InMemoryDataStoreTest {
+ private static EffectiveModelContext SCHEMA_CONTEXT;
- private SchemaContext schemaContext;
private InMemoryDOMDataStore domStore;
+ @BeforeClass
+ public static void beforeClass() {
+ SCHEMA_CONTEXT = TestModel.createTestContext();
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ SCHEMA_CONTEXT = null;
+ }
+
@Before
public void setupStore() {
domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService());
- schemaContext = TestModel.createTestContext();
- domStore.onGlobalContextUpdated(schemaContext);
+ domStore.onModelContextUpdated(SCHEMA_CONTEXT);
}
@Test
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public final class TestModel {
throw new UnsupportedOperationException();
}
- public static SchemaContext createTestContext() {
+ public static EffectiveModelContext createTestContext() {
return YangParserTestUtils.parseYangResource("/odl-datastore-test.yang");
}
}
import java.util.Hashtable;
import java.util.Map;
import org.gaul.modernizer_maven_annotations.SuppressModernizer;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
/**
- * A Factory Component which implements {@link SchemaContextListener}. Instances of this component are created through
- * by {@link OSGiDOMSchemaService} each time a listener is registered.
+ * A Factory Component which implements {@link EffectiveModelContextListener}. Instances of this component are created
+ * through by {@link OSGiDOMSchemaService} each time a listener is registered.
*/
-@Component(factory = SchemaSchemaContextListenerImpl.FACTORY_NAME, service = SchemaContextListener.class)
-public final class SchemaSchemaContextListenerImpl implements SchemaContextListener {
+@Component(factory = EffectiveModelContextImpl.FACTORY_NAME, service = EffectiveModelContextListener.class)
+public final class EffectiveModelContextImpl implements EffectiveModelContextListener {
static final String FACTORY_NAME = "org.opendaylight.mdsal.dom.schema.osgi.impl.SchemaSchemaContextListener";
@VisibleForTesting
static final String DELEGATE = "org.opendaylight.mdsal.dom.schema.osgi.SchemaSchemaContextListener";
- private SchemaContextListener delegate = null;
+ private EffectiveModelContextListener delegate = null;
@Override
- public void onGlobalContextUpdated(final SchemaContext context) {
- delegate.onGlobalContextUpdated(context);
+ public void onModelContextUpdated(final EffectiveModelContext newModelContext) {
+ delegate.onModelContextUpdated(newModelContext);
}
@Activate
void activate(final Map<String, ?> properties) {
- delegate = (SchemaContextListener) verifyNotNull(properties.get(DELEGATE));
+ delegate = (EffectiveModelContextListener) verifyNotNull(properties.get(DELEGATE));
}
@Deactivate
}
@SuppressModernizer
- static Dictionary<String, ?> props(final SchemaContextListener delegate) {
+ static Dictionary<String, ?> props(final EffectiveModelContextListener delegate) {
final Dictionary<String, Object> ret = new Hashtable<>(2);
ret.put(DELEGATE, requireNonNull(delegate));
return ret;
import org.opendaylight.mdsal.dom.spi.AbstractDOMSchemaService;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.osgi.service.component.ComponentFactory;
import org.osgi.service.component.ComponentInstance;
import org.osgi.service.component.annotations.Activate;
public final class OSGiDOMSchemaService extends AbstractDOMSchemaService {
private static final Logger LOG = LoggerFactory.getLogger(OSGiDOMSchemaService.class);
- @Reference(target = "(component.factory=" + SchemaSchemaContextListenerImpl.FACTORY_NAME + ")")
+ @Reference(target = "(component.factory=" + EffectiveModelContextImpl.FACTORY_NAME + ")")
ComponentFactory listenerFactory = null;
- private final List<SchemaContextListener> listeners = new CopyOnWriteArrayList<>();
+ private final List<EffectiveModelContextListener> listeners = new CopyOnWriteArrayList<>();
private volatile ModuleInfoSnapshot currentSnapshot;
}
@Override
- public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
- final SchemaContextListener listener) {
+ public ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
+ final EffectiveModelContextListener listener) {
return registerListener(requireNonNull(listener));
}
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC,
policyOption = ReferencePolicyOption.GREEDY)
- void addListener(final SchemaContextListener listener) {
+ void addListener(final EffectiveModelContextListener listener) {
LOG.trace("Adding listener {}", listener);
listeners.add(listener);
- listener.onGlobalContextUpdated(getGlobalContext());
+ listener.onModelContextUpdated(getGlobalContext());
}
- void removeListener(final SchemaContextListener listener) {
+ void removeListener(final EffectiveModelContextListener listener) {
LOG.trace("Removing listener {}", listener);
listeners.remove(listener);
}
LOG.info("DOM Schema services deactivated");
}
- private @NonNull ListenerRegistration<SchemaContextListener> registerListener(
- final @NonNull SchemaContextListener listener) {
- final ComponentInstance reg = listenerFactory.newInstance(SchemaSchemaContextListenerImpl.props(listener));
+ private @NonNull ListenerRegistration<EffectiveModelContextListener> registerListener(
+ final @NonNull EffectiveModelContextListener listener) {
+ final ComponentInstance reg = listenerFactory.newInstance(EffectiveModelContextImpl.props(listener));
return new ListenerRegistration<>() {
@Override
- public SchemaContextListener getInstance() {
+ public EffectiveModelContextListener getInstance() {
return listener;
}
}
@SuppressWarnings("checkstyle:illegalCatch")
- private static void notifyListener(final SchemaContext context, final SchemaContextListener listener) {
+ private static void notifyListener(final EffectiveModelContext context,
+ final EffectiveModelContextListener listener) {
try {
- listener.onGlobalContextUpdated(context);
+ listener.onModelContextUpdated(context);
} catch (RuntimeException e) {
LOG.warn("Failed to notify listener {}", listener, e);
}
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public final class TestModel {
}
- public static SchemaContext createTestContext() {
+ public static EffectiveModelContext createTestContext() {
return YangParserTestUtils.parseYangResource("/odl-datastore-test.yang");
}
}
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension;
import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
/**
* Base class to implement DOMSchemaService more easily while providing a bridge between MD-SAL DOM Schema services
*/
@Beta
@NonNullByDefault
-public abstract class AbstractDOMSchemaService implements DOMSchemaService, SchemaContextProvider {
+public abstract class AbstractDOMSchemaService implements DOMSchemaService, EffectiveModelContextProvider {
public abstract static class WithYangTextSources extends AbstractDOMSchemaService
implements DOMYangTextSourceProvider {
@Override
}
@Override
- public final SchemaContext getSchemaContext() {
+ public final EffectiveModelContext getEffectiveModelContext() {
// Always route context queries to a single method
return getGlobalContext();
}
@Override
- public final SchemaContext getSessionContext() {
+ public final EffectiveModelContext getSessionContext() {
// This method should not be implemented
throw new UnsupportedOperationException();
}
import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.NoOpListenerRegistration;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
private static final class WithYangTextSources extends FixedDOMSchemaService implements DOMYangTextSourceProvider {
private final @NonNull SchemaSourceProvider<YangTextSchemaSource> schemaSourceProvider;
- WithYangTextSources(final SchemaContextProvider schemaContextProvider,
+ WithYangTextSources(final EffectiveModelContextProvider schemaContextProvider,
final SchemaSourceProvider<YangTextSchemaSource> schemaSourceProvider) {
super(schemaContextProvider);
this.schemaSourceProvider = requireNonNull(schemaSourceProvider);
}
}
- private final @NonNull SchemaContextProvider schemaContextProvider;
+ private final @NonNull EffectiveModelContextProvider schemaContextProvider;
- private FixedDOMSchemaService(final SchemaContextProvider schemaContextProvider) {
+ private FixedDOMSchemaService(final EffectiveModelContextProvider schemaContextProvider) {
this.schemaContextProvider = requireNonNull(schemaContextProvider);
}
- public static @NonNull DOMSchemaService of(final SchemaContextProvider schemaContextProvider) {
+ public static @NonNull DOMSchemaService of(final EffectiveModelContextProvider schemaContextProvider) {
return new FixedDOMSchemaService(schemaContextProvider);
}
- public static @NonNull DOMSchemaService of(final SchemaContextProvider schemaContextProvider,
+ public static @NonNull DOMSchemaService of(final EffectiveModelContextProvider schemaContextProvider,
final SchemaSourceProvider<YangTextSchemaSource> yangTextSourceProvider) {
return new WithYangTextSources(schemaContextProvider, requireNonNull(yangTextSourceProvider));
}
@Override
- public final SchemaContext getGlobalContext() {
- return schemaContextProvider.getSchemaContext();
+ public final EffectiveModelContext getGlobalContext() {
+ return schemaContextProvider.getEffectiveModelContext();
}
@Override
- public final @NonNull ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
- final SchemaContextListener listener) {
- listener.onGlobalContextUpdated(getGlobalContext());
+ public final @NonNull ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
+ final EffectiveModelContextListener listener) {
+ listener.onModelContextUpdated(getGlobalContext());
return NoOpListenerRegistration.of(listener);
}
}