diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index d217914..c8e70dd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,6 +1,7 @@
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index ab9e0f0..00cc6c2 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,7 +1,108 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -9,35 +110,58 @@
+
+
+
+
+
+
-
+
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
-
-
+
+
+
+
-
+
+
+
+
-
+
+
+
+
@@ -45,25 +169,13 @@
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
+
+
+
@@ -72,6 +184,7 @@
@@ -79,23 +192,72 @@
List<WeChatUser> userList
+ TOMCAT
+ case1
WeChatUser weChatUser
+ Linux
+ logicTest
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -117,6 +279,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -126,12 +304,13 @@
+
-
+
@@ -156,39 +335,47 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -202,29 +389,100 @@
-
+
-
-
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -252,9 +510,20 @@
+
+
+
+
+
+
+
-
+
+
+
+
+
@@ -270,17 +539,206 @@
1550332102563
+
+
+
+
+
+
+
+
+
+
+
+
+ 1550497556468
+
+
+
+ 1550497556468
+
+
+ 1550497864256
+
+
+
+ 1550497864256
+
+
+ 1550498046807
+
+
+
+ 1550498046807
+
+
+ 1550498615539
+
+
+
+ 1550498615539
+
+
+ 1550498663917
+
+
+
+ 1550498663917
+
+
+ 1550498705101
+
+
+
+ 1550498705101
+
+
+ 1550675876004
+
+
+
+ 1550675876004
+
+
+ 1550762815911
+
+
+
+ 1550762815911
+
+
+ 1550762880374
+
+
+
+ 1550762880374
+
+
+ 1550762907662
+
+
+
+ 1550762907662
+
+
+ 1550763092270
+
+
+
+ 1550763092270
+
+
+ 1550763298187
+
+
+
+ 1550763298187
+
+
+ 1550929327841
+
+
+
+ 1550929327841
+
+
+ 1550929360294
+
+
+
+ 1550929360294
+
+
+ 1550929565432
+
+
+
+ 1550929565432
+
+
+ 1550931738216
+
+
+
+ 1550931738224
+
+
+ 1550975271892
+
+
+
+ 1550975271892
+
+ 1551017118404
+
+
+
+ 1551017118404
+
+
+ 1551017164486
+
+
+
+ 1551017164486
+
+
+ 1551107239988
+
+
+
+ 1551107239988
+
+
+ 1551107455450
+
+
+
+ 1551107455450
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
@@ -290,27 +748,28 @@
-
-
+
+
-
+
-
+
-
+
+
-
+
@@ -318,7 +777,7 @@
-
+
@@ -328,27 +787,28 @@
-
-
+
+
-
+
-
+
-
+
+
-
+
@@ -362,147 +822,431 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- file://$PROJECT_DIR$/src/main/com/mxy/design/observer/WeChatSubjectImpl.java
+ file://$PROJECT_DIR$/src/main/com/mxy/design/observer/WeChatOfficialAccountImpl.java
30
- file://$PROJECT_DIR$/src/main/com/mxy/design/observer/MAIN.java
- 9
+ file://$PROJECT_DIR$/src/test/com/mxy/design/decorator/DecoratorTest.java
+ 27
+
+
+
+
+ file://$PROJECT_DIR$/src/test/com/mxy/design/proxy/DynamicProxyTest.java
+ 42
+
+
+
+
+ file://$PROJECT_DIR$/src/main/com/mxy/design/proxy/dynamic/jdk/proxy/StudentJdkProxy.java
+ 18
+
+
+
+
+ jar://E:/Java/Java1.8/src.zip!/java/lang/reflect/Proxy.java
+ 709
-
+
-
- jar://E:/Java/Java1.8/src.zip!/java/io/PrintStream.java
- 804
+
+ file://$PROJECT_DIR$/src/main/com/mxy/design/proxy/dynamic/jdk/proxy/StudentJdkProxy.java
+ 23
+
+
+
+
+ jar://E:/Java/Java1.8/src.zip!/java/lang/reflect/Method.java
+ 487
-
+
+
+
+
+ h
+ JAVA
+ EXPRESSION
+
+
+ interfaces.length
+ JAVA
+ EXPRESSION
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..dc889d5
--- /dev/null
+++ b/README.md
@@ -0,0 +1,29 @@
+# DesignPatterns
+
+1.观察者模式 - 已上传
+
+2.装饰模式- 已上传
+
+3.策略模式-已上传
+
+4.适配器模式- 已上传
+
+5.代理模式- 已上传
+
+6.模板模式- 已上传
+
+7.工厂模式(抽象)- 整理中
+
+8.桥接模式- 整理中
+
+9.门面模式- 整理中
+
+10.组合模式- 整理中
+
+11.状态模式- 整理中
+
+12.命令模式- 整理中
+
+13.解释器模式- 整理中
+
+
diff --git a/pom.xml b/pom.xml
index 31f7351..db8e35c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -84,6 +84,14 @@
1.1.0.Final
+
+
+ cglib
+ cglib
+ 3.2.10
+
+
+
diff --git a/src/main/com/mxy/design/adapter/classes/adapter/Ps2Connector.java b/src/main/com/mxy/design/adapter/classes/adapter/Ps2Connector.java
new file mode 100644
index 0000000..cce86b6
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/classes/adapter/Ps2Connector.java
@@ -0,0 +1,11 @@
+package com.mxy.design.adapter.classes.adapter;
+
+/**
+ * ps2插口
+ */
+public interface Ps2Connector {
+
+
+ void ps2Description();
+
+}
diff --git a/src/main/com/mxy/design/adapter/classes/adapter/Ps2UsbAdapter.java b/src/main/com/mxy/design/adapter/classes/adapter/Ps2UsbAdapter.java
new file mode 100644
index 0000000..a4d766c
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/classes/adapter/Ps2UsbAdapter.java
@@ -0,0 +1,17 @@
+package com.mxy.design.adapter.classes.adapter;
+
+/**
+ * 1.类适配器
+ * PS2 to Usb 转换口
+ */
+public class Ps2UsbAdapter extends UsbConnectorImpl implements Ps2Connector {
+
+ /**
+ * 重点:继承你需要适配的类
+ */
+ @Override
+ public void ps2Description() {
+ System.out.println("正在进行 PS/2适配USB中....");
+ usbDescription();
+ }
+}
diff --git a/src/main/com/mxy/design/adapter/classes/adapter/PsConnectorImpl.java b/src/main/com/mxy/design/adapter/classes/adapter/PsConnectorImpl.java
new file mode 100644
index 0000000..9512200
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/classes/adapter/PsConnectorImpl.java
@@ -0,0 +1,11 @@
+package com.mxy.design.adapter.classes.adapter;
+
+
+public class PsConnectorImpl implements Ps2Connector {
+
+ @Override
+ public void ps2Description() {
+
+ System.out.println("使用PS/2插口");
+ }
+}
diff --git a/src/main/com/mxy/design/adapter/classes/adapter/UsbConnector.java b/src/main/com/mxy/design/adapter/classes/adapter/UsbConnector.java
new file mode 100644
index 0000000..e016fc9
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/classes/adapter/UsbConnector.java
@@ -0,0 +1,11 @@
+package com.mxy.design.adapter.classes.adapter;
+
+/**
+ * USB插口
+ */
+public interface UsbConnector {
+
+
+ void usbDescription();
+
+}
diff --git a/src/main/com/mxy/design/adapter/classes/adapter/UsbConnectorImpl.java b/src/main/com/mxy/design/adapter/classes/adapter/UsbConnectorImpl.java
new file mode 100644
index 0000000..fd983ee
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/classes/adapter/UsbConnectorImpl.java
@@ -0,0 +1,12 @@
+package com.mxy.design.adapter.classes.adapter;
+
+/**
+ * 使用USB插槽
+ */
+public class UsbConnectorImpl implements UsbConnector {
+
+ @Override
+ public void usbDescription() {
+ System.out.println("使用USB插口");
+ }
+}
diff --git a/src/main/com/mxy/design/adapter/interfaces/adapter/Adapter.java b/src/main/com/mxy/design/adapter/interfaces/adapter/Adapter.java
new file mode 100644
index 0000000..a297f59
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/interfaces/adapter/Adapter.java
@@ -0,0 +1,23 @@
+package com.mxy.design.adapter.interfaces.adapter;
+
+/**
+ * 接口适配器:重在共享接口功能,并为继承该适配器的类提供各自所需方法
+ */
+public abstract class Adapter implements Port {
+
+ @Override
+ public void SSH() {
+
+ }
+
+ @Override
+ public void NET() {
+
+ }
+
+ @Override
+ public void FTP() {
+
+ }
+
+}
diff --git a/src/main/com/mxy/design/adapter/interfaces/adapter/Chat.java b/src/main/com/mxy/design/adapter/interfaces/adapter/Chat.java
new file mode 100644
index 0000000..312a900
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/interfaces/adapter/Chat.java
@@ -0,0 +1,17 @@
+package com.mxy.design.adapter.interfaces.adapter;
+/**
+ * 该类只需要 NET FTP 就够了 所以继承父类并重写
+ */
+public class Chat extends Adapter {
+
+
+ @Override
+ public void NET() {
+ System.out.println("Chat 开启80端口");
+ }
+
+ @Override
+ public void FTP() {
+ System.out.println("Chat 开启21端口");
+ }
+}
diff --git a/src/main/com/mxy/design/adapter/interfaces/adapter/Linux.java b/src/main/com/mxy/design/adapter/interfaces/adapter/Linux.java
new file mode 100644
index 0000000..b89d6fb
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/interfaces/adapter/Linux.java
@@ -0,0 +1,22 @@
+package com.mxy.design.adapter.interfaces.adapter;
+
+/**
+ * 该系统需要全部方法
+ */
+public class Linux implements Port {
+
+ @Override
+ public void SSH() {
+ System.out.println("Linux 开启22端口");
+ }
+
+ @Override
+ public void NET() {
+ System.out.println("Linux 开启80端口");
+ }
+
+ @Override
+ public void FTP() {
+ System.out.println("Linux 开启21端口");
+ }
+}
diff --git a/src/main/com/mxy/design/adapter/interfaces/adapter/Port.java b/src/main/com/mxy/design/adapter/interfaces/adapter/Port.java
new file mode 100644
index 0000000..1203d25
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/interfaces/adapter/Port.java
@@ -0,0 +1,17 @@
+package com.mxy.design.adapter.interfaces.adapter;
+
+/**
+ * 各种协议端口
+ */
+public interface Port {
+
+ // 远程SSH端口22
+ public void SSH();
+
+ // 网络端口80
+ public void NET();
+
+ // 文件传输FTP端口21
+ public void FTP();
+}
+
diff --git a/src/main/com/mxy/design/adapter/interfaces/adapter/Tomcat.java b/src/main/com/mxy/design/adapter/interfaces/adapter/Tomcat.java
new file mode 100644
index 0000000..e9878cb
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/interfaces/adapter/Tomcat.java
@@ -0,0 +1,13 @@
+package com.mxy.design.adapter.interfaces.adapter;
+
+/**
+ * 该类只需要 NET 就够了 所以继承父类并重写
+ */
+public class Tomcat extends Adapter {
+
+
+ @Override
+ public void NET() {
+ System.out.println("Tomcat 开启80端口");
+ }
+}
diff --git a/src/main/com/mxy/design/adapter/object/adapater/Ps2Connector.java b/src/main/com/mxy/design/adapter/object/adapater/Ps2Connector.java
new file mode 100644
index 0000000..e044504
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/object/adapater/Ps2Connector.java
@@ -0,0 +1,11 @@
+package com.mxy.design.adapter.object.adapater;
+
+/**
+ * ps2插口
+ */
+public interface Ps2Connector {
+
+
+ void ps2Description();
+
+}
diff --git a/src/main/com/mxy/design/adapter/object/adapater/Ps2UsbAdapter.java b/src/main/com/mxy/design/adapter/object/adapater/Ps2UsbAdapter.java
new file mode 100644
index 0000000..de06190
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/object/adapater/Ps2UsbAdapter.java
@@ -0,0 +1,25 @@
+package com.mxy.design.adapter.object.adapater;
+
+/**
+ * 1.对象适配器
+ * PS2 to Usb 转换口
+ */
+public class Ps2UsbAdapter implements Ps2Connector {
+
+
+ /**
+ * 重点:在适配器里面持有需要适配的对象
+ */
+ private UsbConnector usbConnector;
+
+
+ public Ps2UsbAdapter(UsbConnector usbConnector) {
+ this.usbConnector = usbConnector;
+ }
+
+ @Override
+ public void ps2Description() {
+ System.out.println("正在进行 PS/2适配USB中....");
+ usbConnector.usbDescription();
+ }
+}
diff --git a/src/main/com/mxy/design/adapter/object/adapater/PsConnectorImpl.java b/src/main/com/mxy/design/adapter/object/adapater/PsConnectorImpl.java
new file mode 100644
index 0000000..5464ded
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/object/adapater/PsConnectorImpl.java
@@ -0,0 +1,11 @@
+package com.mxy.design.adapter.object.adapater;
+
+
+public class PsConnectorImpl implements Ps2Connector {
+
+ @Override
+ public void ps2Description() {
+
+ System.out.println("使用PS/2插口");
+ }
+}
diff --git a/src/main/com/mxy/design/adapter/object/adapater/UsbConnector.java b/src/main/com/mxy/design/adapter/object/adapater/UsbConnector.java
new file mode 100644
index 0000000..1307c7f
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/object/adapater/UsbConnector.java
@@ -0,0 +1,11 @@
+package com.mxy.design.adapter.object.adapater;
+
+/**
+ * USB插口
+ */
+public interface UsbConnector {
+
+
+ void usbDescription();
+
+}
diff --git a/src/main/com/mxy/design/adapter/object/adapater/UsbConnectorImpl.java b/src/main/com/mxy/design/adapter/object/adapater/UsbConnectorImpl.java
new file mode 100644
index 0000000..f8eff55
--- /dev/null
+++ b/src/main/com/mxy/design/adapter/object/adapater/UsbConnectorImpl.java
@@ -0,0 +1,12 @@
+package com.mxy.design.adapter.object.adapater;
+
+/**
+ * 使用USB插槽
+ */
+public class UsbConnectorImpl implements UsbConnector {
+
+ @Override
+ public void usbDescription() {
+ System.out.println("使用USB插口");
+ }
+}
diff --git a/src/main/com/mxy/design/decorator/Cake.java b/src/main/com/mxy/design/decorator/Cake.java
new file mode 100644
index 0000000..848dc7b
--- /dev/null
+++ b/src/main/com/mxy/design/decorator/Cake.java
@@ -0,0 +1,15 @@
+package com.mxy.design.decorator;
+
+public interface Cake {
+
+ /**
+ * 描述
+ */
+ String description();
+
+ /**
+ * 花费金额
+ */
+ double cost();
+
+}
diff --git a/src/main/com/mxy/design/decorator/CakeDecorator.java b/src/main/com/mxy/design/decorator/CakeDecorator.java
new file mode 100644
index 0000000..906d7ce
--- /dev/null
+++ b/src/main/com/mxy/design/decorator/CakeDecorator.java
@@ -0,0 +1,12 @@
+package com.mxy.design.decorator;
+
+public abstract class CakeDecorator implements Cake {
+
+
+ protected Cake cake;
+
+ public CakeDecorator(Cake cake) {
+ this.cake = cake;
+ }
+
+}
diff --git a/src/main/com/mxy/design/decorator/CakeImpl.java b/src/main/com/mxy/design/decorator/CakeImpl.java
new file mode 100644
index 0000000..4cd4567
--- /dev/null
+++ b/src/main/com/mxy/design/decorator/CakeImpl.java
@@ -0,0 +1,15 @@
+package com.mxy.design.decorator;
+
+public class CakeImpl implements Cake {
+
+
+ @Override
+ public String description() {
+ return "蛋糕";
+ }
+
+ @Override
+ public double cost() {
+ return 10;
+ }
+}
diff --git a/src/main/com/mxy/design/decorator/Candle.java b/src/main/com/mxy/design/decorator/Candle.java
new file mode 100644
index 0000000..80a5669
--- /dev/null
+++ b/src/main/com/mxy/design/decorator/Candle.java
@@ -0,0 +1,29 @@
+package com.mxy.design.decorator;
+
+
+public class Candle extends CakeDecorator {
+
+ double candleCost = 30;
+
+ public Candle(Cake cake) {
+ super(cake);
+ }
+
+ @Override
+ public String description() {
+ return "蜡烛";
+ }
+
+ @Override
+ public double cost() {
+ return (candleCost) + (cake.cost());
+ }
+
+ /**
+ * 涨价
+ * @param price
+ */
+ public void risePrice(double price) {
+ this.candleCost += price;
+ }
+}
diff --git a/src/main/com/mxy/design/decorator/Fruits.java b/src/main/com/mxy/design/decorator/Fruits.java
new file mode 100644
index 0000000..fe5e919
--- /dev/null
+++ b/src/main/com/mxy/design/decorator/Fruits.java
@@ -0,0 +1,25 @@
+package com.mxy.design.decorator;
+
+public class Fruits extends CakeDecorator {
+
+ double fruitsCost = 20;
+
+ /**
+ * 构造为了 调用父类方法
+ *
+ * @param cake
+ */
+ public Fruits(Cake cake) {
+ super(cake);
+ }
+
+ @Override
+ public String description() {
+ return "水果";
+ }
+
+ @Override
+ public double cost() {
+ return (fruitsCost) + (cake.cost());
+ }
+}
diff --git a/src/main/com/mxy/design/observer/MAIN.java b/src/main/com/mxy/design/observer/MAIN.java
deleted file mode 100644
index bede442..0000000
--- a/src/main/com/mxy/design/observer/MAIN.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.mxy.design.observer;
-
-/**
- * 观察者模式
- */
-public class MAIN {
-
- public static void main(String[] args) {
-
- WeChatSubject subject = new WeChatSubjectImpl();
- //微信公众号关注的用户
- subject.followUser(new WeChatUser(1, "张三"));
- subject.followUser(new WeChatUser(3, "李四"));
- subject.followUser(new WeChatUser(2, "王五"));
- //推送文章
- subject.notifyObServer("C#学习入门");
- //王五不关注了 觉得该公众号很烂 ^_^
- subject.cancelFollowUser(new WeChatUser(2,"王五"));
-
- //继续推送文章给其他两位
- subject.notifyObServer("spring学习入门");
-
-
-
- }
-
-}
diff --git a/src/main/com/mxy/design/observer/WeChatSubject.java b/src/main/com/mxy/design/observer/WeChatOfficialAccount.java
similarity index 90%
rename from src/main/com/mxy/design/observer/WeChatSubject.java
rename to src/main/com/mxy/design/observer/WeChatOfficialAccount.java
index 4f35023..3546a16 100644
--- a/src/main/com/mxy/design/observer/WeChatSubject.java
+++ b/src/main/com/mxy/design/observer/WeChatOfficialAccount.java
@@ -1,6 +1,6 @@
package com.mxy.design.observer;
-public interface WeChatSubject {
+public interface WeChatOfficialAccount {
/**
* 该公众号关注的用户
diff --git a/src/main/com/mxy/design/observer/WeChatSubjectImpl.java b/src/main/com/mxy/design/observer/WeChatOfficialAccountImpl.java
similarity index 94%
rename from src/main/com/mxy/design/observer/WeChatSubjectImpl.java
rename to src/main/com/mxy/design/observer/WeChatOfficialAccountImpl.java
index 536aac2..0fc34e9 100644
--- a/src/main/com/mxy/design/observer/WeChatSubjectImpl.java
+++ b/src/main/com/mxy/design/observer/WeChatOfficialAccountImpl.java
@@ -7,7 +7,7 @@
import java.util.List;
-public class WeChatSubjectImpl implements WeChatSubject {
+public class WeChatOfficialAccountImpl implements WeChatOfficialAccount {
private List users = new ArrayList<>();
diff --git a/src/main/com/mxy/design/proxy/IStudent.java b/src/main/com/mxy/design/proxy/IStudent.java
new file mode 100644
index 0000000..2477d73
--- /dev/null
+++ b/src/main/com/mxy/design/proxy/IStudent.java
@@ -0,0 +1,9 @@
+package com.mxy.design.proxy;
+
+public interface IStudent {
+
+ void save();
+
+ void delete();
+
+}
diff --git a/src/main/com/mxy/design/proxy/StudentImpl.java b/src/main/com/mxy/design/proxy/StudentImpl.java
new file mode 100644
index 0000000..3193002
--- /dev/null
+++ b/src/main/com/mxy/design/proxy/StudentImpl.java
@@ -0,0 +1,13 @@
+package com.mxy.design.proxy;
+
+public class StudentImpl implements IStudent {
+ @Override
+ public void save() {
+ System.out.println("保存ing");
+ }
+
+ @Override
+ public void delete() {
+ System.out.println("删除ing");
+ }
+}
diff --git a/src/main/com/mxy/design/proxy/StudentProxy.java b/src/main/com/mxy/design/proxy/StudentProxy.java
new file mode 100644
index 0000000..f5271c0
--- /dev/null
+++ b/src/main/com/mxy/design/proxy/StudentProxy.java
@@ -0,0 +1,36 @@
+package com.mxy.design.proxy;
+
+import java.util.Random;
+
+/**
+ * 重点类 静态代理 实现目标接口
+ */
+public class StudentProxy implements IStudent {
+
+ private IStudent student;
+
+ public StudentProxy(IStudent iStudent) {
+ this.student = iStudent;
+ }
+
+ @Override
+ public void save() {
+ System.out.println("==开启事务");
+ student.save();
+ System.out.println("==提交事务");
+ }
+
+ @Override
+ public void delete() {
+ Random random = new Random();
+ //查询是否存在
+ if(random.nextBoolean()){
+ System.out.println("===开启事务");
+ student.delete();
+ System.out.println("===提交事务");
+ }else{
+ System.out.println("===该用户已经被删除");
+ }
+
+ }
+}
diff --git a/src/main/com/mxy/design/proxy/dynamic/cglib/proxy/IStudent.java b/src/main/com/mxy/design/proxy/dynamic/cglib/proxy/IStudent.java
new file mode 100644
index 0000000..6ff4a41
--- /dev/null
+++ b/src/main/com/mxy/design/proxy/dynamic/cglib/proxy/IStudent.java
@@ -0,0 +1,9 @@
+package com.mxy.design.proxy.dynamic.cglib.proxy;
+
+public interface IStudent {
+
+ void save();
+
+ void delete();
+
+}
diff --git a/src/main/com/mxy/design/proxy/dynamic/cglib/proxy/StudentCglibProxy.java b/src/main/com/mxy/design/proxy/dynamic/cglib/proxy/StudentCglibProxy.java
new file mode 100644
index 0000000..77f85b6
--- /dev/null
+++ b/src/main/com/mxy/design/proxy/dynamic/cglib/proxy/StudentCglibProxy.java
@@ -0,0 +1,23 @@
+package com.mxy.design.proxy.dynamic.cglib.proxy;
+
+import net.sf.cglib.proxy.Enhancer;
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+
+import java.lang.reflect.Method;
+
+/**
+ * 动态代理 实现JDK 接口
+ */
+public class StudentCglibProxy implements MethodInterceptor {
+
+
+ @Override
+ public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
+ return methodProxy.invokeSuper(o, objects);
+ }
+
+ public T getInstance(Class objClass) {
+ return (T)Enhancer.create(objClass.getClass(), this);
+ }
+}
diff --git a/src/main/com/mxy/design/proxy/dynamic/cglib/proxy/StudentImpl.java b/src/main/com/mxy/design/proxy/dynamic/cglib/proxy/StudentImpl.java
new file mode 100644
index 0000000..dff60d9
--- /dev/null
+++ b/src/main/com/mxy/design/proxy/dynamic/cglib/proxy/StudentImpl.java
@@ -0,0 +1,13 @@
+package com.mxy.design.proxy.dynamic.cglib.proxy;
+
+public class StudentImpl implements IStudent {
+ @Override
+ public void save() {
+ System.out.println("保存ing");
+ }
+
+ @Override
+ public void delete() {
+ System.out.println("删除ing");
+ }
+}
diff --git a/src/main/com/mxy/design/proxy/dynamic/jdk/proxy/IStudent.java b/src/main/com/mxy/design/proxy/dynamic/jdk/proxy/IStudent.java
new file mode 100644
index 0000000..02a7667
--- /dev/null
+++ b/src/main/com/mxy/design/proxy/dynamic/jdk/proxy/IStudent.java
@@ -0,0 +1,9 @@
+package com.mxy.design.proxy.dynamic.jdk.proxy;
+
+public interface IStudent {
+
+ void save();
+
+ void delete();
+
+}
diff --git a/src/main/com/mxy/design/proxy/dynamic/jdk/proxy/StudentImpl.java b/src/main/com/mxy/design/proxy/dynamic/jdk/proxy/StudentImpl.java
new file mode 100644
index 0000000..2c7cf4e
--- /dev/null
+++ b/src/main/com/mxy/design/proxy/dynamic/jdk/proxy/StudentImpl.java
@@ -0,0 +1,13 @@
+package com.mxy.design.proxy.dynamic.jdk.proxy;
+
+public class StudentImpl implements IStudent {
+ @Override
+ public void save() {
+ System.out.println("保存ing");
+ }
+
+ @Override
+ public void delete() {
+ System.out.println("删除ing");
+ }
+}
diff --git a/src/main/com/mxy/design/proxy/dynamic/jdk/proxy/StudentJdkProxy.java b/src/main/com/mxy/design/proxy/dynamic/jdk/proxy/StudentJdkProxy.java
new file mode 100644
index 0000000..f2d6e96
--- /dev/null
+++ b/src/main/com/mxy/design/proxy/dynamic/jdk/proxy/StudentJdkProxy.java
@@ -0,0 +1,26 @@
+package com.mxy.design.proxy.dynamic.jdk.proxy;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+/**
+ * 动态代理 实现JDK 接口
+ */
+public class StudentJdkProxy implements InvocationHandler {
+
+ private Object target;
+
+ public StudentJdkProxy(Object object) {
+ this.target = object;
+ }
+
+ public T getInstance() {
+ return (T) Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), this);
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ return method.invoke(target, args);
+ }
+}
diff --git a/src/main/com/mxy/design/strategy/DiscountStrategy.java b/src/main/com/mxy/design/strategy/DiscountStrategy.java
new file mode 100644
index 0000000..a34e17c
--- /dev/null
+++ b/src/main/com/mxy/design/strategy/DiscountStrategy.java
@@ -0,0 +1,12 @@
+package com.mxy.design.strategy;
+
+/**
+ * 策略角色
+ */
+public interface DiscountStrategy {
+
+
+ double calculateDiscount(double price);
+
+
+}
diff --git a/src/main/com/mxy/design/strategy/NewCustomerQuoteStrategy.java b/src/main/com/mxy/design/strategy/NewCustomerQuoteStrategy.java
new file mode 100644
index 0000000..af81ccc
--- /dev/null
+++ b/src/main/com/mxy/design/strategy/NewCustomerQuoteStrategy.java
@@ -0,0 +1,15 @@
+package com.mxy.design.strategy;
+
+import java.math.BigDecimal;
+
+/**
+ * 策略角色实现 新客户
+ */
+public class NewCustomerQuoteStrategy implements DiscountStrategy {
+
+ @Override
+ public double calculateDiscount(double price) {
+ System.out.println("老顾客9折");
+ return new BigDecimal(price).multiply(new BigDecimal(0.9)).doubleValue();
+ }
+}
diff --git a/src/main/com/mxy/design/strategy/OldCustomerQuoteStrategy.java b/src/main/com/mxy/design/strategy/OldCustomerQuoteStrategy.java
new file mode 100644
index 0000000..768c63c
--- /dev/null
+++ b/src/main/com/mxy/design/strategy/OldCustomerQuoteStrategy.java
@@ -0,0 +1,17 @@
+package com.mxy.design.strategy;
+
+import java.math.BigDecimal;
+
+/**
+ * 策略角色实现 老客户
+ */
+public class OldCustomerQuoteStrategy implements DiscountStrategy {
+
+
+
+ @Override
+ public double calculateDiscount(double price) {
+ System.out.println("老顾客8折");
+ return new BigDecimal(price).multiply(new BigDecimal(0.8)).doubleValue();
+ }
+}
diff --git a/src/main/com/mxy/design/strategy/StrategyContext.java b/src/main/com/mxy/design/strategy/StrategyContext.java
new file mode 100644
index 0000000..63d5ccf
--- /dev/null
+++ b/src/main/com/mxy/design/strategy/StrategyContext.java
@@ -0,0 +1,24 @@
+package com.mxy.design.strategy;
+
+/**
+ * 策略环境 重点类
+ */
+public class StrategyContext {
+
+ private DiscountStrategy discountStrategy;
+
+ public StrategyContext(DiscountStrategy discountStrategy) {
+ this.discountStrategy = discountStrategy;
+ }
+
+ /**
+ * 多态机制
+ * @param price
+ * @return
+ */
+ public double invoke(double price) {
+ return discountStrategy.calculateDiscount(price);
+ }
+
+
+}
diff --git a/src/main/com/mxy/design/strategy/VipCustomerQuoteStrategy.java b/src/main/com/mxy/design/strategy/VipCustomerQuoteStrategy.java
new file mode 100644
index 0000000..d73742c
--- /dev/null
+++ b/src/main/com/mxy/design/strategy/VipCustomerQuoteStrategy.java
@@ -0,0 +1,15 @@
+package com.mxy.design.strategy;
+
+import java.math.BigDecimal;
+
+/**
+ * 策略角色实现 vip客户
+ */
+public class VipCustomerQuoteStrategy implements DiscountStrategy {
+
+ @Override
+ public double calculateDiscount(double price) {
+ System.out.println("vip顾客5折");
+ return new BigDecimal(price).multiply(new BigDecimal(0.5)).doubleValue();
+ }
+}
diff --git a/src/main/com/mxy/design/template/ProcessTempLate.java b/src/main/com/mxy/design/template/ProcessTempLate.java
new file mode 100644
index 0000000..74aed65
--- /dev/null
+++ b/src/main/com/mxy/design/template/ProcessTempLate.java
@@ -0,0 +1,36 @@
+package com.mxy.design.template;
+
+/**
+ * 抽象模板
+ */
+public abstract class ProcessTempLate {
+
+ /**
+ * 校验参数
+ */
+ protected void checkParam(String... arg) {
+ if( null == arg){
+ System.out.println("参数为null");
+ return;
+ }
+ }
+
+ /**
+ * 主逻辑业务
+ */
+ protected abstract void mainLogic();
+
+ /**
+ * 执行模板
+ */
+ protected void invoke(String... param) {
+ try {
+ checkParam(param);
+ mainLogic();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/src/test/com/mxy/design/adapter/ClassesAdapterTest.java b/src/test/com/mxy/design/adapter/ClassesAdapterTest.java
new file mode 100644
index 0000000..06bf946
--- /dev/null
+++ b/src/test/com/mxy/design/adapter/ClassesAdapterTest.java
@@ -0,0 +1,34 @@
+package com.mxy.design.adapter;
+
+import com.mxy.design.adapter.classes.adapter.Ps2Connector;
+import com.mxy.design.adapter.classes.adapter.Ps2UsbAdapter;
+import com.mxy.design.adapter.classes.adapter.PsConnectorImpl;
+import org.junit.Test;
+
+/**
+ * 适配器:这种模式涉及到一个单一的类,该类负责加入独立的或不兼容的接口功能
+ * 适配器分为两类:类适配器模式、对象的适配器模式,接口适配器
+ * 不同点:
+ * 1.类适配器:使用继承
+ * 2.对象适配器:使用组合(建议使用组合模式 降低耦合)
+ * 3.继承原有方法 子类需要重写需要的 并不需要全部都是实现
+ */
+public class ClassesAdapterTest {
+
+
+ /**
+ * 类适配器
+ */
+ @Test
+ public void logicTest() {
+ System.out.println("======适配前=======");
+ Ps2Connector ps2Connector = new PsConnectorImpl();
+ ps2Connector.ps2Description();
+ System.out.println("======适配后======");
+ Ps2Connector adapter = new Ps2UsbAdapter();
+ adapter.ps2Description();
+ }
+
+
+
+}
diff --git a/src/test/com/mxy/design/adapter/InterfaceAdapterTest.java b/src/test/com/mxy/design/adapter/InterfaceAdapterTest.java
new file mode 100644
index 0000000..2836d06
--- /dev/null
+++ b/src/test/com/mxy/design/adapter/InterfaceAdapterTest.java
@@ -0,0 +1,37 @@
+package com.mxy.design.adapter;
+
+import com.mxy.design.adapter.interfaces.adapter.Chat;
+import com.mxy.design.adapter.interfaces.adapter.Linux;
+import com.mxy.design.adapter.interfaces.adapter.Port;
+import com.mxy.design.adapter.interfaces.adapter.Tomcat;
+import org.junit.Test;
+/**
+ * 适配器:这种模式涉及到一个单一的类,该类负责加入独立的或不兼容的接口功能
+ * 适配器分为两类:类适配器模式、对象的适配器模式,接口适配器
+ * 不同点:
+ * 1.类适配器:使用继承
+ * 2.对象适配器:使用组合(建议使用组合模式 降低耦合)
+ * 3.继承原有方法 子类需要重写需要的 并不需要全部都是实现
+ */
+public class InterfaceAdapterTest {
+
+ /**
+ * 接口适配器
+ */
+ @Test
+ public void logicTest() {
+ System.out.println("====LINUX使用原生的端口");
+ Port linuxPort = new Linux();
+ linuxPort.FTP();
+ linuxPort.SSH();
+ linuxPort.NET();
+ System.out.println("====TOMCAT抽象并重写的端口");
+ Port tomcatPort = new Tomcat();
+ tomcatPort.NET();
+ System.out.println("====CHAT抽象并重写的端口");
+ Port ChatPort = new Chat();
+ ChatPort.FTP();
+ ChatPort.NET();
+ }
+
+}
diff --git a/src/test/com/mxy/design/adapter/ObjectAdapterTest.java b/src/test/com/mxy/design/adapter/ObjectAdapterTest.java
new file mode 100644
index 0000000..ec5b7ed
--- /dev/null
+++ b/src/test/com/mxy/design/adapter/ObjectAdapterTest.java
@@ -0,0 +1,36 @@
+package com.mxy.design.adapter;
+
+import com.mxy.design.adapter.object.adapater.Ps2Connector;
+import com.mxy.design.adapter.object.adapater.Ps2UsbAdapter;
+import com.mxy.design.adapter.object.adapater.PsConnectorImpl;
+import com.mxy.design.adapter.object.adapater.UsbConnectorImpl;
+import org.junit.Test;
+
+/**
+ * 适配器:这种模式涉及到一个单一的类,该类负责加入独立的或不兼容的接口功能
+ * 适配器分为两类:类适配器模式、对象的适配器模式,接口适配器
+ * 不同点:
+ * 1.类适配器:使用继承
+ * 2.对象适配器:使用组合(建议使用组合模式 降低耦合)
+ * 3.继承原有方法 子类需要重写需要的 并不需要全部都是实现
+ */
+public class ObjectAdapterTest {
+
+
+ /**
+ * 对象适配器
+ */
+ @Test
+ public void logicTest() {
+
+ System.out.println("======适配前=======");
+ Ps2Connector ps2Connector = new PsConnectorImpl();
+ ps2Connector.ps2Description();
+ System.out.println("======适配后======");
+ Ps2Connector adapter = new Ps2UsbAdapter(new UsbConnectorImpl());
+ adapter.ps2Description();
+ }
+
+
+
+}
diff --git a/src/test/com/mxy/design/decorator/DecoratorTest.java b/src/test/com/mxy/design/decorator/DecoratorTest.java
new file mode 100644
index 0000000..ceade0f
--- /dev/null
+++ b/src/test/com/mxy/design/decorator/DecoratorTest.java
@@ -0,0 +1,30 @@
+package com.mxy.design.decorator;
+
+import org.junit.Test;
+
+/**
+ * 装饰模式:增加功能,不改变接口
+ * 对比
+ * 适配器模式:改变接口名,不改变功能
+ * 对比
+ * 代理模式:代理类对被代理的对象有控制权,决定其执行或者不执行。
+ * 而装饰模式中,装饰类对代理对象没有控制权,只能为其增加一层装饰,以加强被装饰对象的功能。
+ */
+public class DecoratorTest {
+
+ @Test
+ public void logicTest() {
+ System.out.println("装饰前======");
+ Cake cake = new CakeImpl();
+ System.out.println(cake.description()+"花费:"+cake.cost());
+ System.out.println("装饰后======");
+ Cake addFruits = new Fruits(cake);
+ System.out.println("只增加"+addFruits.description()+"共花费:"+addFruits.cost());
+ Cake addCandle = new Candle(cake);
+ System.out.println("只增加"+addCandle.description()+"共花费:"+addCandle.cost());
+ //为期增加功能 向下转型
+ ((Candle) addCandle).risePrice(10);
+ System.out.println("涨价后"+addCandle.description()+"总共花费:"+addCandle.cost());
+ }
+
+}
diff --git a/src/test/com/mxy/design/observer/ObServerTest.java b/src/test/com/mxy/design/observer/ObServerTest.java
new file mode 100644
index 0000000..3e1ca39
--- /dev/null
+++ b/src/test/com/mxy/design/observer/ObServerTest.java
@@ -0,0 +1,28 @@
+package com.mxy.design.observer;
+
+import org.junit.Test;
+
+/**
+ * 观察者模式:在对象之间定义了一对多的依赖,这样一来,当一个对象改变状态,依赖它的对象会收到通知并自动更新。
+ * 其实就是发布订阅模式,发布者发布信息,订阅者获取信息,订阅了就能收到信息,没订阅就收不到信息。
+ */
+
+public class ObServerTest {
+
+ @Test
+ public void logicTest() {
+ WeChatOfficialAccount account = new WeChatOfficialAccountImpl();
+ //微信公众号关注的用户
+ account.followUser(new WeChatUser(1, "张三"));
+ account.followUser(new WeChatUser(3, "李四"));
+ account.followUser(new WeChatUser(2, "王五"));
+ //推送文章
+ account.notifyObServer("C#学习入门");
+ //王五不关注了 觉得该公众号很烂 ^_^
+ account.cancelFollowUser(new WeChatUser(2, "王五"));
+ //继续推送文章给其他两位
+ account.notifyObServer("spring学习入门");
+ }
+
+
+}
diff --git a/src/test/com/mxy/design/proxy/DynamicProxyTest.java b/src/test/com/mxy/design/proxy/DynamicProxyTest.java
new file mode 100644
index 0000000..5867323
--- /dev/null
+++ b/src/test/com/mxy/design/proxy/DynamicProxyTest.java
@@ -0,0 +1,68 @@
+package com.mxy.design.proxy;
+
+import com.mxy.design.proxy.dynamic.cglib.proxy.StudentCglibProxy;
+import com.mxy.design.proxy.dynamic.jdk.proxy.StudentJdkProxy;
+import org.junit.Test;
+
+import java.util.Random;
+
+/**
+ * 装饰模式:增加功能,不改变接口
+ * 对比
+ * 适配器模式:改变接口名,不改变功能
+ * 对比
+ * 代理模式:代理类对被代理的对象有控制权,决定其执行或者不执行。
+ * 而装饰模式中,装饰类对代理对象没有控制权,只能为其增加一层装饰,以加强被装饰对象的功能。
+ * 动态代理:原理通过反射来获得代理的实现 常用的有JDK 自带jdkProxy 与 cglib 之前hibernate使用 javassist
+ * 好处:当时用动态代理 一个动态代理模板就能代理多个目标类 只需要传入接口 通过反射得到实现目标类方法
+ */
+public class DynamicProxyTest {
+
+
+ @Test
+ public void cglibProxyTest() {
+ System.out.println("====使用代理模式前");
+ IStudent iStudent = new StudentImpl();
+ iStudent.save();
+ iStudent.delete();
+ System.out.println();
+ System.out.println("=====使用CGLIB代理模式后");
+ IStudent cglibProxy = new StudentCglibProxy().getInstance(IStudent.class);
+ save(cglibProxy);
+ delete(cglibProxy);
+ }
+
+ @Test
+ public void jdkProxyTest() {
+ System.out.println("====使用代理模式前");
+ IStudent iStudent = new StudentImpl();
+ iStudent.save();
+ iStudent.delete();
+ System.out.println();
+ System.out.println("=====使用JDK动态代理模式后");
+ IStudent jdkProxy = new StudentJdkProxy(iStudent).getInstance();
+
+ //与静态代理输出结果保持一致
+ save(jdkProxy);
+
+ //查询是否存在
+ delete(jdkProxy);
+ }
+
+ private void delete(IStudent jdkProxy) {
+ if (new Random().nextBoolean()) {
+ System.out.println("===开启事务");
+ jdkProxy.delete();
+ System.out.println("===提交事务");
+ } else {
+ System.out.println("===该用户已经被删除");
+ }
+ }
+
+ private void save(IStudent jdkProxy) {
+ System.out.println("==开启事务");
+ jdkProxy.save();
+ System.out.println("==提交事务");
+ }
+
+}
diff --git a/src/test/com/mxy/design/proxy/StaticProxyTest.java b/src/test/com/mxy/design/proxy/StaticProxyTest.java
new file mode 100644
index 0000000..2d4fd1a
--- /dev/null
+++ b/src/test/com/mxy/design/proxy/StaticProxyTest.java
@@ -0,0 +1,35 @@
+package com.mxy.design.proxy;
+
+import org.junit.Test;
+
+/**
+ * 装饰模式:增加功能,不改变接口
+ * 对比
+ * 适配器模式:改变接口名,不改变功能
+ * 对比
+ * 代理模式:代理类对被代理的对象有控制权,决定其执行或者不执行。
+ * 而装饰模式中,装饰类对代理对象没有控制权,只能为其增加一层装饰,以加强被装饰对象的功能。
+ *
+ * 缺点:
+ *
+ * 1)代理类和委托类实现了相同的接口,代理类通过委托类实现了相同的方法。这样就出现了大量的代码重复。如果接口增加一个方法,除了所有实现类需要实现这个方法外,所有代理类也需要实现此方法。增加了代码维护的复杂度。
+ *
+ * 2)代理对象只服务于一种类型的对象,如果要服务多类型的对象。势必要为每一种对象都进行代理,静态代理在程序规模稍大时就无法胜任了。如上的代码是只为UserManager类的访问提供了代理,但是如果还要为其他类如Department类提供代理的话,就需要我们再次添加代理Department的代理类。
+ */
+public class StaticProxyTest {
+
+
+ @Test
+ public void logicTest() {
+ System.out.println("====使用代理模式前");
+ IStudent iStudent = new StudentImpl();
+ iStudent.save();
+ iStudent.delete();
+ System.out.println();
+ System.out.println("=====使用代理模式后");
+ IStudent studentProxy = new StudentProxy(iStudent);
+ studentProxy.save();
+ studentProxy.delete();
+ }
+
+}
diff --git a/src/test/com/mxy/design/strategy/StrategyTest.java b/src/test/com/mxy/design/strategy/StrategyTest.java
new file mode 100644
index 0000000..87b77f5
--- /dev/null
+++ b/src/test/com/mxy/design/strategy/StrategyTest.java
@@ -0,0 +1,20 @@
+package com.mxy.design.strategy;
+
+import org.junit.Test;
+
+/**
+ * 策略模式:定义了一系列的算法,并将每一个算法封装起来,使每个算法可以相互替代,使算法本身和使用算法的客户端分割开来,相互独立。
+ * 开发中:解决相同条件的多层if...else..
+ */
+public class StrategyTest {
+
+
+ @Test
+ public void logicTest(){
+ System.out.println("======不同客户,不同的折扣!=======");
+ System.out.println("老顾客实际消费:"+new StrategyContext(new OldCustomerQuoteStrategy()).invoke(10));
+ System.out.println("vip顾客实际消费:"+new StrategyContext(new VipCustomerQuoteStrategy()).invoke(10));
+ System.out.println("新顾客实际消费:"+new StrategyContext(new NewCustomerQuoteStrategy()).invoke(10));
+ }
+
+}
diff --git a/src/test/com/mxy/design/template/TempLateTest.java b/src/test/com/mxy/design/template/TempLateTest.java
new file mode 100644
index 0000000..4570fcf
--- /dev/null
+++ b/src/test/com/mxy/design/template/TempLateTest.java
@@ -0,0 +1,29 @@
+package com.mxy.design.template;
+
+import org.junit.Test;
+
+/**
+ * 模板方法 一个模板方法是定义在抽象类中的,把基本操作方法组合在一起形成一个总算法或一个总行为的方法。
+ * 本人倾向于使用内部构造实现
+ * JDK 中的servlet 就是一个典型的模板方法
+ */
+public class TempLateTest {
+ @Test
+ public void logicTest() {
+
+
+ new ProcessTempLate() {
+
+ @Override
+ protected void checkParam(String... arg) {
+ System.out.println(arg.length);
+ }
+
+ @Override
+ protected void mainLogic() {
+ System.out.println("处理主逻辑");
+ }
+ }.invoke("参数1","参数2");
+
+ }
+}
diff --git a/target/classes/com/mxy/design/adapter/classes/adapter/Ps2Connector.class b/target/classes/com/mxy/design/adapter/classes/adapter/Ps2Connector.class
new file mode 100644
index 0000000..96a286e
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/classes/adapter/Ps2Connector.class differ
diff --git a/target/classes/com/mxy/design/adapter/classes/adapter/Ps2UsbAdapter.class b/target/classes/com/mxy/design/adapter/classes/adapter/Ps2UsbAdapter.class
new file mode 100644
index 0000000..ce7cdad
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/classes/adapter/Ps2UsbAdapter.class differ
diff --git a/target/classes/com/mxy/design/adapter/classes/adapter/PsConnectorImpl.class b/target/classes/com/mxy/design/adapter/classes/adapter/PsConnectorImpl.class
new file mode 100644
index 0000000..829be4e
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/classes/adapter/PsConnectorImpl.class differ
diff --git a/target/classes/com/mxy/design/adapter/classes/adapter/UsbConnector.class b/target/classes/com/mxy/design/adapter/classes/adapter/UsbConnector.class
new file mode 100644
index 0000000..3f722b0
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/classes/adapter/UsbConnector.class differ
diff --git a/target/classes/com/mxy/design/adapter/classes/adapter/UsbConnectorImpl.class b/target/classes/com/mxy/design/adapter/classes/adapter/UsbConnectorImpl.class
new file mode 100644
index 0000000..5bdc2e4
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/classes/adapter/UsbConnectorImpl.class differ
diff --git a/target/classes/com/mxy/design/adapter/interfaces/adapter/Adapter.class b/target/classes/com/mxy/design/adapter/interfaces/adapter/Adapter.class
new file mode 100644
index 0000000..3470eec
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/interfaces/adapter/Adapter.class differ
diff --git a/target/classes/com/mxy/design/adapter/interfaces/adapter/Chat.class b/target/classes/com/mxy/design/adapter/interfaces/adapter/Chat.class
new file mode 100644
index 0000000..b517d9b
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/interfaces/adapter/Chat.class differ
diff --git a/target/classes/com/mxy/design/adapter/interfaces/adapter/Linux.class b/target/classes/com/mxy/design/adapter/interfaces/adapter/Linux.class
new file mode 100644
index 0000000..ec83a30
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/interfaces/adapter/Linux.class differ
diff --git a/target/classes/com/mxy/design/adapter/interfaces/adapter/Port.class b/target/classes/com/mxy/design/adapter/interfaces/adapter/Port.class
new file mode 100644
index 0000000..47a9c35
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/interfaces/adapter/Port.class differ
diff --git a/target/classes/com/mxy/design/adapter/interfaces/adapter/Tomcat.class b/target/classes/com/mxy/design/adapter/interfaces/adapter/Tomcat.class
new file mode 100644
index 0000000..afb48dc
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/interfaces/adapter/Tomcat.class differ
diff --git a/target/classes/com/mxy/design/adapter/object/adapater/Ps2Connector.class b/target/classes/com/mxy/design/adapter/object/adapater/Ps2Connector.class
new file mode 100644
index 0000000..2391546
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/object/adapater/Ps2Connector.class differ
diff --git a/target/classes/com/mxy/design/adapter/object/adapater/Ps2UsbAdapter.class b/target/classes/com/mxy/design/adapter/object/adapater/Ps2UsbAdapter.class
new file mode 100644
index 0000000..de7e098
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/object/adapater/Ps2UsbAdapter.class differ
diff --git a/target/classes/com/mxy/design/adapter/object/adapater/PsConnectorImpl.class b/target/classes/com/mxy/design/adapter/object/adapater/PsConnectorImpl.class
new file mode 100644
index 0000000..7d7572c
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/object/adapater/PsConnectorImpl.class differ
diff --git a/target/classes/com/mxy/design/adapter/object/adapater/UsbConnector.class b/target/classes/com/mxy/design/adapter/object/adapater/UsbConnector.class
new file mode 100644
index 0000000..b863e71
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/object/adapater/UsbConnector.class differ
diff --git a/target/classes/com/mxy/design/adapter/object/adapater/UsbConnectorImpl.class b/target/classes/com/mxy/design/adapter/object/adapater/UsbConnectorImpl.class
new file mode 100644
index 0000000..aa21154
Binary files /dev/null and b/target/classes/com/mxy/design/adapter/object/adapater/UsbConnectorImpl.class differ
diff --git a/target/classes/com/mxy/design/decorator/Cake.class b/target/classes/com/mxy/design/decorator/Cake.class
new file mode 100644
index 0000000..6e52a13
Binary files /dev/null and b/target/classes/com/mxy/design/decorator/Cake.class differ
diff --git a/target/classes/com/mxy/design/decorator/CakeDecorator.class b/target/classes/com/mxy/design/decorator/CakeDecorator.class
new file mode 100644
index 0000000..9914fb2
Binary files /dev/null and b/target/classes/com/mxy/design/decorator/CakeDecorator.class differ
diff --git a/target/classes/com/mxy/design/decorator/CakeImpl.class b/target/classes/com/mxy/design/decorator/CakeImpl.class
new file mode 100644
index 0000000..7a3f68a
Binary files /dev/null and b/target/classes/com/mxy/design/decorator/CakeImpl.class differ
diff --git a/target/classes/com/mxy/design/decorator/Candle.class b/target/classes/com/mxy/design/decorator/Candle.class
new file mode 100644
index 0000000..e8aac26
Binary files /dev/null and b/target/classes/com/mxy/design/decorator/Candle.class differ
diff --git a/target/classes/com/mxy/design/decorator/Fruits.class b/target/classes/com/mxy/design/decorator/Fruits.class
new file mode 100644
index 0000000..6fa92f2
Binary files /dev/null and b/target/classes/com/mxy/design/decorator/Fruits.class differ
diff --git a/target/classes/com/mxy/design/observer/MAIN.class b/target/classes/com/mxy/design/observer/MAIN.class
deleted file mode 100644
index d5e7d43..0000000
Binary files a/target/classes/com/mxy/design/observer/MAIN.class and /dev/null differ
diff --git a/target/classes/com/mxy/design/observer/WeChatOfficialAccount.class b/target/classes/com/mxy/design/observer/WeChatOfficialAccount.class
new file mode 100644
index 0000000..993f530
Binary files /dev/null and b/target/classes/com/mxy/design/observer/WeChatOfficialAccount.class differ
diff --git a/target/classes/com/mxy/design/observer/WeChatSubjectImpl.class b/target/classes/com/mxy/design/observer/WeChatOfficialAccountImpl.class
similarity index 66%
rename from target/classes/com/mxy/design/observer/WeChatSubjectImpl.class
rename to target/classes/com/mxy/design/observer/WeChatOfficialAccountImpl.class
index 23e6458..cd05009 100644
Binary files a/target/classes/com/mxy/design/observer/WeChatSubjectImpl.class and b/target/classes/com/mxy/design/observer/WeChatOfficialAccountImpl.class differ
diff --git a/target/classes/com/mxy/design/observer/WeChatSubject.class b/target/classes/com/mxy/design/observer/WeChatSubject.class
deleted file mode 100644
index 89d2908..0000000
Binary files a/target/classes/com/mxy/design/observer/WeChatSubject.class and /dev/null differ
diff --git a/target/classes/com/mxy/design/proxy/IStudent.class b/target/classes/com/mxy/design/proxy/IStudent.class
new file mode 100644
index 0000000..7614bb4
Binary files /dev/null and b/target/classes/com/mxy/design/proxy/IStudent.class differ
diff --git a/target/classes/com/mxy/design/proxy/StudentImpl.class b/target/classes/com/mxy/design/proxy/StudentImpl.class
new file mode 100644
index 0000000..90fb58b
Binary files /dev/null and b/target/classes/com/mxy/design/proxy/StudentImpl.class differ
diff --git a/target/classes/com/mxy/design/proxy/StudentProxy.class b/target/classes/com/mxy/design/proxy/StudentProxy.class
new file mode 100644
index 0000000..da0e2f2
Binary files /dev/null and b/target/classes/com/mxy/design/proxy/StudentProxy.class differ
diff --git a/target/classes/com/mxy/design/proxy/dynamic/cglib/proxy/IStudent.class b/target/classes/com/mxy/design/proxy/dynamic/cglib/proxy/IStudent.class
new file mode 100644
index 0000000..81891d3
Binary files /dev/null and b/target/classes/com/mxy/design/proxy/dynamic/cglib/proxy/IStudent.class differ
diff --git a/target/classes/com/mxy/design/proxy/dynamic/cglib/proxy/StudentCglibProxy.class b/target/classes/com/mxy/design/proxy/dynamic/cglib/proxy/StudentCglibProxy.class
new file mode 100644
index 0000000..2192f5c
Binary files /dev/null and b/target/classes/com/mxy/design/proxy/dynamic/cglib/proxy/StudentCglibProxy.class differ
diff --git a/target/classes/com/mxy/design/proxy/dynamic/cglib/proxy/StudentImpl.class b/target/classes/com/mxy/design/proxy/dynamic/cglib/proxy/StudentImpl.class
new file mode 100644
index 0000000..84d41bc
Binary files /dev/null and b/target/classes/com/mxy/design/proxy/dynamic/cglib/proxy/StudentImpl.class differ
diff --git a/target/classes/com/mxy/design/proxy/dynamic/jdk/proxy/IStudent.class b/target/classes/com/mxy/design/proxy/dynamic/jdk/proxy/IStudent.class
new file mode 100644
index 0000000..74a1d48
Binary files /dev/null and b/target/classes/com/mxy/design/proxy/dynamic/jdk/proxy/IStudent.class differ
diff --git a/target/classes/com/mxy/design/proxy/dynamic/jdk/proxy/StudentImpl.class b/target/classes/com/mxy/design/proxy/dynamic/jdk/proxy/StudentImpl.class
new file mode 100644
index 0000000..680ea84
Binary files /dev/null and b/target/classes/com/mxy/design/proxy/dynamic/jdk/proxy/StudentImpl.class differ
diff --git a/target/classes/com/mxy/design/proxy/dynamic/jdk/proxy/StudentJdkProxy.class b/target/classes/com/mxy/design/proxy/dynamic/jdk/proxy/StudentJdkProxy.class
new file mode 100644
index 0000000..fcbcc6b
Binary files /dev/null and b/target/classes/com/mxy/design/proxy/dynamic/jdk/proxy/StudentJdkProxy.class differ
diff --git a/target/classes/com/mxy/design/strategy/DiscountStrategy.class b/target/classes/com/mxy/design/strategy/DiscountStrategy.class
new file mode 100644
index 0000000..80026b9
Binary files /dev/null and b/target/classes/com/mxy/design/strategy/DiscountStrategy.class differ
diff --git a/target/classes/com/mxy/design/strategy/NewCustomerQuoteStrategy.class b/target/classes/com/mxy/design/strategy/NewCustomerQuoteStrategy.class
new file mode 100644
index 0000000..36484a1
Binary files /dev/null and b/target/classes/com/mxy/design/strategy/NewCustomerQuoteStrategy.class differ
diff --git a/target/classes/com/mxy/design/strategy/OldCustomerQuoteStrategy.class b/target/classes/com/mxy/design/strategy/OldCustomerQuoteStrategy.class
new file mode 100644
index 0000000..6591b8f
Binary files /dev/null and b/target/classes/com/mxy/design/strategy/OldCustomerQuoteStrategy.class differ
diff --git a/target/classes/com/mxy/design/strategy/StrategyContext.class b/target/classes/com/mxy/design/strategy/StrategyContext.class
new file mode 100644
index 0000000..b92da85
Binary files /dev/null and b/target/classes/com/mxy/design/strategy/StrategyContext.class differ
diff --git a/target/classes/com/mxy/design/strategy/VipCustomerQuoteStrategy.class b/target/classes/com/mxy/design/strategy/VipCustomerQuoteStrategy.class
new file mode 100644
index 0000000..4b21155
Binary files /dev/null and b/target/classes/com/mxy/design/strategy/VipCustomerQuoteStrategy.class differ
diff --git a/target/classes/com/mxy/design/template/ProcessTempLate.class b/target/classes/com/mxy/design/template/ProcessTempLate.class
new file mode 100644
index 0000000..1635d2b
Binary files /dev/null and b/target/classes/com/mxy/design/template/ProcessTempLate.class differ
diff --git a/target/test-classes/com/mxy/design/adapter/ClassesAdapterTest.class b/target/test-classes/com/mxy/design/adapter/ClassesAdapterTest.class
new file mode 100644
index 0000000..e098ed3
Binary files /dev/null and b/target/test-classes/com/mxy/design/adapter/ClassesAdapterTest.class differ
diff --git a/target/test-classes/com/mxy/design/adapter/InterfaceAdapterTest.class b/target/test-classes/com/mxy/design/adapter/InterfaceAdapterTest.class
new file mode 100644
index 0000000..6ec7407
Binary files /dev/null and b/target/test-classes/com/mxy/design/adapter/InterfaceAdapterTest.class differ
diff --git a/target/test-classes/com/mxy/design/adapter/ObjectAdapterTest.class b/target/test-classes/com/mxy/design/adapter/ObjectAdapterTest.class
new file mode 100644
index 0000000..9fe72a7
Binary files /dev/null and b/target/test-classes/com/mxy/design/adapter/ObjectAdapterTest.class differ
diff --git a/target/test-classes/com/mxy/design/decorator/DecoratorTest.class b/target/test-classes/com/mxy/design/decorator/DecoratorTest.class
new file mode 100644
index 0000000..977236a
Binary files /dev/null and b/target/test-classes/com/mxy/design/decorator/DecoratorTest.class differ
diff --git a/target/test-classes/com/mxy/design/observer/ObServerTest.class b/target/test-classes/com/mxy/design/observer/ObServerTest.class
new file mode 100644
index 0000000..70533a6
Binary files /dev/null and b/target/test-classes/com/mxy/design/observer/ObServerTest.class differ
diff --git a/target/test-classes/com/mxy/design/proxy/DynamicProxyTest.class b/target/test-classes/com/mxy/design/proxy/DynamicProxyTest.class
new file mode 100644
index 0000000..08a57b8
Binary files /dev/null and b/target/test-classes/com/mxy/design/proxy/DynamicProxyTest.class differ
diff --git a/target/test-classes/com/mxy/design/proxy/StaticProxyTest.class b/target/test-classes/com/mxy/design/proxy/StaticProxyTest.class
new file mode 100644
index 0000000..26bad31
Binary files /dev/null and b/target/test-classes/com/mxy/design/proxy/StaticProxyTest.class differ
diff --git a/target/test-classes/com/mxy/design/strategy/StrategyTest.class b/target/test-classes/com/mxy/design/strategy/StrategyTest.class
new file mode 100644
index 0000000..6852463
Binary files /dev/null and b/target/test-classes/com/mxy/design/strategy/StrategyTest.class differ
diff --git a/target/test-classes/com/mxy/design/template/TempLateTest$1.class b/target/test-classes/com/mxy/design/template/TempLateTest$1.class
new file mode 100644
index 0000000..e826b15
Binary files /dev/null and b/target/test-classes/com/mxy/design/template/TempLateTest$1.class differ
diff --git a/target/test-classes/com/mxy/design/template/TempLateTest.class b/target/test-classes/com/mxy/design/template/TempLateTest.class
new file mode 100644
index 0000000..4ef7e89
Binary files /dev/null and b/target/test-classes/com/mxy/design/template/TempLateTest.class differ