[英]Spring AOP Proxy for java.security.KeyStore
I'm wondering is there any way to make a Spring AOP Proxy for the java.security.KeyStore
, there are few obstacles here: 我想知道有什么方法可以为java.security.KeyStore
制作Spring AOP代理,这里没有什么障碍:
I know that it is impossible to make a Spring AOP Proxy with the above constraints, but anyway I need to somehow count the method invocations of the KeyStore in the application. 我知道用上述约束制作Spring AOP代理是不可能的,但是无论如何我都需要以某种方式计算应用程序中KeyStore的方法调用。 Could anybody suggest some way to bypass the Spring AOP constraints or another way? 有人可以建议绕过Spring AOP约束的其他方法吗?
If you have control of the calling code - and hopefully you do because it is your own application you are talking about - and are willing to use full AspectJ (which does not need any proxies) instead of Spring-AOP, you cann use a call()
pointcut instead of being limited to Spring-AOP's execution()
pointcut. 如果您可以控制调用代码-并希望能够这样做,因为您正在谈论的是它自己的应用程序-并且愿意使用完整的AspectJ(不需要任何代理)代替Spring-AOP,则可以使用call()
切入点,而不仅限于Spring-AOP的execution()
切入点。 The pointcut would look something like this (untested, hacked from memory): 切入点看起来像这样(未经测试,从内存中被黑客入侵):
@Pointcut("call(* java.security.KeyStore.*(..))")
If you want to extend the pointcut to subclasses, add a +
after the class name: 如果要将切入点扩展到子类,请在类名称后添加+
:
@Pointcut("call(* java.security.KeyStore+.*(..))")
You can even intercept constructor calls if they come from code you can weave into: 如果它们来自您可以编入的代码,您甚至可以拦截构造函数调用:
@Pointcut("call(java.security.KeyStore+.new(..))")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.