Initial source code
[oam/tr069-adapter.git] / netconf-server / src / main / java / org / commscope / tr069adapter / netconf / boot / NetConfServiceBooter.java
diff --git a/netconf-server/src/main/java/org/commscope/tr069adapter/netconf/boot/NetConfServiceBooter.java b/netconf-server/src/main/java/org/commscope/tr069adapter/netconf/boot/NetConfServiceBooter.java
new file mode 100644 (file)
index 0000000..88b2771
--- /dev/null
@@ -0,0 +1,50 @@
+/*\r
+ * ============LICENSE_START========================================================================\r
+ * ONAP : tr-069-adapter\r
+ * =================================================================================================\r
+ * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
+ * =================================================================================================\r
+ * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
+ * may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
+ * either express or implied. See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ===============LICENSE_END=======================================================================\r
+ */\r
+\r
+package org.commscope.tr069adapter.netconf.boot;\r
+\r
+import org.commscope.tr069adapter.netconf.server.NetConfServerManagerImpl;\r
+import org.springframework.boot.SpringApplication;\r
+import org.springframework.boot.autoconfigure.SpringBootApplication;\r
+import org.springframework.boot.autoconfigure.domain.EntityScan;\r
+import org.springframework.context.ApplicationContext;\r
+import org.springframework.context.annotation.ComponentScan;\r
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;\r
+import org.springframework.retry.annotation.EnableRetry;\r
+\r
+@SpringBootApplication\r
+@ComponentScan({"org.commscope.tr069adapter.netconf", "org.opendaylight.netconf.test"})\r
+@EnableJpaRepositories("org.commscope.tr069adapter.netconf.dao")\r
+@EntityScan("org.commscope.tr069adapter.netconf.entity")\r
+@EnableRetry\r
+public class NetConfServiceBooter {\r
+\r
+  private static ApplicationContext appContext;\r
+\r
+  public static void main(String[] args) {\r
+    if (args != null)\r
+      appContext = SpringApplication.run(NetConfServiceBooter.class, args);\r
+    NetConfServerManagerImpl serverManager =\r
+        NetConfServiceBooter.getApplicationContext().getBean(NetConfServerManagerImpl.class);\r
+    serverManager.restartServers(); // restart all netconf servers during startup.\r
+  }\r
+\r
+  public static ApplicationContext getApplicationContext() {\r
+    return appContext;\r
+  }\r
+}\r