Hi,
OSGi is built on top of standard Java, a Java agent should therefore function as usual.
However, you still need to run your agent on startup of the OSGi container using the javaagent parameter. You cannot bundle an agent as the OSGi container does not trigger agents.
Cheers, Rafael
byte-buddy-0.7.1
I'm successfully using ByteBuddyAgent in a regular java application but I'm having trouble using it with OSGI. I've tried installing the agent with a transformer before OSGI is initialized and in an Activator on Bundle startup but the transformer is not doing anything. Do you have any examples of how to yse ByteBuddyAgent with OSGI?
--
You received this message because you are subscribed to the Google Groups "Byte Buddy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to byte-buddy+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
ByteBuddyAgent.install(); new AgentBuilder.Default()
.type(ElementMatchers.is(CLASS))
.transform(new AgentBuilder.Transformer() {
@Override
public DynamicType.Builder transform(DynamicType.Builder builder, TypeDescription typeDescription) {
System.out.format("Transforming %s", typeDescription.getName());
return builder
.constructor(any())
.intercept(SuperMethodCall.INSTANCE.andThen(MethodDelegation.to(new Object() {
public void m(@This Object o) {
System.out.format("After constructor %s%n", o.getClass().getName());
}
})));
}
}).installOnByteBuddyAgent();
This might be a visibility issue. Your interceptor is package private. Please register a listener to your agent builder and see if there is any problem. This way, you also have a relyable way of finding out if your type is considered for instrumentation.
--