⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 storefrontdebugserviceimpl.java

📁 《基于Eclipse的开源框架技术与实战》[第5章]随书源码
💻 JAVA
字号:
package com.free.struts.storefront.service;import java.sql.Timestamp;import java.util.ArrayList;import java.util.Collection;import java.util.Iterator;import java.util.List;import javax.servlet.ServletContext;import com.free.struts.storefront.businessobjects.CustomerBO;import com.free.struts.storefront.businessobjects.ItemBO;import com.free.struts.storefront.catalog.view.ItemDetailView;import com.free.struts.storefront.catalog.view.ItemSummaryView;import com.free.struts.storefront.customer.view.UserView;import com.free.struts.storefront.framework.exceptions.AccountLockedException;import com.free.struts.storefront.framework.exceptions.DatastoreException;import com.free.struts.storefront.framework.exceptions.ExpiredPasswordException;import com.free.struts.storefront.framework.exceptions.InvalidLoginException;import com.free.struts.storefront.service.memory.StorefrontMemoryDatabase;/** * <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 StorefrontDebugServiceImpl implements IStorefrontService {	//	          	private String pathname = "database.xml";	ServletContext servletContext = null;	private String serviceClassname = null;	private StorefrontMemoryDatabase database = null;	public StorefrontDebugServiceImpl() {		super();		initializeDatabase();	}	public String getPathname() {		return (this.pathname);	}	public void setPathname(String pathname) {		this.pathname = pathname;	}	public void setServletContext(ServletContext ctx) {		this.servletContext = ctx;	}	public ServletContext getServletContext() {		return servletContext;	}	public StorefrontMemoryDatabase getDatabase() {		return database;	}	/**	 * 获得商品的信息	 * */	public List getFeaturedItems() throws DatastoreException {		List items = new ArrayList();		Collection coll = getDatabase().getFeaturedItems();		Iterator iter = coll.iterator();		while (iter.hasNext()) {			ItemBO itemBO = (ItemBO) iter.next();			ItemSummaryView view = new ItemSummaryView();			view.setName(itemBO.getDisplayLabel());			view.setDescription(itemBO.getDescription());			view.setUnitPrice(itemBO.getBasePrice());			view.setId(itemBO.getId().toString());			view.setSmallImageURL(itemBO.getSmallImageURL());			items.add(view);		}		return items;	}	/**	 * 通过id获得商品的详细信息	 * */	public ItemDetailView getItemDetailView(String itemId)		throws DatastoreException {		ItemBO item = getDatabase().findItem(itemId);		ItemDetailView view = new ItemDetailView();		view.setId(item.getId().toString());		view.setLargeImageURL(item.getLargeImageURL());		view.setSmallImageURL(item.getSmallImageURL());		view.setDescription(item.getDescription());		view.setName(item.getDisplayLabel());		view.setUnitPrice(item.getBasePrice());		return view;	}	public void logout(String email) {		// Do nothing for this example	}	/**	 * 验证用户是否授权	 */	public UserView authenticate(String email, String password)		throws			InvalidLoginException,			ExpiredPasswordException,			AccountLockedException,			DatastoreException {		CustomerBO customer = getDatabase().authenticateUser(email, password);		if (customer != null) {			UserView view = new UserView();			view.setFirstName(customer.getFirstName());			view.setLastName(customer.getLastName());			view.setEmailAddress(customer.getEmail());			view.setId(customer.getId().toString());			view.setTimeCreated(new Timestamp(System.currentTimeMillis()));			return view;		} else {			throw new InvalidLoginException();		}	}	/**	 * @return	 */	public String getServiceClassname() {		return serviceClassname;	}	/**	 * @param string	 */	public void setServiceClassname(String string) {		serviceClassname = string;	}	public void destroy() {		// Do nothing for this example	}	/**	 * 初始化数据	 * */	private void initializeDatabase() {		database = new StorefrontMemoryDatabase();		//设置数据文件		database.setPathname(pathname);		database.open();		setDatabase(database);	}	/**	 * @param database	 */	public void setDatabase(StorefrontMemoryDatabase database) {		this.database = database;	}}

⌨️ 快捷键说明

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