diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..854cfdb
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..b26911b
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..6560a98
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..a940d24
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..e96534f
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..d217914
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..ab9e0f0
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,598 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ List<WeChatUser> userList
+
+
+ WeChatUser weChatUser
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1550332102563
+
+
+ 1550332102563
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/src/main/com/mxy/design/observer/WeChatSubjectImpl.java
+ 30
+
+
+
+
+ file://$PROJECT_DIR$/src/main/com/mxy/design/observer/MAIN.java
+ 9
+
+
+
+
+ jar://E:/Java/Java1.8/src.zip!/java/io/PrintStream.java
+ 804
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DesignPatterns:war
+
+
+
+
+
+
+
+
+
+
+
+
+ Web
+
+
+
+
+
+
+
+
+
+
+
+ Python 3.7 interpreter library
+
+
+
+
+
+
+
+
+
+
+
+ 1.7
+
+
+
+
+
+
+
+
+
+
+
+ DesignPatterns
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.7
+
+
+
+
+
+
+
+
+
+
+
+ Maven: junit:junit:4.11
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..31f7351
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,122 @@
+
+
+
+ 4.0.0
+
+ com.maxy
+ DesignPatterns
+ 1.0-SNAPSHOT
+ war
+
+ DesignPatterns Maven Webapp
+ http://www.example.com
+
+
+
+ UTF-8
+ 1.8
+ 1.8
+ 1.7.21
+ 18.0
+
+
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.7
+
+
+ org.slf4j
+ log4j-over-slf4j
+ ${log4j-over-slf4j.version}
+
+
+ org.apache.commons
+ commons-lang3
+ 3.4
+
+
+ com.google.guava
+ guava
+ ${guava.version}
+
+
+ com.alibaba
+ fastjson
+ 1.2.51
+
+
+
+ org.springframework
+ spring-aop
+ 4.3.22.RELEASE
+
+
+
+ org.springframework
+ spring-core
+ 4.3.22.RELEASE
+
+
+
+ org.aspectj
+ aspectjrt
+ 1.8.13
+
+
+
+ org.springframework
+ spring-context
+ 4.3.22.RELEASE
+
+
+
+ javax.validation
+ validation-api
+ 1.1.0.Final
+
+
+
+
+
+
+ DesignPatterns
+
+
+
+ maven-clean-plugin
+ 3.1.0
+
+
+
+ maven-resources-plugin
+ 3.0.2
+
+
+ maven-compiler-plugin
+ 3.8.0
+
+
+ maven-war-plugin
+ 3.2.2
+
+
+ maven-install-plugin
+ 2.5.2
+
+
+ maven-deploy-plugin
+ 2.8.2
+
+
+
+
+
diff --git a/src/main/com/mxy/design/observer/MAIN.java b/src/main/com/mxy/design/observer/MAIN.java
new file mode 100644
index 0000000..bede442
--- /dev/null
+++ b/src/main/com/mxy/design/observer/MAIN.java
@@ -0,0 +1,27 @@
+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/ObServer.java b/src/main/com/mxy/design/observer/ObServer.java
new file mode 100644
index 0000000..31dd050
--- /dev/null
+++ b/src/main/com/mxy/design/observer/ObServer.java
@@ -0,0 +1,9 @@
+package com.mxy.design.observer;
+
+public interface ObServer {
+ /**
+ * 接受公众号推送的信息
+ * @param receiveMsg
+ */
+ void update(String receiveMsg);
+}
diff --git a/src/main/com/mxy/design/observer/WeChatSubject.java b/src/main/com/mxy/design/observer/WeChatSubject.java
new file mode 100644
index 0000000..4f35023
--- /dev/null
+++ b/src/main/com/mxy/design/observer/WeChatSubject.java
@@ -0,0 +1,24 @@
+package com.mxy.design.observer;
+
+public interface WeChatSubject {
+
+ /**
+ * 该公众号关注的用户
+ * @return
+ */
+ boolean followUser(WeChatUser weChatUser);
+ /**
+ * 用户取消关注该公众号
+ * @return
+ */
+ boolean cancelFollowUser(WeChatUser weChatUser);
+
+ /**
+ * 公众号有新消息
+ * 通知观察者
+ * @return
+ */
+ boolean notifyObServer(String sendMsg);
+
+
+}
diff --git a/src/main/com/mxy/design/observer/WeChatSubjectImpl.java b/src/main/com/mxy/design/observer/WeChatSubjectImpl.java
new file mode 100644
index 0000000..536aac2
--- /dev/null
+++ b/src/main/com/mxy/design/observer/WeChatSubjectImpl.java
@@ -0,0 +1,47 @@
+package com.mxy.design.observer;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class WeChatSubjectImpl implements WeChatSubject {
+
+ private List users = new ArrayList<>();
+
+ public List getUsers() {
+ return users;
+ }
+
+ public void setUsers(List users) {
+ this.users = users;
+ }
+
+ @Override
+ public boolean followUser(WeChatUser weChatUser) {
+ System.out.println(weChatUser.getUserName() + "-->关注了该公众号.");
+ return users.add(weChatUser);
+ }
+
+ @Override
+ public boolean cancelFollowUser(WeChatUser weChatUser) {
+ System.out.println(weChatUser.getUserName() + "-->取消了关注.");
+ users.remove(weChatUser);
+ return true;
+ }
+
+ @Override
+ public boolean notifyObServer(String sendMsg) {
+ articleInfo(sendMsg);
+ return true;
+ }
+
+ private void articleInfo(String articleInfo) {
+ Preconditions.checkArgument(StringUtils.isNotBlank(articleInfo));
+ users.stream().forEach(u -> {
+ u.update(u.getUserName() + "-已收到文章-" + articleInfo + ".");
+ });
+ }
+}
diff --git a/src/main/com/mxy/design/observer/WeChatUser.java b/src/main/com/mxy/design/observer/WeChatUser.java
new file mode 100644
index 0000000..d7bc4e5
--- /dev/null
+++ b/src/main/com/mxy/design/observer/WeChatUser.java
@@ -0,0 +1,54 @@
+package com.mxy.design.observer;
+
+
+import com.google.common.base.Objects;
+
+/**
+ * 微信用户 实现观察接口 随时接受更新的信息
+ */
+public class WeChatUser implements ObServer {
+
+ private int id;
+ private String userName;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public WeChatUser(int id, String userName) {
+ this.id = id;
+ this.userName = userName;
+ }
+
+
+ @Override
+ public void update(String receiveMsg) {
+ System.out.println(receiveMsg);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ WeChatUser user = (WeChatUser) o;
+ return id == user.id &&
+ Objects.equal(userName, user.userName);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, userName);
+ }
+}
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..9f88c1f
--- /dev/null
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,7 @@
+
+
+
+ Archetype Created Web Application
+
diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp
new file mode 100644
index 0000000..c38169b
--- /dev/null
+++ b/src/main/webapp/index.jsp
@@ -0,0 +1,5 @@
+
+
+Hello World!
+
+
diff --git a/target/classes/com/mxy/design/observer/MAIN.class b/target/classes/com/mxy/design/observer/MAIN.class
new file mode 100644
index 0000000..d5e7d43
Binary files /dev/null and b/target/classes/com/mxy/design/observer/MAIN.class differ
diff --git a/target/classes/com/mxy/design/observer/ObServer.class b/target/classes/com/mxy/design/observer/ObServer.class
new file mode 100644
index 0000000..47ffe4a
Binary files /dev/null and b/target/classes/com/mxy/design/observer/ObServer.class differ
diff --git a/target/classes/com/mxy/design/observer/WeChatSubject.class b/target/classes/com/mxy/design/observer/WeChatSubject.class
new file mode 100644
index 0000000..89d2908
Binary files /dev/null and b/target/classes/com/mxy/design/observer/WeChatSubject.class differ
diff --git a/target/classes/com/mxy/design/observer/WeChatSubjectImpl.class b/target/classes/com/mxy/design/observer/WeChatSubjectImpl.class
new file mode 100644
index 0000000..23e6458
Binary files /dev/null and b/target/classes/com/mxy/design/observer/WeChatSubjectImpl.class differ
diff --git a/target/classes/com/mxy/design/observer/WeChatUser.class b/target/classes/com/mxy/design/observer/WeChatUser.class
new file mode 100644
index 0000000..631673a
Binary files /dev/null and b/target/classes/com/mxy/design/observer/WeChatUser.class differ
diff --git a/target/classes/webapp/WEB-INF/web.xml b/target/classes/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..9f88c1f
--- /dev/null
+++ b/target/classes/webapp/WEB-INF/web.xml
@@ -0,0 +1,7 @@
+
+
+
+ Archetype Created Web Application
+
diff --git a/target/classes/webapp/index.jsp b/target/classes/webapp/index.jsp
new file mode 100644
index 0000000..c38169b
--- /dev/null
+++ b/target/classes/webapp/index.jsp
@@ -0,0 +1,5 @@
+
+
+Hello World!
+
+