X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fsrc%2Forg%2Fwamblee%2Fgeneral%2FBeanKernel.java;h=d05eef3dd6b507c8706a5d2dd865b3de4edc06c6;hb=07cedd3f0730646ea35a7f668b3e1e872a4605d9;hp=d140de3d48a8f911fee5c9599d3bbf3e8047ecd0;hpb=5b6b49fbe01397461e67238481c84a62c8ed4bef;p=utils diff --git a/support/src/org/wamblee/general/BeanKernel.java b/support/src/org/wamblee/general/BeanKernel.java index d140de3d..d05eef3d 100644 --- a/support/src/org/wamblee/general/BeanKernel.java +++ b/support/src/org/wamblee/general/BeanKernel.java @@ -25,7 +25,11 @@ import org.wamblee.io.ClassPathResource; import org.wamblee.io.InputResource; /** - * The standard means to obtain the bean factory. + * The standard means to obtain the bean factory. This works by reading a + * property {@value #BEAN_FACTORY_CLASS} from a property file named + * {@value #BEAN_KERNEL_PROP_FILE} from the class path. This property identifies + * the bean factory implementation to use. The configured bean factory must have + * a no-arg constructor. */ public final class BeanKernel { @@ -46,12 +50,12 @@ public final class BeanKernel { * Cached bean factory. */ private static BeanFactory BEAN_FACTORY; - + /** * Disabled constructor. - * + * */ - private BeanKernel() { + private BeanKernel() { // Empty } @@ -67,13 +71,14 @@ public final class BeanKernel { } /** - * Gets the bean factory. - * @return Bean factory. + * Gets the bean factory. + * + * @return Bean factory. */ public static BeanFactory getBeanFactory() { synchronized (BeanFactory.class) { if (BEAN_FACTORY == null) { - BEAN_FACTORY = lookupBeanFactory(); + BEAN_FACTORY = lookupBeanFactory(BEAN_KERNEL_PROP_FILE); } } return BEAN_FACTORY; @@ -84,8 +89,8 @@ public final class BeanKernel { * * @return Bean factory. */ - private static BeanFactory lookupBeanFactory() { - InputResource resource = new ClassPathResource(BEAN_KERNEL_PROP_FILE); + static BeanFactory lookupBeanFactory(String aPropertyFilename) { + InputResource resource = new ClassPathResource(aPropertyFilename); InputStream is; try { is = resource.getInputStream(); @@ -95,7 +100,7 @@ public final class BeanKernel { } try { Properties props = new Properties(); - props.load(resource.getInputStream()); + props.load(is); String className = props.getProperty(BEAN_FACTORY_CLASS); Class beanFactory = Class.forName(className); return (BeanFactory) beanFactory.newInstance();