Comments (1)
Q:我有一个问题提出来探讨一下,指定要修复的类名和方法名的时候,一般情况下,我个人感觉我们应该是比较明确的知道要去热替换哪个类的哪个方法的,用正则要解决什么问题呢?是要匹配一批量的类和方法吗?个人感觉用类和方法的全限定名是最简单易用的,只是用正则要匹配和满足其他需求的问题我还没有想到,所以提出来讨论。因为我碰到的问题都是我知道哪个方法有问题了,我要去替换了分析和排除故障的。
A:哈哈,非常欢迎这种讨论
-
NameRegexFilter本意是一个Filter接口的Example,在
ModuleEventWatcher
的定义中,都是只定义了Filter类型的参数,没有写死必须要用NameRegexFilter
。因此你可以根据自己的实际需要去实现这个接口,从而让你更方便的匹配到你需要进行AOP的类和方法。
// ModuleEventWatcher.java /** * 观察事件 * * @param filter 观察类和方法过滤器 * 通过这个对象来告知{@code EventWatcher}观察的类和方法 * @param listener 事件监听器 * 观察到的事件将会告知此事件监听器 * @param eventType 观察事件类型 * @return {@code watchId},本次观察的唯一编号,{@code watcherId}对象将会是整个操作的唯一KEY,后续删除观察事件的时候也需要通过同一个{@code watcherId}来完成 */ int watch(Filter filter, EventListener listener, Event.Type... eventType);
-
为什么不全部采用精确匹配而是考虑了可进行批量匹配的正则表达式呢?没错,我们的确是有场景需要匹配一批量的类和方法。
在热修复场景中,类的确是越精确越好。但在更多的场景下(比如日志拦截),你可能要对一整个包下的类或者统一前后缀的类的指定方法进行拦截。此时正则表达式、通配符表达式在这种场合表现就非常灵活了
# 匹配上所有对外开放API的出入参(用于业务日志记录、全链路跟踪埋点等) new NameRegexFilter(".*\\.ServiceImpl",".*");
from jvm-sandbox.
Related Issues (20)
- 如何基于jvm-sandbox开发一个java agent HOT 3
- master 版本试用example 出问题 HOT 1
- 1.4.0版本支持JDK20相关问题 HOT 5
- JDK 17下的错误ClassCircularityError HOT 2
- 快速开始中的钉钉二维码过期了 HOT 4
- attack docker中进程失败 HOT 1
- 使用反射,sandbox还是报错class redefinition failed: attempted to change the schema (add/remove fields),请问这里应该怎么修改? HOT 3
- 如何对运行时生成的类进行增强? HOT 1
- 1.4.0版本在jdk17编译打包后,需要兼容增强jdk1.8的应用(实际运行的jre环境是1.8),请问是否可行? HOT 2
- before方法中返回类型转换问题 HOT 1
- 通过agent方式加载sandbox传参的问题 HOT 2
- event.javaMethodDesc 里面的参数和返回值类型不对
- watch大量不存在的类对业务系统的性能是否会有影响? HOT 2
- 请问使用sandbox应该如何拦截feign接口中client端的请求? HOT 2
- 请问,我用了1.4.0,为什么还会报module java.base does not "opens java.net" to unnamed module呢 HOT 2
- 实现类未能重写父类的方法如何transform这个实现类(而非父类,主要实现类太多不能监听父类),使用EventWatchBuilder HOT 2
- hessian序列化redisCache对象时报错 HOT 1
- sandbox支持jdk21吗 HOT 2
- ProcessController.returnImmediately返回new DefaultResponse(eurekaServiceInstance)的问题 HOT 1
- 请问如何将json string反射成复杂的泛型类型? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jvm-sandbox.