标签:cdn int 模式 session alt 应用 ref container 配置
github https://github.com/spring2go/core-spring-patterns.git
public interface IFan {
public void swithOn();
public void switchOff();
}
生产日光灯
public interface IElectricalFactory {
IFan createFan();
ITubeLight createTubeLight();
}
// 中国制造的风扇
public class ChineseFan implements IFan {
public void swithOn() {
System.out.println("The ChineseFan is swithed on ...");
}
public void switchOff() {
System.out.println("The ChineseFan is swithed off ...");
}
}
// 中国制造的台灯
public class ChineseTubeLight implements ITubeLight {
public void swithOn() {
System.out.println("The ChineseTubeLight is swithed on ...");
}
public void switchOff() {
System.out.println("The ChineseTubeLight is swithed off ...");
}
public void tuneLight() {
System.out.println("The ChineseTubeLight is tuned ...");
}
}
// 中国 电器工厂 实现
public class ChineseElectricalFactory implements IElectricalFactory {
public IFan createFan() {
return new ChineseFan();
}
public ITubeLight createTubeLight() {
return new ChineseTubeLight();
}
}
// 美国制造的风扇
public class USFan implements IFan {
public void swithOn() {
System.out.println("The USFan is swithed on ...");
}
public void switchOff() {
System.out.println("The USFan is swithed off ...");
}
}
// 美国制造的 日光灯
public class USTubeLight implements ITubeLight {
public void swithOn() {
System.out.println("The USTubeLight is swithed on ...");
}
public void switchOff() {
System.out.println("The USTubeLight is swithed off ...");
}
public void tuneLight() {
System.out.println("The USTubeLight is tuned ...");
}
}
// 美国 电器工厂的 实现
public class USElectricalFactory implements IElectricalFactory {
public IFan createFan() {
return new USFan();
}
public ITubeLight createTubeLight() {
return new USTubeLight();
}
}
public class AbstractFactoryMain {
public static void main(String[] args) {
// 中国 电器工厂 出来的产品都是中国风格的产品
IElectricalFactory electricalFactory = new ChineseElectricalFactory();
IFan fan = electricalFactory.createFan();
fan.swithOn();
// 美国 电器工厂 出来的产品都是美国风格的产品
electricalFactory = new USElectricalFactory();
ITubeLight tubeLight = electricalFactory.createTubeLight();
tubeLight.swithOn();
tubeLight.tuneLight();
}
}
标签:cdn int 模式 session alt 应用 ref container 配置
原文地址:https://www.cnblogs.com/zhangjianbin/p/9147832.html