Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lsh
patterns
提交
46d3e4c3
P
patterns
项目概览
lsh
/
patterns
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
patterns
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
46d3e4c3
编写于
11月 24, 2021
作者:
C
chenjianqiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
11-24复习
上级
7cb10c8d
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
27 addition
and
13 deletion
+27
-13
.idea/workspace.xml
.idea/workspace.xml
+9
-2
out/production/patterns/com/pattern/PatternApplication.class
out/production/patterns/com/pattern/PatternApplication.class
+0
-0
out/production/patterns/com/pattern/ProxyPattern/ProxyMain.class
...duction/patterns/com/pattern/ProxyPattern/ProxyMain.class
+0
-0
out/production/patterns/com/pattern/ProxyPattern/materials/README.md
...ion/patterns/com/pattern/ProxyPattern/materials/README.md
+2
-0
out/production/patterns/com/pattern/ProxyPattern/materials/po/YellowBullHandler.class
...pattern/ProxyPattern/materials/po/YellowBullHandler.class
+0
-0
src/com/pattern/PatternApplication.java
src/com/pattern/PatternApplication.java
+7
-7
src/com/pattern/ProxyPattern/ProxyMain.java
src/com/pattern/ProxyPattern/ProxyMain.java
+1
-0
src/com/pattern/ProxyPattern/materials/README.md
src/com/pattern/ProxyPattern/materials/README.md
+2
-0
src/com/pattern/ProxyPattern/materials/po/YellowBullHandler.java
.../pattern/ProxyPattern/materials/po/YellowBullHandler.java
+6
-4
未找到文件。
.idea/workspace.xml
浏览文件 @
46d3e4c3
...
@@ -2,8 +2,10 @@
...
@@ -2,8 +2,10 @@
<project
version=
"4"
>
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"e43e9168-5945-4f45-b4c2-1b6410d1eef8"
name=
"Changes"
comment=
"增加策略模式案例 Signed-off-by: chenjianqiang <wushanxi@gmail.com>"
>
<list
default=
"true"
id=
"e43e9168-5945-4f45-b4c2-1b6410d1eef8"
name=
"Changes"
comment=
"增加策略模式案例 Signed-off-by: chenjianqiang <wushanxi@gmail.com>"
>
<change
beforePath=
"$PROJECT_DIR$/src/com/pattern/InterpreterPattern/package-info.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/com/pattern/InterpreterPattern/package-info.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/com/pattern/PatternApplication.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/com/pattern/PatternApplication.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/com/pattern/PatternApplication.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/com/pattern/PatternApplication.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/com/pattern/ProxyPattern/ProxyMain.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/com/pattern/ProxyPattern/ProxyMain.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/com/pattern/ProxyPattern/materials/README.md"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/com/pattern/ProxyPattern/materials/README.md"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/com/pattern/ProxyPattern/materials/po/YellowBullHandler.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/com/pattern/ProxyPattern/materials/po/YellowBullHandler.java"
afterDir=
"false"
/>
</list>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
...
@@ -90,7 +92,11 @@
...
@@ -90,7 +92,11 @@
<option
name=
"showLibraryContents"
value=
"true"
/>
<option
name=
"showLibraryContents"
value=
"true"
/>
</component>
</component>
<component
name=
"PropertiesComponent"
>
<component
name=
"PropertiesComponent"
>
<property
name=
"RunOnceActivity.OpenProjectViewOnStart"
value=
"true"
/>
<property
name=
"RunOnceActivity.ShowReadmeOnStart"
value=
"true"
/>
<property
name=
"WebServerToolWindowFactoryState"
value=
"false"
/>
<property
name=
"WebServerToolWindowFactoryState"
value=
"false"
/>
<property
name=
"go.formatter.settings.were.checked"
value=
"true"
/>
<property
name=
"go.import.settings.migrated"
value=
"true"
/>
<property
name=
"last_opened_file_path"
value=
"$PROJECT_DIR$/src/com/pattern"
/>
<property
name=
"last_opened_file_path"
value=
"$PROJECT_DIR$/src/com/pattern"
/>
<property
name=
"settings.editor.selected.configurable"
value=
"editor.preferences.import"
/>
<property
name=
"settings.editor.selected.configurable"
value=
"editor.preferences.import"
/>
<property
name=
"typescript.add.unambiguous.imports.on.the.fly"
value=
"true"
/>
<property
name=
"typescript.add.unambiguous.imports.on.the.fly"
value=
"true"
/>
...
@@ -156,7 +162,8 @@
...
@@ -156,7 +162,8 @@
<workItem
from=
"1634115899707"
duration=
"377000"
/>
<workItem
from=
"1634115899707"
duration=
"377000"
/>
<workItem
from=
"1634180031509"
duration=
"3704000"
/>
<workItem
from=
"1634180031509"
duration=
"3704000"
/>
<workItem
from=
"1636338443252"
duration=
"4865000"
/>
<workItem
from=
"1636338443252"
duration=
"4865000"
/>
<workItem
from=
"1636350581794"
duration=
"2451000"
/>
<workItem
from=
"1636350581794"
duration=
"2679000"
/>
<workItem
from=
"1637721077456"
duration=
"1739000"
/>
</task>
</task>
<task
id=
"LOCAL-00001"
summary=
"增加策略模式案例 Signed-off-by: chenjianqiang <wushanxi@gmail.com>"
>
<task
id=
"LOCAL-00001"
summary=
"增加策略模式案例 Signed-off-by: chenjianqiang <wushanxi@gmail.com>"
>
<created>
1634096220780
</created>
<created>
1634096220780
</created>
...
...
out/production/patterns/com/pattern/PatternApplication.class
浏览文件 @
46d3e4c3
无法预览此类型文件
out/production/patterns/com/pattern/ProxyPattern/ProxyMain.class
浏览文件 @
46d3e4c3
无法预览此类型文件
out/production/patterns/com/pattern/ProxyPattern/materials/README.md
浏览文件 @
46d3e4c3
主:官方卖票的地方
代理:将官方买票的构造传进来,然后加上自己的服务然后调用官方的去实现这个功能
out/production/patterns/com/pattern/ProxyPattern/materials/po/YellowBullHandler.class
浏览文件 @
46d3e4c3
无法预览此类型文件
src/com/pattern/PatternApplication.java
浏览文件 @
46d3e4c3
package
com.pattern
;
package
com.pattern
;
import
com.pattern.ProxyPattern.ProxyMain
;
/**
/**
* @author lx
* @author lx
*/
*/
...
@@ -13,6 +11,7 @@ public class PatternApplication {
...
@@ -13,6 +11,7 @@ public class PatternApplication {
解释器模式
解释器模式
new InterpreterMain().main();
new InterpreterMain().main();
2021-10-14:制作多个计算规则,用这些规则去拼装组合来实现某些需求
2021-10-14:制作多个计算规则,用这些规则去拼装组合来实现某些需求
2021-11-24:一个接口很多实例的类,其中一个类是终端计算规则,剩下的类传入一个或多个终端计算,并把每一个终端计算结果再进行计算,成为一个单独的计算规则
*/
*/
...
@@ -21,7 +20,7 @@ public class PatternApplication {
...
@@ -21,7 +20,7 @@ public class PatternApplication {
策略模式
策略模式
new StrategyMain().main();
new StrategyMain().main();
2021-10-14:通过构造context传入不同的规则,再给context执行方法传入不同的值进行不同的计算
2021-10-14:通过构造context传入不同的规则,再给context执行方法传入不同的值进行不同的计算
2021-11-24:context作为触发器,传进来不同的策略,然后执行策略里面的方法
*/
*/
...
@@ -38,7 +37,7 @@ public class PatternApplication {
...
@@ -38,7 +37,7 @@ public class PatternApplication {
/*
/*
工厂模式 -- 方法工厂
工厂模式 -- 方法工厂
new FunctionFactoryMain().main();
new FunctionFactoryMain().main();
2021-10-14:
2021-10-14:
一个工厂只能造一种产品,也就是一个方法工厂返回一个对象,想要多个对象就要多个工厂
*/
*/
...
@@ -47,7 +46,7 @@ public class PatternApplication {
...
@@ -47,7 +46,7 @@ public class PatternApplication {
/*
/*
工厂模式 -- 抽象工厂
工厂模式 -- 抽象工厂
new AbstractFactoryMain().main();
new AbstractFactoryMain().main();
2021-10-14:
2021-10-14:
把工厂抽象,实例化一个工厂定义多个对象的产出,然后实例化这个工厂就可以拿到多个产品
*/
*/
...
@@ -70,9 +69,10 @@ public class PatternApplication {
...
@@ -70,9 +69,10 @@ public class PatternApplication {
*/
*/
new
ProxyMain
().
reflectMain
();
/*
/*
代理模式
代理模式 ---动态代理
new ProxyMain().reflectMain();
代理模式 ---静态代理
new ProxyMain().staticMain();
new ProxyMain().staticMain();
2021-10-14:
2021-10-14:
...
...
src/com/pattern/ProxyPattern/ProxyMain.java
浏览文件 @
46d3e4c3
...
@@ -36,5 +36,6 @@ public class ProxyMain {
...
@@ -36,5 +36,6 @@ public class ProxyMain {
YellowBullHandler
handler
=
new
YellowBullHandler
();
YellowBullHandler
handler
=
new
YellowBullHandler
();
TicketService
subject
=
(
TicketService
)
handler
.
newProxyInstance
(
beijingStation
);
TicketService
subject
=
(
TicketService
)
handler
.
newProxyInstance
(
beijingStation
);
subject
.
consultation
(
"你们卖票的么?"
);
subject
.
consultation
(
"你们卖票的么?"
);
subject
.
sellT
();
}
}
}
}
src/com/pattern/ProxyPattern/materials/README.md
浏览文件 @
46d3e4c3
主:官方卖票的地方
代理:将官方买票的构造传进来,然后加上自己的服务然后调用官方的去实现这个功能
src/com/pattern/ProxyPattern/materials/po/YellowBullHandler.java
浏览文件 @
46d3e4c3
...
@@ -56,11 +56,13 @@ public class YellowBullHandler implements InvocationHandler {
...
@@ -56,11 +56,13 @@ public class YellowBullHandler implements InvocationHandler {
@Override
@Override
public
Object
invoke
(
Object
proxy
,
Method
method
,
Object
[]
args
)
throws
Throwable
{
public
Object
invoke
(
Object
proxy
,
Method
method
,
Object
[]
args
)
throws
Throwable
{
System
.
out
.
println
(
"高级黄牛为你服务..."
);
System
.
out
.
println
(
"
...
高级黄牛为你服务..."
);
Object
ret
;
Object
ret
;
try
{
try
{
if
(
args
!=
null
)
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
System
.
out
.
println
(
"参数"
+
(
i
+
1
)
+
":"
+
args
[
i
]);
System
.
out
.
println
(
"参数"
+
(
i
+
1
)
+
":"
+
args
[
i
]);
}
}
}
//调用目标方法
//调用目标方法
ret
=
method
.
invoke
(
target
,
args
);
ret
=
method
.
invoke
(
target
,
args
);
...
@@ -68,7 +70,7 @@ public class YellowBullHandler implements InvocationHandler {
...
@@ -68,7 +70,7 @@ public class YellowBullHandler implements InvocationHandler {
System
.
err
.
println
(
target
.
getClass
().
getName
()
+
method
.
getName
()
+
e
);
System
.
err
.
println
(
target
.
getClass
().
getName
()
+
method
.
getName
()
+
e
);
throw
e
;
throw
e
;
}
}
System
.
out
.
println
(
"高级黄牛服务结束..."
);
System
.
out
.
println
(
"
...
高级黄牛服务结束..."
);
return
ret
;
return
ret
;
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录