📄 servicefactory.java
字号:
package org.appfuse.util;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
import org.appfuse.util.exception.AppException;
import org.appfuse.util.exception.AppSystemException;
import org.appfuse.util.exception.ExceptionConstants;
import org.springframework.context.ApplicationContext;
import org.appfuse.service.Manager;
/**
*
* Description: Utility for fetching business service object.
* @author Linux
* @version 1.0
*/
public class ServiceFactory {
/** Logger */
private static Log log = LogFactory.getLog(ServiceFactory.class);
/** Spring Application context */
private static ApplicationContext ctx = null;
public static void init(ApplicationContext context) {
ctx = context;
}
public static Manager getService(String serviceName) throws AppException {
if (ctx == null) {
// ApplicationContext Should not be null
log.error("getService error: ApplicationContext is null");
throw new AppSystemException("CreateServiceObject Failed",
ExceptionConstants.SYS_GENERAL_ERR);
}
return (Manager) ctx.getBean(serviceName);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -