Java Code Examples for net.bytebuddy.agent.builder.AgentBuilder#Transformer

The following examples show how to use net.bytebuddy.agent.builder.AgentBuilder#Transformer . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeTransformation.java    From kanela with Apache License 2.0 5 votes vote down vote up
@SafeVarargs
static TypeTransformation of(String instrumentationName,
                             Option<ElementMatcher<? super TypeDescription>> elementMatcher,
                             Option<ClassLoaderRefiner> classLoaderRefiner,
                             List<AgentBuilder.Transformer> bridges,
                             List<AgentBuilder.Transformer> mixins,
                             List<AgentBuilder.Transformer>... transformers) {

    val transformations = Arrays.stream(transformers)
            .flatMap(Collection::stream)
            .collect(Collectors.toList());

    return new TypeTransformation(instrumentationName ,elementMatcher, classLoaderRefiner, bridges, mixins, transformations);
}
 
Example 2
Source File: MixinDescription.java    From kanela with Apache License 2.0 5 votes vote down vote up
public AgentBuilder.Transformer makeTransformer() {
    return (builder, typeDescription, classLoader, module) -> {
        val interfaces = List.ofAll(Arrays.asList(mixinClass.getInterfaces()))
            .toSet()
            .map(TypeDescription.ForLoadedType::new)
            .toJavaList();

        return builder
            .implement(interfaces)
            .visit(MixinClassVisitorWrapper.of(this, typeDescription, classLoader));
    };

}
 
Example 3
Source File: AdvisorDescription.java    From kanela with Apache License 2.0 5 votes vote down vote up
public AgentBuilder.Transformer makeTransformer() {
    val name = Option.of(advisorClassName).getOrElse(() -> advisorClass.getName());
    return new AgentBuilder.Transformer.ForAdvice()
            .advice(this.methodMatcher, name)
            .include(Thread.currentThread().getContextClassLoader())
            .withExceptionHandler(AdviceExceptionHandler.instance());
}
 
Example 4
Source File: BridgeDescription.java    From kanela with Apache License 2.0 4 votes vote down vote up
public AgentBuilder.Transformer makeTransformer() {
    return (builder, typeDescription, classLoader, module) -> builder
        .implement(new TypeDescription.ForLoadedType(this.bridgeInterface))
        .visit(BridgeClassVisitorWrapper.of(this, typeDescription, classLoader));
}
 
Example 5
Source File: ClassFileVersionValidatorTransformer.java    From kanela with Apache License 2.0 4 votes vote down vote up
private static AgentBuilder.Transformer makeTransformer() {
    return (builder, typeDescription, classLoader, module) ->
            builder.visit(ClassFileVersionValidatorWrapper.Instance);
}
 
Example 6
Source File: InstrumentationBuilder.java    From kanela with Apache License 2.0 4 votes vote down vote up
private <T> List<AgentBuilder.Transformer> collect(List<T> transformerList, Function<T, AgentBuilder.Transformer> f) {
    return transformerList.stream()
            .map(f)
            .collect(Collectors.toList());
}
 
Example 7
Source File: InstrumentationDescription.java    From kanela with Apache License 2.0 votes vote down vote up
private AgentBuilder.Transformer withTransformer(Function4<DynamicType.Builder, TypeDescription, ClassLoader, JavaModule, DynamicType.Builder> f) { return f::apply; }