+++ /dev/null
-/*
- * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.binding.dom.codec.osgi;
-
-import java.util.EventListener;
-import org.opendaylight.binding.runtime.api.BindingRuntimeContext;
-
-@Deprecated
-public interface BindingRuntimeContextListener extends EventListener {
-
- void onBindingRuntimeContextUpdated(BindingRuntimeContext context);
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.binding.dom.codec.osgi;
-
-import com.google.common.annotations.Beta;
-import org.opendaylight.binding.runtime.api.BindingRuntimeContext;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
-
-/**
- * A {@link BindingRuntimeContext} enriched with the ability to look up {@link YangTextSchemaSource}s.
- *
- * @author Robert Varga
- *
- * @deprecated This service is exposed for transition purposes only.
- */
-@Deprecated
-@Beta
-public interface BindingRuntimeContextService extends SchemaSourceProvider<YangTextSchemaSource> {
- /**
- * Return the current {@link BindingRuntimeContext}.
- *
- * @return Current BindingRuntimeContext.
- */
- BindingRuntimeContext getBindingRuntimeContext();
-}
import org.opendaylight.binding.runtime.api.ClassLoadingStrategy;
import org.opendaylight.binding.runtime.spi.GeneratedClassLoadingStrategy;
import org.opendaylight.binding.runtime.spi.ModuleInfoBackedContext;
-import org.opendaylight.mdsal.binding.dom.codec.osgi.BindingRuntimeContextService;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
private final List<ServiceRegistration<?>> registrations = new ArrayList<>(2);
private ModuleInfoBundleTracker bundleTracker = null;
- private SimpleBindingRuntimeContextService service = null;
@Override
public void start(final BundleContext context) {
// FIXME: This is the fallback strategy, it should not be needed
GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
- service = new SimpleBindingRuntimeContextService(context, moduleInfoBackedContext, moduleInfoBackedContext);
-
final OsgiModuleInfoRegistry registry = new OsgiModuleInfoRegistry(moduleInfoBackedContext,
- moduleInfoBackedContext, service);
+ moduleInfoBackedContext);
LOG.debug("Starting Binding-DOM codec bundle tracker");
bundleTracker = new ModuleInfoBundleTracker(context, registry);
bundleTracker.open();
- LOG.debug("Starting Binding-DOM runtime context service");
- service.open();
-
LOG.debug("Registering Binding-DOM codec services");
- registrations.add(context.registerService(BindingRuntimeContextService.class, service, null));
registrations.add(context.registerService(ClassLoadingStrategy.class, moduleInfoBackedContext, null));
LOG.info("Binding-DOM codec started");
LOG.debug("Stopping Binding-DOM codec bundle tracker");
bundleTracker.close();
- LOG.debug("Stoping Binding-DOM runtime context service");
- service.close();
-
LOG.info("Binding-DOM codec stopped");
}
}
import static java.util.Objects.requireNonNull;
import org.checkerframework.checker.lock.qual.GuardedBy;
+import org.opendaylight.binding.runtime.spi.ModuleInfoBackedContext;
import org.opendaylight.binding.runtime.spi.ModuleInfoRegistry;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
final class OsgiModuleInfoRegistry implements ModuleInfoRegistry {
private static final Logger LOG = LoggerFactory.getLogger(OsgiModuleInfoRegistry.class);
- private final SimpleBindingRuntimeContextService runtimeContext;
private final SchemaContextProvider schemaContextProvider;
- private final ModuleInfoRegistry moduleInfoRegistry;
+ private final ModuleInfoBackedContext moduleInfoRegistry;
@GuardedBy("this")
private ServiceRegistration<?> registration;
@GuardedBy("this")
private long generation;
- OsgiModuleInfoRegistry(final ModuleInfoRegistry moduleInfoRegistry,
- final SchemaContextProvider schemaContextProvider, final SimpleBindingRuntimeContextService runtimeContext) {
+ OsgiModuleInfoRegistry(final ModuleInfoBackedContext moduleInfoRegistry,
+ final SchemaContextProvider schemaContextProvider) {
this.moduleInfoRegistry = requireNonNull(moduleInfoRegistry);
this.schemaContextProvider = requireNonNull(schemaContextProvider);
- this.runtimeContext = requireNonNull(runtimeContext);
}
@Override
LOG.error("Error updating the schema context", e);
return;
}
+ LOG.trace("Assembled context {}", context);
- try {
- runtimeContext.updateBindingRuntimeContext(context);
- } catch (final RuntimeException e) {
- LOG.error("Error updating binding runtime context", e);
- return;
- }
+ // // FIXME: MDSAL-392: UGH, this should be a snapshot
+ // final BindingRuntimeContext next = DefaultBindingRuntimeContext.create(
+ // new DefaultBindingRuntimeGenerator().generateTypeMapping(context), moduleInfoRegistry);
+
+ // FIXME: publish new the new context, remove the old one
}
ObjectRegistration<YangModuleInfo> registerInfo(final YangModuleInfo yangModuleInfo) {
+++ /dev/null
-/*
- * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.binding.dom.codec.osgi.impl;
-
-import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import org.checkerframework.checker.lock.qual.GuardedBy;
-import org.opendaylight.binding.runtime.api.BindingRuntimeContext;
-import org.opendaylight.binding.runtime.api.ClassLoadingStrategy;
-import org.opendaylight.binding.runtime.api.DefaultBindingRuntimeContext;
-import org.opendaylight.mdsal.binding.dom.codec.osgi.BindingRuntimeContextListener;
-import org.opendaylight.mdsal.binding.dom.codec.osgi.BindingRuntimeContextService;
-import org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-
-@Deprecated
-final class SimpleBindingRuntimeContextService extends
- ServiceTracker<BindingRuntimeContextListener, BindingRuntimeContextListener>
- implements BindingRuntimeContextService {
- private final SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
- private final ClassLoadingStrategy strategy;
- private final Object lock = new Object();
-
- @GuardedBy("lock")
- private BindingRuntimeContext current;
-
- SimpleBindingRuntimeContextService(final BundleContext context, final ClassLoadingStrategy strategy,
- final SchemaSourceProvider<YangTextSchemaSource> sourceProvider) {
- super(context, BindingRuntimeContextListener.class, null);
- this.sourceProvider = requireNonNull(sourceProvider);
- this.strategy = requireNonNull(strategy);
- }
-
- @Override
- public ListenableFuture<? extends YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) {
- return sourceProvider.getSource(sourceIdentifier);
- }
-
- @Override
- public BindingRuntimeContext getBindingRuntimeContext() {
- synchronized (lock) {
- checkState(current != null, "Runtime context is not initialized yet");
- return current;
- }
- }
-
- void updateBindingRuntimeContext(final SchemaContext schemaContext) {
- final BindingRuntimeContext next = DefaultBindingRuntimeContext.create(
- new DefaultBindingRuntimeGenerator().generateTypeMapping(schemaContext), strategy);
-
- final BindingRuntimeContextListener[] listeners;
- synchronized (lock) {
- current = next;
- listeners = this.getServices(new BindingRuntimeContextListener[0]);
- }
-
- for (BindingRuntimeContextListener l : listeners) {
- l.onBindingRuntimeContextUpdated(next);
- }
- }
-
- @Override
- public BindingRuntimeContextListener addingService(
- final ServiceReference<BindingRuntimeContextListener> reference) {
- final BindingRuntimeContextListener listener = super.addingService(reference);
-
- synchronized (lock) {
- listener.onBindingRuntimeContextUpdated(current);
- }
-
- return listener;
- }
-}