-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor:增加cglib 基类测试其结果。证明代理类生成过程以执行过程
- Loading branch information
Showing
18 changed files
with
267 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Example user template template | ||
### Example user template | ||
|
||
# IntelliJ project files | ||
.idea | ||
*.iml | ||
out | ||
gen | ||
target | ||
### JetBrains template | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
|
||
# Generated files | ||
.idea/**/contentModel.xml | ||
|
||
# Sensitive or high-churn files | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
.idea/**/dbnavigator.xml | ||
|
||
# Gradle | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# Gradle and Maven with auto-import | ||
# When using Gradle or Maven with auto-import, you should exclude module files, | ||
# since they will be recreated, and may cause churn. Uncomment if using | ||
# auto-import. | ||
# .idea/modules.xml | ||
# .idea/*.iml | ||
# .idea/modules | ||
# *.iml | ||
# *.ipr | ||
|
||
# CMake | ||
cmake-build-*/ | ||
|
||
# Mongo Explorer plugin | ||
.idea/**/mongoSettings.xml | ||
|
||
# File-based project format | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
.idea/replstate.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
# Editor-based Rest Client | ||
.idea/httpRequests | ||
|
||
# Android studio 3.1+ serialized cache file | ||
.idea/caches/build_file_checksums.ser | ||
|
||
### Java template | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/com/mxy/design/proxy/IStudent.java → src/main/com/mxy/design/proxy/ISchool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package com.mxy.design.proxy; | ||
|
||
public interface IStudent { | ||
public interface ISchool { | ||
|
||
void save(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.mxy.design.proxy; | ||
|
||
public class SchoolImpl implements ISchool { | ||
|
||
public SchoolImpl(){ | ||
//JDK动态代理通过反射会调用这个方法 | ||
System.out.println(SchoolImpl.class+":JDK 动态代理反射调用。"); | ||
} | ||
@Override | ||
public void save() { | ||
System.out.println("保存学校信息ing"); | ||
} | ||
|
||
@Override | ||
public void delete() { | ||
System.out.println("删除学校信息ing"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.mxy.design.proxy; | ||
|
||
/** | ||
* 重点类 静态代理 实现目标接口 | ||
*/ | ||
public class SchoolProxy implements ISchool { | ||
|
||
private ISchool student; | ||
|
||
public SchoolProxy(ISchool iSchool) { | ||
this.student = iSchool; | ||
} | ||
|
||
@Override | ||
public void save() { | ||
System.out.println("==开启事务"); | ||
student.save(); | ||
System.out.println("==提交事务"); | ||
} | ||
|
||
@Override | ||
public void delete() { | ||
//查询是否存在 | ||
System.out.println("===开启事务"); | ||
student.delete(); | ||
System.out.println("===提交事务"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
src/main/com/mxy/design/proxy/dynamic/cglib/proxy/IStudent.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
src/main/com/mxy/design/proxy/dynamic/cglib/proxy/StudentImpl.java
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
src/main/com/mxy/design/proxy/dynamic/cglib/proxy/StudentService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.mxy.design.proxy.dynamic.cglib.proxy; | ||
|
||
public class StudentService { | ||
|
||
public StudentService() { | ||
//CGLIB动态代理通过反射会调用这个方法 | ||
System.out.println("基类==> CGLIB 动态代理反射调用。"); | ||
} | ||
public StudentService(String str) { | ||
//避免混淆 | ||
} | ||
|
||
public void save() { | ||
System.out.println("保存ing"); | ||
} | ||
|
||
public void delete() { | ||
System.out.println("删除ing"); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/com/mxy/design/proxy/dynamic/cglib/proxy/StudentServiceExtend.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.mxy.design.proxy.dynamic.cglib.proxy; | ||
|
||
public class StudentServiceExtend extends StudentService { | ||
|
||
public StudentServiceExtend() { | ||
System.out.println("===>扩展类构造方法"); | ||
} | ||
|
||
@Override | ||
public void save(){ | ||
System.out.println("===>扩展类Save"); | ||
super.save(); | ||
} | ||
|
||
@Override | ||
public void delete(){ | ||
System.out.println("===>扩展类delete"); | ||
super.delete(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/com/mxy/design/proxy/dynamic/cglib/proxy/StudentServiceExtendChildren.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.mxy.design.proxy.dynamic.cglib.proxy; | ||
|
||
public class StudentServiceExtendChildren extends StudentServiceExtend { | ||
|
||
public StudentServiceExtendChildren() { | ||
System.out.println("===>扩展类子类构造方法"); | ||
} | ||
|
||
@Override | ||
public void save(){ | ||
System.out.println("===>扩展类子类save"); | ||
} | ||
|
||
@Override | ||
public void delete(){ | ||
System.out.println("===>扩展类子类delete"); | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
src/main/com/mxy/design/proxy/dynamic/jdk/proxy/IStudent.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
src/main/com/mxy/design/proxy/dynamic/jdk/proxy/StudentImpl.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.