import org.opendaylight.controller.netconf.notifications.BaseNetconfNotificationListener;
import org.opendaylight.controller.netconf.notifications.BaseNotificationPublisherRegistration;
import org.opendaylight.controller.netconf.notifications.NetconfNotificationCollector;
+import org.opendaylight.controller.netconf.util.capability.YangModuleCapability;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange;
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) {
- if(ref.get() == null || ref.get().get() == null) {
- getYangStoreSnapshot();
+
+ YangStoreContext context = ref.get().get();
+
+ if(context == null) {
+ context = getYangStoreSnapshot();
}
this.listeners.add(listener);
- listener.onCapabilitiesAdded(NetconfOperationServiceFactoryImpl.setupCapabilities(ref.get().get()));
+ listener.onCapabilitiesAdded(NetconfOperationServiceFactoryImpl.setupCapabilities(context));
return new AutoCloseable() {
@Override
private static final Function<Module, Capability> MODULE_TO_CAPABILITY = new Function<Module, Capability>() {
@Override
public Capability apply(final Module module) {
- return new NetconfOperationServiceFactoryImpl.YangStoreCapability(module, module.getSource());
+ return new YangModuleCapability(module, module.getSource());
}
};
private static final Function<Module, Uri> MODULE_TO_URI = new Function<Module, Uri>() {
@Override
public Uri apply(final Module input) {
- return new Uri(new NetconfOperationServiceFactoryImpl.YangStoreCapability(input, input.getSource()).getCapabilityUri());
+ return new Uri(new YangModuleCapability(input, input.getSource()).getCapabilityUri());
}
};