dictmanager.java

来自「这是一个轻便的j2ee的web应用框架,是一个在多个项目中运用的实际框架,采用s」· Java 代码 · 共 96 行

JAVA
96
字号
/*
 * Created on 2004-3-25
 *
 */
package com.esimple.service.dict;

import java.util.*;
import org.springframework.beans.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.esimple.service.dict.po.*;
import com.esimple.framework.dao.ibatis.BaseSqlMapClientDaoImpl;


/**
 * @author steven
 *
 */
public class DictManager {
	
	public static final String BEAN_CONFIG_NAME="dictManager";
	
	private Log logger = LogFactory.getLog(DictManager.class);
	
	private DictDataCache cache;//数据字典内容缓存
	
	private BaseSqlMapClientDaoImpl sqlMapDao;
	
	public void setCache(DictDataCache cache){
		this.cache = cache;
	}
	
	public DictDataCache getCache(){
		return this.cache;
	}
	

	public BaseSqlMapClientDaoImpl getSqlMapDao() {
		return this.sqlMapDao;
	}
	
	public void setSqlMapDao(BaseSqlMapClientDaoImpl sqlMapDao) {
	  this.sqlMapDao = sqlMapDao;
	}
				
	public String getDictType(String typeID){
		return cache.getDictType(typeID);
	}
	
	public HashMap getDictContent(String typeID){
		return cache.getDictContent(typeID);
	}
	
	public String getDictContent(String typeID,String contentID){
		return cache.getDictContent(typeID,contentID);
	}	
	

	public void load() throws FatalBeanException{
		cache =new DictDataCache();
		try{
			//clear cache
			cache.clear();

			//read dict
			getTypes();
			getItems();
		}catch(Exception e){
			logger.debug(e);
			throw new FatalBeanException("error in DictManager init",e);
		}
	}

	private void getTypes()  {
		List list = sqlMapDao.query("EBS.Dict.getAllDictTypes",null);
		Iterator iter = list.iterator();
		while ( iter.hasNext() ) {
			DictType type = (DictType) iter.next(); 
			logger.debug(type.getBusintypeid()+":" +type.getBusintypename()); 
			cache.addDictType(type.getBusintypeid(),type.getBusintypename());
		}
	}
	
	private void getItems(){
		List list = sqlMapDao.query("EBS.Dict.getAllDictItems",null);
		Iterator iter = list.iterator();
		while ( iter.hasNext() ) {
			DictItem content = (DictItem)iter.next();
			cache.addDictContent(
				content.getBusintypeid(),
				content.getBusinid(),
				content.getBusinname() );
		}
	}
}

⌨️ 快捷键说明

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