首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

模板方法方式与回调函数

2012-09-12 
模板方法模式与回调函数先上模板方法模式的类图:代码演示:public interface StatementCallback{Object doW

模板方法模式与回调函数
先上模板方法模式的类图:

代码演示:

public interface StatementCallback{      Object doWithStatement(Statement stmt);}public class JdbcTemplate {      public final Object execute(StatementCallback callback){   Connection con=null;   Statement stmt=null;   try   {        con=getConnection();        stmt=con.createStatement();        Object retValue=callback.doWithStatement(stmt);        return retValue;   }    catch(SQLException e){         ...   }    finally   {       closeStatement(stmt);        releaseConnection(con);   }}



热点排行