공통코드선언방법


 

code.java
	public static List<Code> cachedCodeArrayList = new ArrayList<Code>();

 

 

게터 세터 선언하지 않아도된다.

 

 

 

codeDao.java
public List<Code> selectListForCache() { List<Code> list = sqlSession.selectList(namespace + ".selectListForCache", ""); return list;}

 

 

 

다오 다음코드 삽입

 

codeServiceImpl.java
@PostConstruct
	public void selectListForCache(){
		
		List<Code> codeListFromDb = (ArrayList<Code>) dao.selectListForCache();
		
		Code.cachedCodeArrayList.clear();
		Code.cachedCodeArrayList.addAll(codeListFromDb);
		System.out.println("cachedCodeArrayList: " + Code.cachedCodeArrayList.size() + " catched !!");
		
	}
	public static List<Code> selectListCachedCode(String ifcgSeq) throws Exception {
		List<Code> rt = new ArrayList<Code>();
		for(Code codeRow : Code.cachedCodeArrayList) {
			if(codeRow.getIfcgSeq().equals(ifcgSeq)) {
				rt.add(codeRow);
			} else {
				// by pass
			}
		}
		return rt;
	}

 

 

 

 

임플에 다음코드 삽입

 

 

 

 

결과값

 

 

 

 

 

 


 

 

 

To be continue..

복사했습니다!