• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NamedElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.bytebuddy.description.NamedElement的典型用法代码示例。如果您正苦于以下问题:Java NamedElement类的具体用法?Java NamedElement怎么用?Java NamedElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NamedElement类属于net.bytebuddy.description包,在下文中一共展示了NamedElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createAgentBuilder

import net.bytebuddy.description.NamedElement; //导入依赖的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;
}
 
开发者ID:wsargent,项目名称:securityfixer,代码行数:29,代码来源:SecurityFixerAgent.java


示例2:

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
<T, B extends AnnotatedCodeElement & NamedElement.WithRuntimeName> ControllerInjectValueData<T> createValue
        (int index, TypeDescription classType, TypeDescription.ForLoadedType.Generic type, B member, String name,
         Map<Class<? extends Annotation>, ? extends Annotation> parentRawScopeAnnotations,
         Map<Class<? extends Annotation>, ? extends Annotation> parentRawQualifierAnnotations)
{
    Map<Class<? extends Annotation>, ? extends Annotation> scopeAnnotations;
    {
        Map<Class<? extends Annotation>, ? extends Annotation> memberRawScopeAnnotations = this.extractRawScopeAnnotations(member);
        Map<Class<? extends Annotation>, Annotation> rawScopeAnnotations = new HashMap<>(parentRawScopeAnnotations);
        rawScopeAnnotations.putAll(memberRawScopeAnnotations);
        scopeAnnotations = this.transformAll(classType, name, member, rawScopeAnnotations);
    }
    Map<Class<? extends Annotation>, ? extends Annotation> qualifierAnnotations;
    {
        Map<Class<? extends Annotation>, ? extends Annotation> memberRawQualifierAnnotations = this.extractRawQualifierAnnotations(member);
        Map<Class<? extends Annotation>, Annotation> rawQualifierAnnotations = new HashMap<>(parentRawQualifierAnnotations);
        rawQualifierAnnotations.putAll(memberRawQualifierAnnotations);
        qualifierAnnotations = this.transformAll(classType, name, member, rawQualifierAnnotations);
    }
    return new ControllerInjectValueData<>(index, name, type, scopeAnnotations, qualifierAnnotations);
}
 
开发者ID:Diorite,项目名称:Diorite,代码行数:22,代码来源:Controller.java


示例3: buildMatch

import net.bytebuddy.description.NamedElement; //导入依赖的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);
}
 
开发者ID:apache,项目名称:incubator-skywalking,代码行数:17,代码来源:PluginFinder.java


示例4: locate

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
@Override
public Resolution locate(String typeName) throws IOException {
    int packageIndex = typeName.lastIndexOf('.');
    ClassFileLocator classFileLocator = classFileLocators.get(packageIndex == -1
            ? NamedElement.EMPTY_NAME
            : typeName.substring(0, packageIndex));
    return classFileLocator == null
            ? new Resolution.Illegal(typeName)
            : classFileLocator.locate(typeName);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:11,代码来源:ClassFileLocator.java


示例5: testIsNamed

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
@Test
public void testIsNamed() throws Exception {
    NamedElement.WithOptionalName namedElement = mock(NamedElement.WithOptionalName.class);
    assertThat(ElementMatchers.isNamed().matches(namedElement), is(false));
    when(namedElement.isNamed()).thenReturn(true);
    assertThat(ElementMatchers.isNamed().matches(namedElement), is(true));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:8,代码来源:ElementMatchersTest.java


示例6: testMatch

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
@Test
public void testMatch() throws Exception {
    when(nameMatcher.matches(FOO)).thenReturn(true);
    assertThat(new NameMatcher<NamedElement>(nameMatcher).matches(namedElement), is(true));
    verify(nameMatcher).matches(FOO);
    verifyNoMoreInteractions(nameMatcher);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:8,代码来源:NameMatcherTest.java


示例7: testNoMatch

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
@Test
public void testNoMatch() throws Exception {
    when(nameMatcher.matches(FOO)).thenReturn(false);
    assertThat(new NameMatcher<NamedElement>(nameMatcher).matches(namedElement), is(false));
    verify(nameMatcher).matches(FOO);
    verifyNoMoreInteractions(nameMatcher);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:8,代码来源:NameMatcherTest.java


示例8: setUp

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    when(foo.locate(FOO + "." + BAR)).thenReturn(fooResulution);
    when(bar.locate(BAR)).thenReturn(barResolution);
    Map<String, ClassFileLocator> map = new HashMap<String, ClassFileLocator>();
    map.put(FOO, foo);
    map.put(NamedElement.EMPTY_NAME, bar);
    classFileLocator = new ClassFileLocator.PackageDiscriminating(map);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:10,代码来源:ClassFileLocatorPackageDiscriminatingTest.java


示例9: inPlugins

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
public <T extends NamedElement> ElementMatcher.Junction<T> inPlugins() {
    return new NameMatcher(new PluginMathers(pluginManager));
}
 
开发者ID:superbiger,项目名称:sbiger-apm,代码行数:4,代码来源:AgentBoot.java


示例10: geTypeMatchers

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
private static Junction<NamedElement> geTypeMatchers() {

		// TODO: try that instead: type(any(), not(isBootstrapClassLoader()))
		return not(nameStartsWith("java").or(nameStartsWith("sun")).or(nameStartsWith("javax"))
				.or(nameStartsWith("com.sun")));
	}
 
开发者ID:YoannBuch,项目名称:DependencyInjectionAgent,代码行数:7,代码来源:DIAgent.java


示例11: testMatch

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
@Test
public void testMatch() throws Exception {
    when(namedElement.isNamed()).thenReturn(true);
    assertThat(new IsNamedMatcher<NamedElement.WithOptionalName>().matches(namedElement), is(true));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:6,代码来源:IsNamedMatcherTest.java


示例12: testPositiveToNegative

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
@Test
public void testPositiveToNegative() throws Exception {
    assertThat(new IsNamedMatcher<NamedElement.WithOptionalName>().matches(namedElement), is(false));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:5,代码来源:IsNamedMatcherTest.java


示例13: testTypeEmptyEndName

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testTypeEmptyEndName() throws Exception {
    makePlainInstrumentedType().withName(NamedElement.EMPTY_NAME).validated();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:5,代码来源:InstrumentedTypeDefaultTest.java


示例14: isVariable

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
/**
 * Matches a type variable with the given name.
 *
 * @param matcher A matcher for the type variable's name.
 * @param <T>     The type of the matched object.
 * @return A matcher that matches type variables with the given name.
 */
public static <T extends TypeDefinition> ElementMatcher.Junction<T> isVariable(ElementMatcher<? super NamedElement> matcher) {
    return new TypeSortMatcher<T>(anyOf(TypeDefinition.Sort.VARIABLE, TypeDefinition.Sort.VARIABLE_SYMBOLIC)).and(matcher);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:11,代码来源:ElementMatchers.java


示例15: named

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
/**
 * Matches a {@link NamedElement} for its exact name.
 *
 * @param name The expected name.
 * @param <T>  The type of the matched object.
 * @return An element matcher for a named element's exact name.
 */
public static <T extends NamedElement> ElementMatcher.Junction<T> named(String name) {
    return new NameMatcher<T>(new StringMatcher(name, StringMatcher.Mode.EQUALS_FULLY));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:11,代码来源:ElementMatchers.java


示例16: namedIgnoreCase

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
/**
 * Matches a {@link NamedElement} for its name. The name's
 * capitalization is ignored.
 *
 * @param name The expected name.
 * @param <T>  The type of the matched object.
 * @return An element matcher for a named element's name.
 */
public static <T extends NamedElement> ElementMatcher.Junction<T> namedIgnoreCase(String name) {
    return new NameMatcher<T>(new StringMatcher(name, StringMatcher.Mode.EQUALS_FULLY_IGNORE_CASE));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:12,代码来源:ElementMatchers.java


示例17: nameStartsWith

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
/**
 * Matches a {@link NamedElement} for its name's prefix.
 *
 * @param prefix The expected name's prefix.
 * @param <T>    The type of the matched object.
 * @return An element matcher for a named element's name's prefix.
 */
public static <T extends NamedElement> ElementMatcher.Junction<T> nameStartsWith(String prefix) {
    return new NameMatcher<T>(new StringMatcher(prefix, StringMatcher.Mode.STARTS_WITH));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:11,代码来源:ElementMatchers.java


示例18: nameStartsWithIgnoreCase

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
/**
 * Matches a {@link NamedElement} for its name's prefix. The name's
 * capitalization is ignored.
 *
 * @param prefix The expected name's prefix.
 * @param <T>    The type of the matched object.
 * @return An element matcher for a named element's name's prefix.
 */
public static <T extends NamedElement> ElementMatcher.Junction<T> nameStartsWithIgnoreCase(String prefix) {
    return new NameMatcher<T>(new StringMatcher(prefix, StringMatcher.Mode.STARTS_WITH_IGNORE_CASE));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:12,代码来源:ElementMatchers.java


示例19: nameEndsWith

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
/**
 * Matches a {@link NamedElement} for its name's suffix.
 *
 * @param suffix The expected name's suffix.
 * @param <T>    The type of the matched object.
 * @return An element matcher for a named element's name's suffix.
 */
public static <T extends NamedElement> ElementMatcher.Junction<T> nameEndsWith(String suffix) {
    return new NameMatcher<T>(new StringMatcher(suffix, StringMatcher.Mode.ENDS_WITH));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:11,代码来源:ElementMatchers.java


示例20: nameEndsWithIgnoreCase

import net.bytebuddy.description.NamedElement; //导入依赖的package包/类
/**
 * Matches a {@link NamedElement} for its name's suffix. The name's
 * capitalization is ignored.
 *
 * @param suffix The expected name's suffix.
 * @param <T>    The type of the matched object.
 * @return An element matcher for a named element's name's suffix.
 */
public static <T extends NamedElement> ElementMatcher.Junction<T> nameEndsWithIgnoreCase(String suffix) {
    return new NameMatcher<T>(new StringMatcher(suffix, StringMatcher.Mode.ENDS_WITH_IGNORE_CASE));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:12,代码来源:ElementMatchers.java



注:本文中的net.bytebuddy.description.NamedElement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileTextureData类代码示例发布时间:2022-05-23
下一篇:
Java DeleteType类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap