../TestSpring/src/main/java/com/sample/SampleBeanFactoryBuilder.java
| 1 | |
package com.sample; |
| 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 SampleBeanFactoryBuilder { |
| 9 | 0 |
private static String applicationContextName = "applicationContext.xml"; |
| 10 | |
private ApplicationContext applicationContext; |
| 11 | |
| 12 | 0 |
private static class BeanFactoryBuilderHolder { |
| 13 | 0 |
private static final SampleBeanFactoryBuilder instance = new SampleBeanFactoryBuilder(); |
| 14 | |
} |
| 15 | |
public static SampleBeanFactoryBuilder 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 |
System.err.println("start"); |
| 28 | 0 |
if (applicationContext == null){ |
| 29 | 0 |
System.err.println("ERROR"); |
| 30 | |
|
| 31 | |
} |
| 32 | 0 |
System.err.println("end"); |
| 33 | 0 |
} |
| 34 | |
| 35 | 0 |
private SampleBeanFactoryBuilder(){ |
| 36 | |
| 37 | 0 |
} |
| 38 | |
| 39 | |
public ApplicationContext build(){ |
| 40 | 0 |
return applicationContext; |
| 41 | |
} |
| 42 | |
} |