📄 servicefactory.java
字号:
/* @LICENSE_COPYRIGHT@ */
package net.sf.irunninglog.service;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.sf.irunninglog.util.ObjectFactory;
/**
* Factory class for creating <code>IService</code> instances. New service
* instances may be obtained by calling the static <code>newService</code>
* method. Each call to <code>newService</code> will instantiate and return
* a new service instance. Any instance of the <code>IService</code>
* interface mapped in the object factory properties file can be obtained
* using this class.
*
* @author <a href="mailto:allan_e_lewis@yahoo.com">Allan Lewis</a>
* @version $Revision: 1.1.1.1 $ $Date: 2005/06/23 01:48:57 $
* @since iRunningLog 1.0
* @see IService
*/
public final class ServiceFactory {
/** <code>Log</code> instance for this class. */
private static final Log LOG = LogFactory.getLog(ServiceFactory.class);
/** Utility class - does not expose a constructor. */
private ServiceFactory() { }
/**
* Get a new instance of an <code>IService</code> object. This method
* will used the parameter to determine the class name of the service and
* instantiate a new instance.
*
* @param serviceName The name of the service to be created. This will be
* used to look up the actual service class to be
* created.
* @return The new service instance
* @see IService
*/
public static IService newService(String serviceName) {
if (LOG.isDebugEnabled()) {
LOG.debug("newService: Creating a new service for name '"
+ serviceName + "'");
}
ObjectFactory factory = ObjectFactory.getInstance();
IService service = (IService) factory.createObject(serviceName);
if (LOG.isDebugEnabled()) {
LOG.debug("newService: Service instance created successfully "
+ service);
}
return service;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -