Java Code Examples for net.bytebuddy.matcher.ElementMatchers#named()

The following examples show how to use net.bytebuddy.matcher.ElementMatchers#named() . 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 Project: skywalking   File: LightInstrumentation.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
    return new InstanceMethodsInterceptPoint[] {
        new InstanceMethodsInterceptPoint() {
            @Override
            public ElementMatcher<MethodDescription> getMethodsMatcher() {
                return ElementMatchers.named(ENHANCE_METHOD);
            }

            @Override
            public String getMethodsInterceptor() {
                return INTERCEPTOR_CLASS;
            }

            @Override
            public boolean isOverrideArgs() {
                return false;
            }
        }
    };
}
 
Example 2
@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
    return new InstanceMethodsInterceptPoint[] {
        new InstanceMethodsInterceptPoint() {
            @Override
            public ElementMatcher<MethodDescription> getMethodsMatcher() {
                return ElementMatchers.named("request");
            }

            @Override
            public String getMethodsInterceptor() {
                return INTERCEPTOR_CLASS;
            }

            @Override
            public boolean isOverrideArgs() {
                return false;
            }
        }
    };
}
 
Example 3
@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
    return new InstanceMethodsInterceptPoint[] {
        new InstanceMethodsInterceptPoint() {
            @Override
            public ElementMatcher<MethodDescription> getMethodsMatcher() {
                return ElementMatchers.named("respond");
            }

            @Override
            public String getMethodsInterceptor() {
                return INTERCEPTOR_CLASS;
            }

            @Override
            public boolean isOverrideArgs() {
                return false;
            }
        }
    };
}
 
Example 4
@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
    return new InstanceMethodsInterceptPoint[] {
        new InstanceMethodsInterceptPoint() {
            @Override
            public ElementMatcher<MethodDescription> getMethodsMatcher() {
                return ElementMatchers.named("invoke");
            }

            @Override
            public String getMethodsInterceptor() {
                return INTERCEPTOR_CLASS;
            }

            @Override
            public boolean isOverrideArgs() {
                return false;
            }
        }
    };
}
 
Example 5
@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
    return new InstanceMethodsInterceptPoint[] {
        new InstanceMethodsInterceptPoint() {
            @Override
            public ElementMatcher<MethodDescription> getMethodsMatcher() {
                return ElementMatchers.named(METHOD_NAME);
            }

            @Override
            public String getMethodsInterceptor() {
                return INTERCEPTOR_CLASS;
            }

            @Override
            public boolean isOverrideArgs() {
                return false;
            }
        }
    };
}
 
Example 6
@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
    return new InstanceMethodsInterceptPoint[] {
        new InstanceMethodsInterceptPoint() {
            @Override
            public ElementMatcher<MethodDescription> getMethodsMatcher() {
                return ElementMatchers
                    // 3.6.x
                    .named(METHOD_NAME);
            }

            @Override
            public String getMethodsInterceptor() {
                return INTERCEPTOR_CLASS;
            }

            @Override
            public boolean isOverrideArgs() {
                return false;
            }
        }
    };
}
 
Example 7
@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
    return new InstanceMethodsInterceptPoint[] {
        new InstanceMethodsInterceptPoint() {
            @Override
            public boolean isOverrideArgs() {
                return false;
            }

            @Override
            public ElementMatcher<MethodDescription> getMethodsMatcher() {
                return ElementMatchers.named("request").and(ElementMatchers.takesArguments(3));
            }

            @Override
            public String getMethodsInterceptor() {
                return "org.apache.skywalking.apm.plugin.solrj.SolrClientInterceptor";
            }
        },
        new InstanceMethodsInterceptPoint() {
            @Override
            public boolean isOverrideArgs() {
                return false;
            }

            @Override
            public ElementMatcher<MethodDescription> getMethodsMatcher() {
                return ElementMatchers.named("executeMethod");
            }

            @Override
            public String getMethodsInterceptor() {
                return "org.apache.skywalking.apm.plugin.solrj.SolrConnectorInterceptor";
            }
        }
    };
}
 
Example 8
/**
 * Creates a matcher where only overridable or declared methods are matched unless those are ignored. Methods that
 * are declared by the target type are only matched if they are not ignored. Declared methods that are not found on the
 * target type are always matched.
 *
 * @param ignoredMethods A method matcher that matches any ignored method.
 * @param originalType   The original type of the instrumentation before adding any user methods.
 * @return A latent method matcher that identifies any method to instrument for a rebasement or redefinition.
 */
protected static LatentMatcher<MethodDescription> of(LatentMatcher<? super MethodDescription> ignoredMethods, TypeDescription originalType) {
    ElementMatcher.Junction<MethodDescription> predefinedMethodSignatures = none();
    for (MethodDescription methodDescription : originalType.getDeclaredMethods()) {
        ElementMatcher.Junction<MethodDescription> signature = methodDescription.isConstructor()
                ? isConstructor()
                : ElementMatchers.<MethodDescription>named(methodDescription.getName());
        signature = signature.and(returns(methodDescription.getReturnType().asErasure()));
        signature = signature.and(takesArguments(methodDescription.getParameters().asTypeList().asErasures()));
        predefinedMethodSignatures = predefinedMethodSignatures.or(signature);
    }
    return new InliningImplementationMatcher(ignoredMethods, predefinedMethodSignatures);
}
 
Example 9
@Override
public ElementMatcher<? super TypeDescription> getTypeMatcher() {
    return ElementMatchers.named("co.elastic.apm.agent.bci.InstrumentationTest");
}
 
Example 10
@Override
public ElementMatcher<? super MethodDescription> getMethodMatcher() {
    return ElementMatchers.named("interceptMe");
}
 
Example 11
@Override
public ElementMatcher<? super TypeDescription> getTypeMatcher() {
    return ElementMatchers.named("org.apache.commons.math.util.MathUtils");
}
 
Example 12
@Override
public ElementMatcher<? super TypeDescription> getTypeMatcher() {
    return ElementMatchers.named(InstrumentationTest.class.getName());
}
 
Example 13
@Override
public ElementMatcher<? super TypeDescription> getTypeMatcher() {
    return ElementMatchers.named(InstrumentationTest.class.getName());
}
 
Example 14
@Override
public ElementMatcher<? super MethodDescription> getMethodMatcher() {
    return ElementMatchers.named("noExceptionPlease");
}