Something about plugin dependencies.

Answered

I want to implement the function of traffic replay. So i want to enhancer org.springframework.web.servlet.DispatcherServlet this class. And I have achieved the increase of bytecode using asm and javassist both ways.

When I went to test this function I found a problem. If the target project does not have asm or javassist dependencies, This enhanced function will not be triggered, and the added functions can be executed normally when I manually add their dependencies.  Is this a normal result?

0
6 comments

Sorry but it's impossible to understand what your code does exactly and how it might depend on the (non-)presence of these libraries. Please share more details.

0

I have two projects, one is a plugin project and the other is a simple Spring-Boot project that only contains the dependencies of spring-boot-starter-web.

The purpose of writing a plugin is to get all http requests in the web project. So i use javassist enhancer `org.springframework.web.servlet.DispatcherServlet`. The problem now is that this enhancement won't work if the web project doesn't add the javassist dependency.

plugin project: https://github.com/GGGGGHT/hotswap

web project: https://github.com/GGGGGHT/mvc

0

when project start https://github.com/GGGGGHT/hotswap/blob/main/agent/src/main/java/com/ggggght/agent/enhancer/JavassistEnhancer.java#L10.

This method will be called. But when the web project has no dependencies of javassist,ClassPool.getDefault() This method will return directly and will not continue to execute downwards. Only when the web project depends on javassist, it can be executed normally

0

Sorry for delay. I guess this is the expected result. You could modify and add required dependencies from your plugin "manually", or for a start, show notification to user that such dependencies must be added in their project to make your enhancement working at runtime.

0

In other words, if users don't add dependencies to their own projects, can these features not be implemented?

0

Your plugin could automate this process of adding required dependencies.

0

Please sign in to leave a comment.