+
+ private static final class RuntimeGeneratedMappingServiceProxy implements //
+ BindingIndependentMappingService, //
+ Delegator<BindingIndependentMappingService>, //
+ AutoCloseable {
+
+ private BindingIndependentMappingService delegate;
+ private ServiceReference<BindingIndependentMappingService> reference;
+ private BundleContext bundleContext;
+
+ public RuntimeGeneratedMappingServiceProxy(BundleContext bundleContext,
+ ServiceReference<BindingIndependentMappingService> serviceRef,
+ BindingIndependentMappingService delegate) {
+ this.bundleContext = Preconditions.checkNotNull(bundleContext);
+ this.reference = Preconditions.checkNotNull(serviceRef);
+ this.delegate = Preconditions.checkNotNull(delegate);
+ }
+
+ @Override
+ public CodecRegistry getCodecRegistry() {
+ return delegate.getCodecRegistry();
+ }
+
+ @Override
+ public CompositeNode toDataDom(DataObject data) {
+ return delegate.toDataDom(data);
+ }
+
+ @Override
+ public Entry<YangInstanceIdentifier, CompositeNode> toDataDom(
+ Entry<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject>, DataObject> entry) {
+ return delegate.toDataDom(entry);
+ }
+
+ @Override
+ public YangInstanceIdentifier toDataDom(
+ org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject> path) {
+ return delegate.toDataDom(path);
+ }
+
+ @Override
+ public DataObject dataObjectFromDataDom(
+ org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject> path,
+ CompositeNode result) throws DeserializationException {
+ return delegate.dataObjectFromDataDom(path, result);
+ }
+
+ @Override
+ public org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?> fromDataDom(YangInstanceIdentifier entry)
+ throws DeserializationException {
+ return delegate.fromDataDom(entry);
+ }
+
+ @Override
+ public Set<QName> getRpcQNamesFor(Class<? extends RpcService> service) {
+ return delegate.getRpcQNamesFor(service);
+ }
+
+ @Override
+ public Optional<Class<? extends RpcService>> getRpcServiceClassFor(String namespace, String revision) {
+ return delegate.getRpcServiceClassFor(namespace,revision);
+ }
+
+ @Override
+ public DataContainer dataObjectFromDataDom(Class<? extends DataContainer> inputClass, CompositeNode domInput) {
+ return delegate.dataObjectFromDataDom(inputClass, domInput);
+ }
+
+ @Override
+ public void close() {
+ if(delegate != null) {
+ delegate = null;
+
+ try {
+ bundleContext.ungetService(reference);
+ } catch (IllegalStateException e) {
+ // Indicates the BundleContext is no longer valid which can happen normally on shutdown.
+ LOG.debug( "Error unregistering service", e );
+ }
+
+ bundleContext= null;
+ reference = null;
+ }
+ }
+
+ @Override
+ public BindingIndependentMappingService getDelegate() {
+ return delegate;
+ }
+ }