📄 businessobjectfactory.java
字号:
/* @LICENSE_COPYRIGHT@ */
package net.sf.irunninglog.businessobject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.sf.irunninglog.util.ObjectFactory;
/**
* Factory class for creating <code>IBusinessObject</code> instances. New
* instances may be obtained by calling the static <code>newInstance</code>
* method. Each call to <code>newInstance</code> will instantiate and return
* a new business object. Any instance of the <code>IBusinessObject</code>
* interface mapped to an implementaion class in the object factory mappings
* property file may be obtained using this factory.
*
* @author <a href="mailto:allan_e_lewis@yahoo.com">Allan Lewis</a>
* @version $Revision: 1.1.1.1 $ $Date: 2005/06/23 01:48:54 $
* @since iRunningLog 1.0
* @see IBusinessObject
*/
public final class BusinessObjectFactory {
/** <code>Log</code> instance for this class. */
private static final Log LOG =
LogFactory.getLog(BusinessObjectFactory.class);
/** Suffix used to append to BO types when creating instances. */
private static final String PROPERTY_SUFFIX = ".businessObject";
/** Utility class - does not expose a constructor. */
private BusinessObjectFactory() { }
/**
* Get a new instance of an <code>IBusinessObject</code>. This method
* will use the parameter to determine the class name of the business object
* and instantiate a new business object instance.
*
* @param type The type of business object to be created
* @return The new business object
* @throws Exception If there is a problem creating the business object
*/
public static IBusinessObject newInstance(String type) throws Exception {
if (LOG.isDebugEnabled()) {
LOG.debug("newInstance: Creating a new instance of type " + type);
}
type += PROPERTY_SUFFIX;
if (LOG.isDebugEnabled()) {
LOG.debug("newInstance: Using the following name for object"
+ " creation " + type);
}
ObjectFactory factory = ObjectFactory.getInstance();
IBusinessObject instance = (IBusinessObject) factory.createObject(type);
if (LOG.isDebugEnabled()) {
LOG.debug("newInstance: Returning the following new instance "
+ instance);
}
return instance;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -