se模式
一。基本的面向对象原则:封装,多态,针对接口。
二。策略模式:
???????????
?
具体店面:
?
package maintest;/** * @author handw * @date 2009-12-12 下午03:07:06 * @infomation:单例 */public class Sington { private static Sington sington; private String QueryCarSQL="select * from mg_car"; private String QueryStationSQL="select * from mg_car"; /** * 私有构造方法 */private Sington() {}/** * 返回实例 * @author handw * @date 2009-12-12 下午03:08:11 * @infomation: * @return */public static Sington getSingtonIntance(){if(sington==null){ synchronized (Sington.class) {//---比同步一个变量的作用范围大,它相当于同步静态方法if(sington==null){ sington=new Sington();} }} return sington;} public String getPublicQueryCar() { return "select * from mg_car"; } /** * 外部不可用 * @author handw * @date 2009-12-12 下午03:43:21 * @infomation: * @return */ private String getPrivateQueryCar() { return "select * from mg_car"; } /** * * @author handw * @date 2009-12-12 下午03:43:42 * @infomation:同一个包中,子类,内部可用 * @return */ protected String getProtectedQueryCar() { return "select * from mg_car"; } /** * * @author handw * @date 2009-12-12 下午03:46:08 * @infomation:友好权限 * @return */ String getFriendly() { return "select * from mg_car"; }}?
也个同步获得实例的静态方法,但是性能不好,不如同步块,只是在第一次创建的时候同步块才运行一次。
?
?
?
?
?
?
?
?