From 2bca3b4a54e1b0a5206c7be14262e35753700d13 Mon Sep 17 00:00:00 2001 From: Jan Srnicek Date: Mon, 9 Oct 2017 10:39:17 +0200 Subject: HONEYCOMB-363 - Bgp extension modules Provides maven modules per bgp extension. Defines common configuration that can be used to define new extensions(AbstractBgpExtensionModule). Change-Id: I1c8ff65b6f9aa5474026f4bdf42476bd0559208e Signed-off-by: Jan Srnicek --- .../RIBExtensionConsumerContextProvider.java | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 infra/northbound/bgp-extensions/extension-common/src/main/java/io/fd/honeycomb/northbound/bgp/extension/RIBExtensionConsumerContextProvider.java (limited to 'infra/northbound/bgp-extensions/extension-common/src/main/java/io/fd/honeycomb/northbound/bgp/extension/RIBExtensionConsumerContextProvider.java') diff --git a/infra/northbound/bgp-extensions/extension-common/src/main/java/io/fd/honeycomb/northbound/bgp/extension/RIBExtensionConsumerContextProvider.java b/infra/northbound/bgp-extensions/extension-common/src/main/java/io/fd/honeycomb/northbound/bgp/extension/RIBExtensionConsumerContextProvider.java new file mode 100644 index 000000000..a8374ea67 --- /dev/null +++ b/infra/northbound/bgp-extensions/extension-common/src/main/java/io/fd/honeycomb/northbound/bgp/extension/RIBExtensionConsumerContextProvider.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.honeycomb.northbound.bgp.extension; + +import com.google.inject.Inject; +import io.fd.honeycomb.binding.init.ProviderTrait; +import io.fd.honeycomb.data.init.ShutdownHandler; +import org.opendaylight.protocol.bgp.rib.spi.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Set; + +public class RIBExtensionConsumerContextProvider extends ProviderTrait { + private static final Logger LOG = LoggerFactory.getLogger(RIBExtensionConsumerContextProvider.class); + @Inject + private Set activators; + @Inject + private ShutdownHandler shutdownHandler; + + @Override + protected RIBExtensionConsumerContext create() { + final RIBExtensionProviderContext ctx = new SimpleRIBExtensionProviderContext(); + final SimpleRIBExtensionProviderContextActivator activator = + new SimpleRIBExtensionProviderContextActivator(ctx, new ArrayList<>(activators)); + LOG.debug("Starting RIBExtensionConsumerContext with activators: {}", activators); + activator.start(); + shutdownHandler.register("rib-extension-consumer-context-activator", activator); + return ctx; + } +} -- cgit 1.2.3-korg