../common/src/main/java/com/xxxxxxx/drvpp/fw/common/util/BeanFactoryBuilder.java
| 1 | |
package com.xxxxxxx.drvpp.fw.common.util; |
| 2 | |
| 3 | |
import org.springframework.context.ApplicationContext; |
| 4 | |
import org.springframework.context.support.ClassPathXmlApplicationContext; |
| 5 | |
| 6 | |
import com.xxxxxxx.drvpp.fw.common.exception.FwRuntimeException; |
| 7 | |
| 8 | |
public class BeanFactoryBuilder { |
| 9 | 0 |
private static String applicationContextName = "applicationContext.xml"; |
| 10 | |
private ApplicationContext applicationContext; |
| 11 | |
| 12 | 0 |
private static class BeanFactoryBuilderHolder { |
| 13 | 0 |
private static final BeanFactoryBuilder instance = new BeanFactoryBuilder(); |
| 14 | |
} |
| 15 | |
public static BeanFactoryBuilder getInstance() { |
| 16 | 0 |
BeanFactoryBuilderHolder.instance.init(); |
| 17 | 0 |
return BeanFactoryBuilderHolder.instance; |
| 18 | |
} |
| 19 | |
| 20 | |
public static void setApplicationContext(String context){ |
| 21 | 0 |
applicationContextName = context; |
| 22 | 0 |
} |
| 23 | |
| 24 | |
private void init() { |
| 0 |
Path coverage: 0/2
A: 0
B: 0
|
| 25 | 0 |
applicationContext = new ClassPathXmlApplicationContext( |
| 26 | 0 |
applicationContextName); |
| 27 | 0 |
if (applicationContext == null){ |
| 28 | 0 |
throw new FwRuntimeException(null); |
| 29 | |
} |
| 30 | 0 |
} |
| 31 | |
| 32 | 0 |
private BeanFactoryBuilder(){ |
| 33 | |
| 34 | 0 |
} |
| 35 | |
| 36 | |
public ApplicationContext build(){ |
| 37 | 0 |
return applicationContext; |
| 38 | |
} |
| 39 | |
} |