import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.ChangedByBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.changed.by.server.or.user.ServerBuilder;
+import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
*
* We synchronize with GC as usual, using a SoftReference.
*
- * The atomic reference is used to synchronize with {@link #refresh()}, e.g. when
+ * The atomic reference is used to synchronize with {@link #refresh(org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext)}, e.g. when
* refresh happens, it will push a SoftReference(null), e.g. simulate the GC. Now
* that may happen while the getter is already busy acting on the old schema context,
* so it needs to understand that a refresh has happened and retry. To do that, it
private final AtomicReference<SoftReference<YangStoreSnapshot>> ref =
new AtomicReference<>(new SoftReference<YangStoreSnapshot>(null));
+ private final AtomicReference<SoftReference<BindingRuntimeContext>> refBindingContext =
+ new AtomicReference<>(new SoftReference<BindingRuntimeContext>(null));
+
private final SchemaContextProvider schemaContextProvider;
private final BaseNetconfNotificationListener notificationPublisher;
while (ret == null) {
// We need to be compute a new value
- ret = new YangStoreSnapshot(schemaContextProvider.getSchemaContext());
+ ret = new YangStoreSnapshot(schemaContextProvider.getSchemaContext(), refBindingContext.get().get());
if (!ref.compareAndSet(r, new SoftReference<>(ret))) {
LOG.debug("Concurrent refresh detected, recomputing snapshot");
return getYangStoreSnapshot().getModuleSource(moduleIdentifier);
}
- public void refresh() {
+ @Override
+ public EnumResolver getEnumResolver() {
+ return getYangStoreSnapshot().getEnumResolver();
+ }
+
+ public void refresh(final BindingRuntimeContext runtimeContext) {
final YangStoreSnapshot previous = ref.get().get();
ref.set(new SoftReference<YangStoreSnapshot>(null));
+ refBindingContext.set(new SoftReference<>(runtimeContext));
notificationExecutor.submit(new CapabilityChangeNotifier(previous));
}
public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
- final SoftReference<YangStoreSnapshot> yangStoreSnapshotSoftReference = ref.get();
- YangStoreContext ret = yangStoreSnapshotSoftReference != null ? yangStoreSnapshotSoftReference.get() : null;
- if(ret == null) {
- ret = getYangStoreSnapshot();
+ YangStoreContext context = ref.get().get();
+
+ if(context == null) {
+ context = getYangStoreSnapshot();
}
this.listeners.add(listener);
- listener.onCapabilitiesAdded(NetconfOperationServiceFactoryImpl.setupCapabilities(ret));
+ listener.onCapabilitiesAdded(NetconfOperationServiceFactoryImpl.setupCapabilities(context));
return new AutoCloseable() {
@Override