File tree Expand file tree Collapse file tree
src/main/java/com/cpucode/pattern/proxy/simpleproxy Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8484## [ 代理模式] ( src/main/java/com/cpucode/pattern/proxy )
8585
8686- [x] [ 静态代理__ StaticProxyTest] ( src/main/java/com/cpucode/pattern/proxy/staticproxy/StaticProxyTest.java )
87+ - [x] [ 静态代理__ Client] ( src/main/java/com/cpucode/pattern/proxy/simpleproxy/Client.java )
8788- [x] [ 静态代理__ DbRouteProxyTest] ( src/main/java/com/cpucode/pattern/proxy/db/route/proxy/staticdb/DbRouteProxyTest.java )
8889- [x] [ 动态代理__ DbRouteProxyTest] ( src/main/java/com/cpucode/pattern/proxy/db/route/proxy/dynamic/DbRouteProxyTest.java )
8990- [x] [ JDK动态代理__ JDKProxyTest] ( src/main/java/com/cpucode/pattern/proxy/dynamicproxy/jdkproxy/JDKProxyTest.java )
9091- [x] [ JDK手写实现__ GPProxyTest] ( src/main/java/com/cpucode/pattern/proxy/dynamicproxy/gpproxy/GPProxyTest.java )
91-
92+
9293
9394## [ 适配器模式] ( )
9495
Original file line number Diff line number Diff line change 1111 </content >
1212 <orderEntry type =" inheritedJdk" />
1313 <orderEntry type =" sourceFolder" forTests =" false" />
14+ <orderEntry type =" library" name =" Maven: cglib:cglib-nodep:2.2" level =" project" />
1415 </component >
1516</module >
Original file line number Diff line number Diff line change 88 <artifactId >pattern</artifactId >
99 <version >1.0-SNAPSHOT</version >
1010
11+ <dependencies >
12+ <dependency >
13+ <groupId >cglib</groupId >
14+ <artifactId >cglib-nodep</artifactId >
15+ <version >2.2</version >
16+ </dependency >
17+ </dependencies >
18+
1119 <build >
1220 <plugins >
1321 <!-- java编译插件 -->
Original file line number Diff line number Diff line change 1+ package com .cpucode .pattern .proxy .simpleproxy ;
2+
3+ /**
4+ * @author : cpucode
5+ * @date : 2021/5/30
6+ * @time : 17:50
7+ * @github : https://github.com/CPU-Code
8+ * @csdn : https://blog.csdn.net/qq_44226094
9+ */
10+ public class Client {
11+ public static void main (String [] args ) {
12+ Proxy proxy = new Proxy (new RealSubject ());
13+ proxy .request ();
14+ }
15+ }
Original file line number Diff line number Diff line change 1+ package com .cpucode .pattern .proxy .simpleproxy ;
2+
3+ /**
4+ * @author : cpucode
5+ * @date : 2021/5/30
6+ * @time : 17:49
7+ * @github : https://github.com/CPU-Code
8+ * @csdn : https://blog.csdn.net/qq_44226094
9+ */
10+ public class Proxy implements Subject {
11+ private Subject subject ;
12+
13+ public Proxy (Subject subject ){
14+ this .subject = subject ;
15+ }
16+
17+ @ Override
18+ public void request () {
19+ before ();
20+ subject .request ();
21+ after ();
22+ }
23+
24+ public void before (){
25+ System .out .println ("called before request()." );
26+ }
27+
28+ public void after (){
29+ System .out .println ("called after request()." );
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ package com .cpucode .pattern .proxy .simpleproxy ;
2+
3+ /**
4+ * @author : cpucode
5+ * @date : 2021/5/30
6+ * @time : 17:49
7+ * @github : https://github.com/CPU-Code
8+ * @csdn : https://blog.csdn.net/qq_44226094
9+ */
10+ public class RealSubject implements Subject {
11+ @ Override
12+ public void request () {
13+ System .out .println ("real service is called." );
14+ }
15+ }
Original file line number Diff line number Diff line change 1+ package com .cpucode .pattern .proxy .simpleproxy ;
2+
3+ /**
4+ * @author : cpucode
5+ * @date : 2021/5/30
6+ * @time : 17:45
7+ * @github : https://github.com/CPU-Code
8+ * @csdn : https://blog.csdn.net/qq_44226094
9+ */
10+ public interface Subject {
11+ void request ();
12+ }
You can’t perform that action at this time.
0 commit comments