diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 0d84d72ec0b45dbac67207f912bc27821b82c3f8..8494d15196e51c49e741dcae803373242bdf4d4a 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,8 +2,10 @@ - + + + + + + + @@ -156,7 +162,8 @@ - + + 1634096220780 diff --git a/out/production/patterns/com/pattern/PatternApplication.class b/out/production/patterns/com/pattern/PatternApplication.class index 77a84322e28da84717ce23253864e394bfebd30c..c5aebe48760ac73c736a1f294b2fc0e1f9108e8c 100644 Binary files a/out/production/patterns/com/pattern/PatternApplication.class and b/out/production/patterns/com/pattern/PatternApplication.class differ diff --git a/out/production/patterns/com/pattern/ProxyPattern/ProxyMain.class b/out/production/patterns/com/pattern/ProxyPattern/ProxyMain.class index 4649b0ebd1b9bd3d087a649f860f90a8c8ea4cda..fb205bb327f4170622a07fb76b44dace7d7e31c3 100644 Binary files a/out/production/patterns/com/pattern/ProxyPattern/ProxyMain.class and b/out/production/patterns/com/pattern/ProxyPattern/ProxyMain.class differ diff --git a/out/production/patterns/com/pattern/ProxyPattern/materials/README.md b/out/production/patterns/com/pattern/ProxyPattern/materials/README.md index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6ba9cd96276fa43cdc7baf6131da5893cc95dc1b 100644 --- a/out/production/patterns/com/pattern/ProxyPattern/materials/README.md +++ b/out/production/patterns/com/pattern/ProxyPattern/materials/README.md @@ -0,0 +1,2 @@ +主:官方卖票的地方 +代理:将官方买票的构造传进来,然后加上自己的服务然后调用官方的去实现这个功能 diff --git a/out/production/patterns/com/pattern/ProxyPattern/materials/po/YellowBullHandler.class b/out/production/patterns/com/pattern/ProxyPattern/materials/po/YellowBullHandler.class index e16669dfca49b846172b1ef6771cde3fa440a06b..343246d97fae30c830147f7fa6872474e1b46e43 100644 Binary files a/out/production/patterns/com/pattern/ProxyPattern/materials/po/YellowBullHandler.class and b/out/production/patterns/com/pattern/ProxyPattern/materials/po/YellowBullHandler.class differ diff --git a/src/com/pattern/PatternApplication.java b/src/com/pattern/PatternApplication.java index 6d22d6cde9dc0f87a8b663e28db56bc459bc5a78..93af7e413dacab895604198cb26e6e914f69b33a 100644 --- a/src/com/pattern/PatternApplication.java +++ b/src/com/pattern/PatternApplication.java @@ -1,7 +1,5 @@ package com.pattern; -import com.pattern.ProxyPattern.ProxyMain; - /** * @author lx */ @@ -13,6 +11,7 @@ public class PatternApplication { 解释器模式 new InterpreterMain().main(); 2021-10-14:制作多个计算规则,用这些规则去拼装组合来实现某些需求 + 2021-11-24:一个接口很多实例的类,其中一个类是终端计算规则,剩下的类传入一个或多个终端计算,并把每一个终端计算结果再进行计算,成为一个单独的计算规则 */ @@ -21,7 +20,7 @@ public class PatternApplication { 策略模式 new StrategyMain().main(); 2021-10-14:通过构造context传入不同的规则,再给context执行方法传入不同的值进行不同的计算 - + 2021-11-24:context作为触发器,传进来不同的策略,然后执行策略里面的方法 */ @@ -38,7 +37,7 @@ public class PatternApplication { /* 工厂模式 -- 方法工厂 new FunctionFactoryMain().main(); - 2021-10-14: + 2021-10-14: 一个工厂只能造一种产品,也就是一个方法工厂返回一个对象,想要多个对象就要多个工厂 */ @@ -47,7 +46,7 @@ public class PatternApplication { /* 工厂模式 -- 抽象工厂 new AbstractFactoryMain().main(); - 2021-10-14: + 2021-10-14: 把工厂抽象,实例化一个工厂定义多个对象的产出,然后实例化这个工厂就可以拿到多个产品 */ @@ -70,9 +69,10 @@ public class PatternApplication { */ - new ProxyMain().reflectMain(); /* - 代理模式 + 代理模式 ---动态代理 + new ProxyMain().reflectMain(); + 代理模式 ---静态代理 new ProxyMain().staticMain(); 2021-10-14: diff --git a/src/com/pattern/ProxyPattern/ProxyMain.java b/src/com/pattern/ProxyPattern/ProxyMain.java index 67f77c2518fff0797d2abc814ea49cde7b00b7ca..4b29bf6d3915aee19396b949b2524e6ceea8c1a8 100644 --- a/src/com/pattern/ProxyPattern/ProxyMain.java +++ b/src/com/pattern/ProxyPattern/ProxyMain.java @@ -36,5 +36,6 @@ public class ProxyMain { YellowBullHandler handler = new YellowBullHandler(); TicketService subject = (TicketService) handler.newProxyInstance(beijingStation); subject.consultation("你们卖票的么?"); + subject.sellT(); } } diff --git a/src/com/pattern/ProxyPattern/materials/README.md b/src/com/pattern/ProxyPattern/materials/README.md index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6ba9cd96276fa43cdc7baf6131da5893cc95dc1b 100644 --- a/src/com/pattern/ProxyPattern/materials/README.md +++ b/src/com/pattern/ProxyPattern/materials/README.md @@ -0,0 +1,2 @@ +主:官方卖票的地方 +代理:将官方买票的构造传进来,然后加上自己的服务然后调用官方的去实现这个功能 diff --git a/src/com/pattern/ProxyPattern/materials/po/YellowBullHandler.java b/src/com/pattern/ProxyPattern/materials/po/YellowBullHandler.java index 865da0a50bbd26801dc38fa6917c0fded00b5781..2d1d637c0e3a6134f7cab01caa91efbd97ef4844 100644 --- a/src/com/pattern/ProxyPattern/materials/po/YellowBullHandler.java +++ b/src/com/pattern/ProxyPattern/materials/po/YellowBullHandler.java @@ -56,11 +56,13 @@ public class YellowBullHandler implements InvocationHandler { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - System.out.println("高级黄牛为你服务..."); + System.out.println("...高级黄牛为你服务..."); Object ret; try { - for (int i = 0; i < args.length; i++) { - System.out.println("参数" + (i + 1) +":"+ args[i]); + if (args != null) { + for (int i = 0; i < args.length; i++) { + System.out.println("参数" + (i + 1) + ":" + args[i]); + } } //调用目标方法 ret = method.invoke(target, args); @@ -68,7 +70,7 @@ public class YellowBullHandler implements InvocationHandler { System.err.println(target.getClass().getName() + method.getName() + e); throw e; } - System.out.println("高级黄牛服务结束..."); + System.out.println("...高级黄牛服务结束..."); return ret; } }