为agent创建专有的全局匹配器。用于控制是否需要进入增强逻辑。

This commit is contained in:
wusheng 2016-07-31 22:22:27 +08:00
parent d6ae469b76
commit f9653bbdf3
3 changed files with 39 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package com.ai.cloud.skywalking.agent;
import com.ai.cloud.skywalking.agent.junction.SkyWalkingEnhanceMatcher;
import com.ai.cloud.skywalking.conf.AuthDesc;
import com.ai.cloud.skywalking.conf.Config;
import com.ai.cloud.skywalking.logging.LogManager;
@ -10,6 +11,7 @@ import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.matcher.BooleanMatcher;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.matcher.ElementMatchers;
@ -19,6 +21,7 @@ import java.net.URL;
import java.util.List;
import static net.bytebuddy.matcher.ElementMatchers.any;
import static net.bytebuddy.matcher.ElementMatchers.named;
public class SkywalkingAgent {
@ -56,7 +59,11 @@ public class SkywalkingAgent {
}
private static ElementMatcher.Junction<NamedElement> exclusivePackageClass() {
return any();
return myMatcher();
}
private static <T extends NamedElement> ElementMatcher.Junction<T> myMatcher() {
return new SkyWalkingEnhanceMatcher<T>();
}

View File

@ -0,0 +1,18 @@
package com.ai.cloud.skywalking.agent.junction;
import net.bytebuddy.matcher.ElementMatcher;
/**
* Created by wusheng on 16/7/31.
*/
public abstract class AbstractJunction<V> implements ElementMatcher.Junction<V> {
@Override
public <U extends V> Junction<U> and(ElementMatcher<? super U> other) {
return new Conjunction<U>(this, other);
}
@Override
public <U extends V> Junction<U> or(ElementMatcher<? super U> other) {
return new Disjunction<U>(this, other);
}
}

View File

@ -0,0 +1,13 @@
package com.ai.cloud.skywalking.agent.junction;
import net.bytebuddy.description.NamedElement;
/**
* Created by wusheng on 16/7/31.
*/
public class SkyWalkingEnhanceMatcher<T extends NamedElement> extends AbstractJunction<T> {
@Override
public boolean matches(T target) {
return false;
}
}