/*
- * Copyright 2005 the original author or authors.
- *
+ * Copyright 2005-2010 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.wamblee.general;
import org.apache.commons.logging.Log;
import java.util.Properties;
-
/**
* 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.
+ * 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 {
- /**
- * DOCUMENT ME!
- */
private static final Log LOG = LogFactory.getLog(BeanKernel.class);
/**
private static final String BEAN_KERNEL_PROP_FILE = "org.wamblee.beanfactory.properties";
/**
- * Name of the property to define the name of the bean factory
- * class to use. THis class must have a public default constructor.
+ * Name of the property to define the name of the bean factory class to use.
+ * THis class must have a public default constructor.
*/
private static final String BEAN_FACTORY_CLASS = "org.wamblee.beanfactory.class";
*/
private static BeanFactory BEAN_FACTORY;
-/**
+ /**
* Disabled constructor.
- *
+ *
*/
private BeanKernel() {
// Empty
}
/**
- * Overrides the default mechanism for looking up the bean factory
- * by specifying it yourself.
- *
- * @param aOverride Override bean factory.
+ * Overrides the default mechanism for looking up the bean factory by
+ * specifying it yourself.
+ *
+ * @param aOverride
+ * Override bean factory.
*/
public static void overrideBeanFactory(BeanFactory aOverride) {
BEAN_FACTORY = aOverride;
/**
* Gets the bean factory.
- *
+ *
* @return Bean factory.
*/
public static BeanFactory getBeanFactory() {
/**
* Lookup the bean factory based on the properties file.
- *
- * @param aPropertyFilename DOCUMENT ME!
- *
+ *
+ *
* @return Bean factory.
- *
- * @throws BeanFactoryException DOCUMENT ME!
+ *
*/
static BeanFactory lookupBeanFactory(String aPropertyFilename) {
InputResource resource = new ClassPathResource(aPropertyFilename);
- InputStream is;
+ InputStream is;
try {
- is = resource.getInputStream();
+ is = resource.getInputStream();
} catch (IOException e) {
- throw new BeanFactoryException("Cannot open resource " + resource, e);
+ throw new BeanFactoryException("Cannot open resource " + resource,
+ e);
}
try {
Properties props = new Properties();
props.load(is);
- String className = props.getProperty(BEAN_FACTORY_CLASS);
- Class beanFactory = Class.forName(className);
+ String className = props.getProperty(BEAN_FACTORY_CLASS);
+ Class beanFactory = Class.forName(className);
return (BeanFactory) beanFactory.newInstance();
} catch (Exception e) {
- throw new BeanFactoryException("Cannot read from resource "
- + resource, e);
+ throw new BeanFactoryException("Cannot read from resource " +
+ resource, e);
} finally {
try {
is.close();