2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.binding.runtime.osgi.impl;
10 import com.google.common.primitives.UnsignedLong;
11 import org.opendaylight.binding.runtime.api.AbstractBindingRuntimeContext;
12 import org.opendaylight.binding.runtime.api.BindingRuntimeContext;
13 import org.opendaylight.binding.runtime.api.BindingRuntimeGenerator;
14 import org.opendaylight.binding.runtime.api.BindingRuntimeTypes;
15 import org.opendaylight.binding.runtime.api.ClassLoadingStrategy;
16 import org.opendaylight.binding.runtime.api.DefaultBindingRuntimeContext;
17 import org.opendaylight.mdsal.dom.schema.osgi.OSGiModuleInfoSnapshot;
18 import org.osgi.service.component.annotations.Activate;
19 import org.osgi.service.component.annotations.Component;
20 import org.osgi.service.component.annotations.Deactivate;
21 import org.osgi.service.component.annotations.Reference;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 * A Factory Component which implements {@link BindingRuntimeContext}.
28 @Component(service = BindingRuntimeContext.class, immediate = true)
29 public final class BindingRuntimeContextImpl extends AbstractBindingRuntimeContext {
30 private static final Logger LOG = LoggerFactory.getLogger(BindingRuntimeContextImpl.class);
33 OSGiModuleInfoSnapshot effectiveModel = null;
35 BindingRuntimeGenerator generator = null;
37 private BindingRuntimeContext delegate;
38 private UnsignedLong generation;
41 public ClassLoadingStrategy getStrategy() {
42 return delegate.getStrategy();
46 public BindingRuntimeTypes getTypes() {
47 return delegate.getTypes();
52 generation = effectiveModel.getGeneration();
53 delegate = DefaultBindingRuntimeContext.create(
54 generator.generateTypeMapping(effectiveModel.getEffectiveModelContext()), effectiveModel);
56 LOG.debug("BindingRuntimeContext generation {} activated", generation);
62 LOG.debug("BindingRuntimeContext generation {} deactivated", generation);