Modify package structure and pom file
[vfc/nfvo/driver/ems.git] / ems / boco / src / main / java / org / onap / vfc / nfvo / emsdriver / EMSDriverApp.java
1 /**
2  * Copyright 2017 BOCO Corporation.  CMCC Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.vfc.nfvo.emsdriver;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20 import org.onap.vfc.nfvo.emsdriver.commons.constant.Constant;
21 import org.onap.vfc.nfvo.emsdriver.commons.utils.DriverThread;
22 import org.onap.vfc.nfvo.emsdriver.northbound.service.EmsDriverApplication;
23 import org.springframework.beans.BeansException;
24 import org.springframework.context.ApplicationContext;
25 import org.springframework.context.support.FileSystemXmlApplicationContext;
26
27
28
29 public class EMSDriverApp {
30
31         private static Log log = LogFactory.getLog(DriverThread.class);
32         public static ApplicationContext context = null;
33         static {
34                 try {
35                         /** spring bean applicationContext **/
36                         context = new FileSystemXmlApplicationContext("file:" + Constant.SYS_CFG+ "spring.xml");
37                         
38                 } catch (BeansException e) {
39                         log.error("spring.xml is fail ", e);
40                         System.exit(1);
41                 } catch (Exception e) {
42                         log.error("spring.xml is fail", e);
43                         System.exit(1);
44                 }
45         }
46         
47         
48         /**
49          * @param args
50          */
51         public static void main(String[] args) {
52                 String[] allThreadName = context.getBeanNamesForType(DriverThread.class);
53
54                 log.info("worker num :" + allThreadName.length);
55
56                 for (String threadName : allThreadName) {
57                         DriverThread thread = (DriverThread) context.getBean(threadName);
58                         if (thread == null) {
59                                 log.error(threadName + "Thread start error,system exit");
60                                 System.exit(1);
61                         }
62                         thread.setName(threadName);
63                         thread.start();
64                 }
65                 
66                 try {
67                         new EmsDriverApplication().run(args);
68                 } catch (Exception e) {
69                         log.error("EmsDriverApplication.run is fail", e);
70                         System.exit(1);
71                 }
72                 log.info("the workerThreads start sucess" );
73         }
74
75 }