1
试图写一个简单的java代理,基于bytebuddy主页上的示例。我让代理工作,但是当我用OSGI运行时运行它时,它会抛出java.lang.NoClassDefFoundError。bytebuddy与osgi容器
任何指针?
java.lang.ClassNotFoundException: com.foo.javaagent.TimingInterceptor cannot be found by ..
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.implementation.MethodDelegation;
import net.bytebuddy.matcher.ElementMatchers;
import java.lang.instrument.Instrumentation;
public class TimerAgent {
public static void premain(String arguments,
Instrumentation instrumentation) {
new AgentBuilder.Default()
.type(ElementMatchers.nameEndsWith("World"))
.transform((builder, type, classLoader, module) ->
builder.method(ElementMatchers.any())
.intercept(MethodDelegation.to(TimingInterceptor.class))
).installOn(instrumentation);
}
}
拉斐尔 - 非常感谢您的快速回复。你已经创作了一个很棒的图书馆。我能够得到它的工作。有没有关于如何修改方法输入参数,HTTP拦截器与字节好友的例子? – basu76