일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 네트워크
- VirtualBox
- 줄바꿈 문자
- plugin
- Quartz
- grep
- import
- Windows
- JavaScript
- web.xml
- bash
- port
- Mac
- tomcat
- find
- lsof
- vscode
- resource
- Windows 10
- 단축키
- maVen
- netsh
- Eclipse
- Source
- ssh
- IntelliJ
- context
- xargs
- GIT
- profile
- 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 |