Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
211010717
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2021
211010717
Commits
e9ff5f99
Unverified
Commit
e9ff5f99
authored
Jan 17, 2021
by
squall
Committed by
GitHub
Jan 17, 2021
Browse files
Options
Downloads
Patches
Plain Diff
optimize: opt the logic of SpringProxyUtils.findTargetClass(#3155) (#3156)
parent
eee0c741
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
spring/src/main/java/io/seata/spring/util/SpringProxyUtils.java
+8
-24
8 additions, 24 deletions
.../src/main/java/io/seata/spring/util/SpringProxyUtils.java
with
8 additions
and
24 deletions
spring/src/main/java/io/seata/spring/util/SpringProxyUtils.java
+
8
−
24
View file @
e9ff5f99
...
@@ -23,10 +23,9 @@ import java.util.Set;
...
@@ -23,10 +23,9 @@ import java.util.Set;
import
io.seata.common.util.CollectionUtils
;
import
io.seata.common.util.CollectionUtils
;
import
io.seata.rm.tcc.remoting.parser.DubboUtil
;
import
io.seata.rm.tcc.remoting.parser.DubboUtil
;
import
org.springframework.aop.
TargetSource
;
import
org.springframework.aop.
framework.Advised
;
import
org.springframework.aop.framework.AdvisedSupport
;
import
org.springframework.aop.framework.AdvisedSupport
;
import
org.springframework.aop.support.AopUtils
;
import
org.springframework.aop.support.AopUtils
;
import
org.springframework.aop.target.EmptyTargetSource
;
/**
/**
* Proxy tools base on spring
* Proxy tools base on spring
...
@@ -34,9 +33,7 @@ import org.springframework.aop.target.EmptyTargetSource;
...
@@ -34,9 +33,7 @@ import org.springframework.aop.target.EmptyTargetSource;
* @author zhangsen
* @author zhangsen
*/
*/
public
class
SpringProxyUtils
{
public
class
SpringProxyUtils
{
private
SpringProxyUtils
()
{
private
SpringProxyUtils
()
{
}
}
/**
/**
...
@@ -47,18 +44,14 @@ public class SpringProxyUtils {
...
@@ -47,18 +44,14 @@ public class SpringProxyUtils {
* @throws Exception the exception
* @throws Exception the exception
*/
*/
public
static
Class
<?>
findTargetClass
(
Object
proxy
)
throws
Exception
{
public
static
Class
<?>
findTargetClass
(
Object
proxy
)
throws
Exception
{
if
(
AopUtils
.
isAopProxy
(
proxy
))
{
if
(
proxy
==
null
)
{
AdvisedSupport
advised
=
getAdvisedSupport
(
proxy
);
return
null
;
if
(
AopUtils
.
isJdkDynamicProxy
(
proxy
))
{
TargetSource
targetSource
=
advised
.
getTargetSource
();
return
targetSource
instanceof
EmptyTargetSource
?
getFirstInterfaceByAdvised
(
advised
)
:
targetSource
.
getTargetClass
();
}
}
Object
target
=
advised
.
getTargetSource
().
getTarget
();
if
(
AopUtils
.
isAopProxy
(
proxy
)
&&
proxy
instanceof
Advised
)
{
return
findTargetClass
(
target
);
Object
targetObject
=
((
Advised
)
proxy
).
getTargetSource
().
getTarget
();
}
else
{
return
findTargetClass
(
targetObject
);
return
proxy
==
null
?
null
:
proxy
.
getClass
();
}
}
return
proxy
.
getClass
();
}
}
public
static
Class
<?>[]
findInterfaces
(
Object
proxy
)
throws
Exception
{
public
static
Class
<?>[]
findInterfaces
(
Object
proxy
)
throws
Exception
{
...
@@ -79,15 +72,6 @@ public class SpringProxyUtils {
...
@@ -79,15 +72,6 @@ public class SpringProxyUtils {
}
}
}
}
private
static
Class
<?>
getFirstInterfaceByAdvised
(
AdvisedSupport
advised
)
{
Class
<?>[]
interfaces
=
advised
.
getProxiedInterfaces
();
if
(
interfaces
.
length
>
0
)
{
return
interfaces
[
0
];
}
else
{
throw
new
IllegalStateException
(
"Find the jdk dynamic proxy class that does not implement the interface"
);
}
}
/**
/**
* Gets advised support.
* Gets advised support.
*
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment