config-persister-feature-adapter to push configs from karaf features
[controller.git] / opendaylight / config / config-persister-feature-adapter / src / main / java / org / opendaylight / controller / configpusherfeature / ConfigPusherFeatureActivator.java
diff --git a/opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/ConfigPusherFeatureActivator.java b/opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/ConfigPusherFeatureActivator.java
new file mode 100644 (file)
index 0000000..ea99579
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. 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.controller.configpusherfeature;
+
+import org.opendaylight.controller.config.persist.api.ConfigPusher;
+import org.opendaylight.controller.configpusherfeature.internal.ConfigPusherCustomizer;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class ConfigPusherFeatureActivator implements BundleActivator {
+
+    BundleContext bc = null;
+    ConfigPusherCustomizer cpc = null;
+    ServiceTracker<ConfigPusher,ConfigPusher> cpst = null;
+
+    public void start(BundleContext context) throws Exception {
+        bc = context;
+        cpc = new ConfigPusherCustomizer();
+        cpst = new ServiceTracker<ConfigPusher, ConfigPusher>(bc, ConfigPusher.class.getName(), cpc);
+        cpst.open();
+    }
+
+    public void stop(BundleContext context) throws Exception {
+        if(cpst != null) {
+            cpst.close();
+            cpst = null;
+        }
+        if(cpc != null) {
+            cpc.close();
+            cpc = null;
+        }
+        bc = null;
+    }
+}