storefrontservicefactory.java

来自「《基于Eclipse的开源框架技术与实战》[第5章]随书源码」· Java 代码 · 共 82 行

JAVA
82
字号
package com.free.struts.storefront.service;import javax.servlet.ServletException;import org.apache.struts.action.ActionServlet;import org.apache.struts.action.PlugIn;import org.apache.struts.config.ModuleConfig;import com.free.struts.storefront.framework.util.IConstants;/** * <p>Title: Eclipse Plugin Development</p> * <p>Description: Free download</p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: Free</p> * @author gan.shu.man * @version 1.0 */public class StorefrontServiceFactory implements IStorefrontServiceFactory {	// The default is to use the debug implementation	private static String serviceClassname =		"com.free.struts.storefront.service.StorefrontDebugServiceImpl";	private static IStorefrontServiceFactory Singleton = null;	public static IStorefrontServiceFactory getInstance() {		synchronized (StorefrontServiceFactory.class) {			if (Singleton == null) {				Singleton = new StorefrontServiceFactory();				return Singleton;			}		}		return Singleton;	}	private StorefrontServiceFactory() {		init();	}	public void init() {		IStorefrontService service = null;		try {			service =				(IStorefrontService) Class					.forName(serviceClassname)					.newInstance();		} catch (Exception ex) {						// Swallow the exception and let it occur during the createService() method call.			ex.printStackTrace();		}	}	public IStorefrontService createService()		throws			ClassNotFoundException,			IllegalAccessException,			InstantiationException {						return (IStorefrontService) Class			.forName(getServiceClassname())			.newInstance();	}	/**	 * @return	 */	public static String getServiceClassname() {		return serviceClassname;	}	/**	 * @param string	 */	public static void setServiceClassname(String string) {		serviceClassname = string;	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?