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 org.opendaylight.binding.runtime.api.AbstractBindingRuntimeContext;
11 import org.opendaylight.binding.runtime.api.BindingRuntimeContext;
12 import org.opendaylight.binding.runtime.api.BindingRuntimeGenerator;
13 import org.opendaylight.binding.runtime.api.BindingRuntimeTypes;
14 import org.opendaylight.binding.runtime.api.ClassLoadingStrategy;
15 import org.opendaylight.binding.runtime.api.DefaultBindingRuntimeContext;
16 import org.opendaylight.mdsal.dom.schema.osgi.OSGiModuleInfoSnapshot;
17 import org.osgi.service.component.annotations.Activate;
18 import org.osgi.service.component.annotations.Component;
19 import org.osgi.service.component.annotations.Deactivate;
20 import org.osgi.service.component.annotations.Reference;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
25 * A Factory Component which implements {@link BindingRuntimeContext}.
27 @Component(service = BindingRuntimeContext.class, immediate = true)
28 public final class BindingRuntimeContextImpl extends AbstractBindingRuntimeContext {
29 private static final Logger LOG = LoggerFactory.getLogger(BindingRuntimeContextImpl.class);
32 OSGiModuleInfoSnapshot effectiveModel = null;
34 BindingRuntimeGenerator generator = null;
36 private BindingRuntimeContext delegate = null;
37 private long generation;
40 public ClassLoadingStrategy getStrategy() {
41 return delegate.getStrategy();
45 public BindingRuntimeTypes getTypes() {
46 return delegate.getTypes();
51 generation = effectiveModel.getGeneration();
52 delegate = DefaultBindingRuntimeContext.create(
53 generator.generateTypeMapping(effectiveModel.getEffectiveModelContext()), effectiveModel);
55 LOG.debug("BindingRuntimeContext generation {} activated", generation);
61 LOG.debug("BindingRuntimeContext generation {} deactivated", generation);