일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- vscode
- VirtualBox
- tomcat
- xargs
- Windows
- GIT
- Quartz
- netsh
- JavaScript
- maVen
- find
- resource
- IntelliJ
- lsof
- bash
- grep
- import
- 네트워크
- 줄바꿈 문자
- ssh
- port
- context
- plugin
- Source
- 단축키
- web.xml
- profile
- Eclipse
- Windows 10
- Mac
- Today
- Total
develog
template, callback 본문
public class Service {
private Dao dao;
public void setDao(Dao dao) {
this.dao = dao;
}
private void template(IService service, Map<String, String> param) {
Connection conn = null;
try {
conn = ConnectionManager.getConnection();
service.invoke(conn, param);
} catch (Exception e) {
e.printStackTrace();
} finally {
ConnectionManager.closeConnection(conn);
}
}
public void insertUser(String userSeq) {
Map<String, String> param = new HashMap<String, String>();
param.put("USER_SEQ", userSeq);
template(new IService() {
public void invoke(Connection conn, Map<String, String> param) throws Exception {
dao.insertUser(conn, param);
}
}, param);
}
}
interface IService {
public void invoke(Connection conn, Map<String, String> param) throws Exception;
}
'Dev > Java' 카테고리의 다른 글
REQUIRES_NEW (0) | 2013.07.18 |
---|---|
jndi (0) | 2013.07.18 |
AsyncHttpClient (0) | 2013.07.11 |
StringBuilder, replace (0) | 2013.07.11 |
spring-test-dbunit (0) | 2013.07.09 |