本文整理汇总了Java中net.bytebuddy.matcher.ElementMatcher类的典型用法代码示例。如果您正苦于以下问题:Java ElementMatcher类的具体用法?Java ElementMatcher怎么用?Java ElementMatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ElementMatcher类属于net.bytebuddy.matcher包,在下文中一共展示了ElementMatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIncludes
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public ElementMatcher<MethodDescription> getIncludes() {
return not(ElementMatchers.<MethodDescription>isPrivate()
.or(ObjectMethodElementMatchers.INSTANCE)
.or(named("close"))
.or(named("getDB"))
.or(named("getClient"))
.or(named("connect"))
.or(named("setDataSource"))
.or(named("resetState"))
.or(named("clusterSlots"))
.or(named("isConnected"))
.or(named("ping"))
.or(named("quit"))
.or(named("checkIsInMultiOrPipeline")));
}
示例2: matchAnyMethodIn
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
/**
* Returns a byte buddy matcher matching any method contained in methodSignatures.
*/
public static ElementMatcher<MethodDescription> matchAnyMethodIn(Set<MethodSignature> methodSignatures) {
ElementMatcher.Junction<MethodDescription> methodMatcher = ElementMatchers.none();
for (MethodSignature methodSignature : methodSignatures) {
ElementMatcher.Junction<MethodDescription> junction = ElementMatchers
.named(methodSignature.getMethodName())
.and(not(isAbstract()))
.and(isPublic())
.and(takesArguments(methodSignature.getParameterTypes().size()));
for (int i = 0; i < methodSignature.getParameterTypes().size(); i++) {
junction = junction.and(takesArgument(i, named(methodSignature.getParameterTypes().get(i))));
}
methodMatcher = methodMatcher.or(junction);
}
return methodMatcher;
}
示例3: createAgentBuilder
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
/**
* Creates the AgentBuilder that will redefine the System class.
* @param inst instrumentation instance.
* @return an agent builder.
*/
private static AgentBuilder createAgentBuilder(Instrumentation inst) {
// Find me a class called "java.lang.System"
final ElementMatcher.Junction<NamedElement> systemType = ElementMatchers.named("java.lang.System");
// And then find a method called setSecurityManager and tell MySystemInterceptor to
// intercept it (the method binding is smart enough to take it from there)
final AgentBuilder.Transformer transformer =
(b, typeDescription) -> b.method(ElementMatchers.named("setSecurityManager"))
.intercept(MethodDelegation.to(MySystemInterceptor.class));
// Disable a bunch of stuff and turn on redefine as the only option
final ByteBuddy byteBuddy = new ByteBuddy().with(Implementation.Context.Disabled.Factory.INSTANCE);
final AgentBuilder agentBuilder = new AgentBuilder.Default()
.withByteBuddy(byteBuddy)
.withInitializationStrategy(AgentBuilder.InitializationStrategy.NoOp.INSTANCE)
.withRedefinitionStrategy(AgentBuilder.RedefinitionStrategy.REDEFINITION)
.withTypeStrategy(AgentBuilder.TypeStrategy.Default.REDEFINE)
.type(systemType)
.transform(transformer);
return agentBuilder;
}
示例4: createMatcher
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
private static ElementMatcher.Junction<TypeDescription> createMatcher() {
// This matcher matches implementations of Executor, but excludes CurrentContextExecutor and
// FixedContextExecutor from io.grpc.Context, which already propagate the context.
// TODO(stschmidt): As the executor implementation itself (e.g. ThreadPoolExecutor) is
// instrumented by the agent for automatic context propagation, CurrentContextExecutor could be
// turned into a no-op to avoid another unneeded context propagation. Likewise, when using
// FixedContextExecutor, the automatic context propagation added by the agent is unneeded.
return isSubTypeOf(Executor.class)
.and(not(isAbstract()))
.and(
not(
nameStartsWith("io.grpc.Context$")
.and(
nameEndsWith("CurrentContextExecutor")
.or(nameEndsWith("FixedContextExecutor")))));
}
示例5: elementMatcher
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
private ElementMatcher.Junction<MethodDescription> elementMatcher() {
switch (this) {
case Private: {
return isPrivate();
}
case Default: {
return isPackagePrivate();
}
case Public: {
return isPublic();
}
case Protected: {
return isProtected();
}
default:
return isPublic();
}
}
示例6: getInstanceMethodsInterceptPoints
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
@Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[] {
new InstanceMethodsInterceptPoint() {
@Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named(ENHANCE_METHOD);
}
@Override public String getMethodsInterceptor() {
return INTERCEPTOR_CLASS;
}
@Override public boolean isOverrideArgs() {
return false;
}
}
};
}
示例7: buildMatch
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
public ElementMatcher<? super TypeDescription> buildMatch() {
ElementMatcher.Junction judge = new AbstractJunction<NamedElement>() {
@Override
public boolean matches(NamedElement target) {
return nameMatchDefine.containsKey(target.getActualName());
}
};
judge = judge.and(not(isInterface()));
for (AbstractClassEnhancePluginDefine define : signatureMatchDefine) {
ClassMatch match = define.enhanceClass();
if (match instanceof IndirectMatch) {
judge = judge.or(((IndirectMatch)match).buildJunction());
}
}
return new ProtectiveShieldMatcher(judge);
}
示例8: getInstanceMethodsInterceptPoints
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
/**
* @return the collection of {@link InstanceMethodsInterceptPoint}, represent the intercepted methods and their
* interceptors.
*/
@Override
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[] {
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("convert");
}
@Override
public String getMethodsInterceptor() {
return "PrintTraceIdInterceptor";
}
@Override public boolean isOverrideArgs() {
return false;
}
}
};
}
示例9: getInstanceMethodsInterceptPoints
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
@Override
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[] {
new InstanceMethodsInterceptPoint() {
@Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("activate");
}
@Override public String getMethodsInterceptor() {
return ACTIVATE_METHOD_INTERCEPTOR;
}
@Override public boolean isOverrideArgs() {
return false;
}
}
};
}
示例10: getInstanceMethodsInterceptPoints
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
/**
* @return the collection of {@link StaticMethodsInterceptPoint}, represent the intercepted methods and their
* interceptors.
*/
@Override
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[] {
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("convert");
}
@Override
public String getMethodsInterceptor() {
return "PrintTraceIdInterceptor";
}
@Override public boolean isOverrideArgs() {
return false;
}
}
};
}
示例11: getInstanceMethodsInterceptPoints
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
@Override
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[] {
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("convertTID");
}
@Override
public String getMethodsInterceptor() {
return "PrintMDCTraceIdInterceptor";
}
@Override public boolean isOverrideArgs() {
return false;
}
}
};
}
示例12: getStaticMethodsInterceptPoints
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
/**
* @return the collection of {@link StaticMethodsInterceptPoint}, represent the intercepted methods and their
* interceptors.
*/
@Override
protected StaticMethodsInterceptPoint[] getStaticMethodsInterceptPoints() {
return new StaticMethodsInterceptPoint[] {
new StaticMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("append");
}
@Override
public String getMethodsInterceptor() {
return "PrintTraceIdInterceptor";
}
@Override public boolean isOverrideArgs() {
return false;
}
}
};
}
示例13: getStaticMethodsInterceptPoints
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
@Override protected StaticMethodsInterceptPoint[] getStaticMethodsInterceptPoints() {
return new StaticMethodsInterceptPoint[] {
new StaticMethodsInterceptPoint() {
@Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named(INTERCEPTOR_METHOD_NAME);
}
@Override public String getMethodsInterceptor() {
return INTERCEPTOR_CLASS;
}
@Override public boolean isOverrideArgs() {
return false;
}
}
};
}
示例14: getStaticMethodsInterceptPoints
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
/**
* @return the collection of {@link StaticMethodsInterceptPoint}, represent the intercepted methods and their
* interceptors.
*/
@Override
protected StaticMethodsInterceptPoint[] getStaticMethodsInterceptPoints() {
return new StaticMethodsInterceptPoint[] {
new StaticMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("traceId");
}
@Override
public String getMethodsInterceptor() {
return "TraceContextInterceptor";
}
@Override public boolean isOverrideArgs() {
return false;
}
}
};
}
示例15: getInstanceMethodsInterceptPoints
import net.bytebuddy.matcher.ElementMatcher; //导入依赖的package包/类
@Override
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[] {
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("get").or(named("set")) .or(named("add")).or(named("replace")).or(named("gets"))
.or(named("append")) .or(named("prepend")).or(named("cas")).or(named("delete")).or(named("touch")).
or(named("getAndTouch")).or(named("incr")) .or(named("decr"));
}
@Override
public String getMethodsInterceptor() {
return METHOD_INTERCEPT_CLASS;
}
@Override public boolean isOverrideArgs() {
return false;
}
}
};
}