Split out DefaultBmpSessionFactory wiring 14/96714/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 29 Jun 2021 11:29:10 +0000 (13:29 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 29 Jun 2021 11:30:18 +0000 (13:30 +0200)
DefaultBmpSessionFactory is a simple service, use usual DI frameworks
to activate it.

JIRA: BGPCEP-953
Change-Id: Ie4c120b652f8e60e0f451052201ec355ab4f61be
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bmp/bmp-impl/pom.xml
bmp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/session/DefaultBmpSessionFactory.java
bmp/bmp-impl/src/main/resources/OSGI-INF/blueprint/bgp-bmp.xml

index cbbc7508b9e7c97e330883e232bf2785ea816d59..b9c259ca93cb6f75f8668a568e797b8fbc6fb235 100644 (file)
             <groupId>org.checkerframework</groupId>
             <artifactId>checker-qual</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.guicedee.services</groupId>
+            <artifactId>javax.inject</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.cmpn</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.kohsuke.metainf-services</groupId>
+            <artifactId>metainf-services</artifactId>
+        </dependency>
+
         <!-- test dependencies -->
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
index 829a3641618e184a7196eb74c69b881e2d8ec489..08265143870b8928434ace141ac55ac5169dc671 100644 (file)
@@ -5,19 +5,28 @@
  * 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.protocol.bmp.impl.session;
 
 import io.netty.channel.Channel;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import org.kohsuke.MetaInfServices;
 import org.opendaylight.protocol.bmp.api.BmpSession;
 import org.opendaylight.protocol.bmp.api.BmpSessionFactory;
 import org.opendaylight.protocol.bmp.api.BmpSessionListenerFactory;
+import org.osgi.service.component.annotations.Component;
 
+@MetaInfServices
+@Singleton
+@Component(immediate = true)
 public final class DefaultBmpSessionFactory implements BmpSessionFactory {
+    @Inject
+    public DefaultBmpSessionFactory() {
+        // Exposed for DI
+    }
 
     @Override
     public BmpSession getSession(final Channel channel, final BmpSessionListenerFactory sessionListenerFactory) {
         return new BmpSessionImpl(sessionListenerFactory.getSessionListener());
     }
-
 }
index 9850f95d878a18faa6ed981b7038eed4ca250ee5..936a9741acec0979e536143e1b5f1c3bbfba2adf 100644 (file)
@@ -11,8 +11,7 @@
   <reference id="bmpExtensionContext" interface="org.opendaylight.protocol.bmp.spi.registry.BmpExtensionConsumerContext"/>
   <reference id="globalBossGroup" interface="io.netty.channel.EventLoopGroup" odl:type="global-boss-group"/>
   <reference id="globalWorkerGroup" interface="io.netty.channel.EventLoopGroup" odl:type="global-worker-group"/>
-
-  <bean id="bmpSessionFactory" class="org.opendaylight.protocol.bmp.impl.session.DefaultBmpSessionFactory"/>
+  <reference id="bmpSessionFactory" interface="org.opendaylight.protocol.bmp.api.BmpSessionFactory"/>
 
   <bean id="bmpDispatcher" class="org.opendaylight.protocol.bmp.impl.BmpDispatcherImpl">
     <argument ref="globalBossGroup"/>