package org.opendaylight.controller.config.yang.md.sal.binding.impl;
import com.google.common.base.Preconditions;
-import java.util.Hashtable;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
-import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
-import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
-import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
/**
+ * Deprecated.
*
-**/
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
public final class RuntimeMappingModule extends AbstractRuntimeMappingModule {
-
private BundleContext bundleContext;
public RuntimeMappingModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
}
@Override
- public java.lang.AutoCloseable createInstance() {
- final GeneratedClassLoadingStrategy classLoading = getGlobalClassLoadingStrategy();
- final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(SingletonHolder.JAVASSIST));
- final BindingToNormalizedNodeCodec instance = new BindingToNormalizedNodeCodec(classLoading, codecRegistry,getWaitForSchema());
- bundleContext.registerService(SchemaContextListener.class, instance, new Hashtable<String,String>());
- return instance;
- }
+ public AutoCloseable createInstance() {
+ // We need to return the concrete BindingToNormalizedNodeCodec instance for backwards compatibility
+ // for CSS users that inject the binding-dom-mapping-service.
+ final WaitingServiceTracker<BindingToNormalizedNodeCodec> tracker =
+ WaitingServiceTracker.create(BindingToNormalizedNodeCodec.class, bundleContext);
+ final BindingToNormalizedNodeCodec service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
- private GeneratedClassLoadingStrategy getGlobalClassLoadingStrategy() {
- final ServiceReference<GeneratedClassLoadingStrategy> ref = bundleContext.getServiceReference(GeneratedClassLoadingStrategy.class);
- return bundleContext.getService(ref);
+ // Ideally we would close the ServiceTracker via the returned AutoCloseable but then we'd have to
+ // proxy the BindingToNormalizedNodeCodec instance which is problematic. It's OK to close the
+ // ServiceTracker here.
+ tracker.close();
+ return service;
}
public void setBundleContext(final BundleContext bundleContext) {