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 static com.google.common.base.Verify.verifyNotNull;
12 import com.google.common.primitives.UnsignedLong;
13 import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext;
14 import org.opendaylight.mdsal.binding.runtime.osgi.OSGiBindingRuntimeContext;
15 import org.opendaylight.mdsal.binding.runtime.spi.ForwardingBindingRuntimeContext;
16 import org.osgi.service.component.annotations.Activate;
17 import org.osgi.service.component.annotations.Component;
18 import org.osgi.service.component.annotations.Deactivate;
19 import org.osgi.service.component.annotations.Reference;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * A global {@link BindingRuntimeContext}. It is injected with latest {@link OSGiBindingRuntimeContext} generation.
26 @Component(service = BindingRuntimeContext.class, immediate = true)
27 public final class GlobalBindingRuntimeContext extends ForwardingBindingRuntimeContext {
28 private static final Logger LOG = LoggerFactory.getLogger(GlobalBindingRuntimeContext.class);
30 private final UnsignedLong generation;
31 private BindingRuntimeContext delegate;
34 public GlobalBindingRuntimeContext(@Reference final OSGiBindingRuntimeContext osgi) {
35 generation = osgi.getGeneration();
36 delegate = osgi.getService();
37 LOG.info("Global BindingRuntimeContext generation {} activated", generation);
41 protected BindingRuntimeContext delegate() {
42 return verifyNotNull(delegate);
48 LOG.info("Global BindingRuntimeContext generation {} deactivated", generation);