Make sure mdsal-eos-dom-simple activates 32/81932/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 7 May 2019 09:53:02 +0000 (11:53 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 7 May 2019 10:05:48 +0000 (12:05 +0200)
Controller packaging of local components requires that the single-node
EOS instance properly activates. This patch fixes that.

Change-Id: I7808c2f517b62c3627d4075fe201739707895923
JIRA: CONTROLLER-1584
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
entityownership/mdsal-eos-dom-simple/pom.xml
entityownership/mdsal-eos-dom-simple/src/main/java/org/opendaylight/mdsal/eos/dom/simple/Activator.java [new file with mode: 0644]

index 2d1ff6ba863f1430e059b036ef035a63e5824234..503791b51d2bf9eb169a2b05e662df97e3edd6a0 100644 (file)
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>mdsal-eos-common-api</artifactId>
 
     <build>
         <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions combine.children="append">
+                        <Bundle-Activator>org.opendaylight.mdsal.eos.dom.simple.Activator</Bundle-Activator>
+                    </instructions>
+                </configuration>
+            </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-checkstyle-plugin</artifactId>
diff --git a/entityownership/mdsal-eos-dom-simple/src/main/java/org/opendaylight/mdsal/eos/dom/simple/Activator.java b/entityownership/mdsal-eos-dom-simple/src/main/java/org/opendaylight/mdsal/eos/dom/simple/Activator.java
new file mode 100644 (file)
index 0000000..dad0a42
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.mdsal.eos.dom.simple;
+
+import com.google.common.annotations.Beta;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+@Beta
+public class Activator implements BundleActivator {
+    private ServiceRegistration<?> reg;
+
+    @Override
+    public void start(final BundleContext context) {
+        reg = context.registerService(DOMEntityOwnershipService.class, new SimpleDOMEntityOwnershipService(), null);
+    }
+
+    @Override
+    public void stop(final BundleContext context) {
+        if (reg != null) {
+            reg.unregister();
+            reg = null;
+        }
+    }
+}