本文整理汇总了Java中net.bytebuddy.matcher.ElementMatcher.Junction方法的典型用法代码示例。如果您正苦于以下问题:Java ElementMatcher.Junction方法的具体用法?Java ElementMatcher.Junction怎么用?Java ElementMatcher.Junction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.bytebuddy.matcher.ElementMatcher
的用法示例。
在下文中一共展示了ElementMatcher.Junction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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")))));
}
示例4: 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();
}
}
示例5: 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);
}
示例6: excludeObjectDefaultMethod
import net.bytebuddy.matcher.ElementMatcher; //导入方法依赖的package包/类
protected ElementMatcher.Junction<MethodDescription> excludeObjectDefaultMethod() {
ElementMatcher.Junction<MethodDescription> exclusiveMatcher = null;
for (MethodMatcher methodMatcher : EXCLUSIVE_DEFAULT_METHOD_NAME) {
if (exclusiveMatcher == null) {
exclusiveMatcher = methodMatcher.buildMatcher();
continue;
}
exclusiveMatcher = exclusiveMatcher.or(methodMatcher.buildMatcher());
}
return not(exclusiveMatcher);
}
示例7: match
import net.bytebuddy.matcher.ElementMatcher; //导入方法依赖的package包/类
@Override
public ElementMatcher.Junction<MethodDescription> match() {
ElementMatcher.Junction<MethodDescription> result = null;
for (MethodMatcher matcher : matchers) {
if (result == null) {
result = matcher.buildMatcher();
continue;
}
result = result.or(matcher.buildMatcher());
}
return not(result);
}
示例8: mergeArgumentsIfNecessary
import net.bytebuddy.matcher.ElementMatcher; //导入方法依赖的package包/类
protected ElementMatcher.Junction<MethodDescription> mergeArgumentsIfNecessary(ElementMatcher.Junction<MethodDescription> matcher) {
if (argTypeArray != null) {
matcher = matcher.and(takesArguments(argTypeArray));
}
if (argNum > -1) {
matcher = matcher.and(takesArguments(argNum));
}
if (modifier != null) {
matcher = matcher.and(modifier.elementMatcher());
}
return matcher;
}
示例9: buildJunction
import net.bytebuddy.matcher.ElementMatcher; //导入方法依赖的package包/类
@Override
public ElementMatcher.Junction buildJunction() {
ElementMatcher.Junction junction = null;
for (String annotation : annotations) {
if (junction == null) {
junction = buildEachAnnotation(annotation);
} else {
junction = junction.and(buildEachAnnotation(annotation));
}
}
junction = declaresMethod(junction).and(not(isInterface()));
return junction;
}
示例10: buildJunction
import net.bytebuddy.matcher.ElementMatcher; //导入方法依赖的package包/类
@Override
public ElementMatcher.Junction buildJunction() {
ElementMatcher.Junction junction = null;
for (String name : matchClassNames) {
if (junction == null) {
junction = named(name);
} else {
junction = junction.or(named(name));
}
}
return junction;
}
示例11: buildJunction
import net.bytebuddy.matcher.ElementMatcher; //导入方法依赖的package包/类
@Override
public ElementMatcher.Junction buildJunction() {
ElementMatcher.Junction junction = null;
for (String superTypeName : parentTypes) {
if (junction == null) {
junction = buildSuperClassMatcher(superTypeName);
} else {
junction = junction.and(buildSuperClassMatcher(superTypeName));
}
}
junction = junction.and(not(isInterface()));
return junction;
}
示例12: buildJunction
import net.bytebuddy.matcher.ElementMatcher; //导入方法依赖的package包/类
@Override
public ElementMatcher.Junction buildJunction() {
ElementMatcher.Junction junction = null;
for (String annotation : annotations) {
if (junction == null) {
junction = buildEachAnnotation(annotation);
} else {
junction = junction.and(buildEachAnnotation(annotation));
}
}
junction = junction.and(not(isInterface()));
return junction;
}
示例13: inPlugins
import net.bytebuddy.matcher.ElementMatcher; //导入方法依赖的package包/类
public <T extends NamedElement> ElementMatcher.Junction<T> inPlugins() {
return new NameMatcher(new PluginMathers(pluginManager));
}
示例14: buildMatcher
import net.bytebuddy.matcher.ElementMatcher; //导入方法依赖的package包/类
@Override
public ElementMatcher.Junction<MethodDescription> buildMatcher() {
return this.match().and(excludeObjectDefaultMethod());
}
示例15: buildMatcher
import net.bytebuddy.matcher.ElementMatcher; //导入方法依赖的package包/类
@Override
public ElementMatcher.Junction<MethodDescription> buildMatcher() {
ElementMatcher.Junction<MethodDescription> matcher = nameMatches(getMethodMatchDescribe());
return mergeArgumentsIfNecessary(matcher);
}