当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationDescription.Loadable方法代码示例

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


在下文中一共展示了AnnotationDescription.Loadable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: make

import net.bytebuddy.description.annotation.AnnotationDescription; //导入方法依赖的package包/类
@Override
public Advice.OffsetMapping make(ParameterDescription.InDefinedShape target, AnnotationDescription.Loadable<MeterExceptionsFor> annotation, AdviceType adviceType) {
	return new Advice.OffsetMapping() {
		@Override
		public Target resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Context context) {
			final ExceptionMetered exceptionMetered = instrumentedMethod.getDeclaredAnnotations().ofType(ExceptionMetered.class).loadSilent();
			final TypeDescription.ForLoadedType exceptionType = new TypeDescription.ForLoadedType(exceptionMetered.cause());
			return Target.ForStackManipulation.of(exceptionType);
		}
	};
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:12,代码来源:ExceptionMeteredTransformer.java

示例2: make

import net.bytebuddy.description.annotation.AnnotationDescription; //导入方法依赖的package包/类
@Override
public OffsetMapping make(ParameterDescription.InDefinedShape target,
                          AnnotationDescription.Loadable<This> annotation,
                          AdviceType adviceType) {
    if (adviceType.isDelegation() && !annotation.loadSilent().readOnly()) {
        throw new IllegalStateException("Cannot write to this reference for " + target + " in read-only context");
    } else {
        return new ForThisReference(target.getType(), annotation.loadSilent());
    }
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:11,代码来源:Advice.java

示例3: testRightPrioritized

import net.bytebuddy.description.annotation.AnnotationDescription; //导入方法依赖的package包/类
@Test
public void testRightPrioritized() throws Exception {
    AnnotationDescription.Loadable<BindingPriority> lowPriority = AnnotationDescription.ForLoadedAnnotation.of(this.lowPriority);
    when(leftAnnotations.ofType(BindingPriority.class)).thenReturn(lowPriority);
    AnnotationDescription.Loadable<BindingPriority> highPriority = AnnotationDescription.ForLoadedAnnotation.of(this.highPriority);
    when(rightAnnotations.ofType(BindingPriority.class)).thenReturn(highPriority);
    assertThat(BindingPriority.Resolver.INSTANCE.resolve(source, left, right), is(MethodDelegationBinder.AmbiguityResolver.Resolution.RIGHT));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:9,代码来源:BindingPriorityResolverTest.java

示例4: getRequestName

import net.bytebuddy.description.annotation.AnnotationDescription; //导入方法依赖的package包/类
public static String getRequestName(MethodDescription instrumentedMethod) {
	final AnnotationDescription.Loadable<Traced> monitorRequestsLoadable = instrumentedMethod
			.getDeclaredAnnotations()
			.ofType(Traced.class);
	if (monitorRequestsLoadable != null) {
		final Traced traced = monitorRequestsLoadable.loadSilent();
		if (!traced.requestName().isEmpty()) {
			return traced.requestName();
		}
		if (traced.resolveNameAtRuntime()) {
			return null;
		}
	}
	return getBusinessTransationName(instrumentedMethod.getDeclaringType().getTypeName(), instrumentedMethod.getName());
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:16,代码来源:AbstractTracingTransformer.java

示例5: bind

import net.bytebuddy.description.annotation.AnnotationDescription; //导入方法依赖的package包/类
@Override
public ParameterBinding<?> bind(AnnotationDescription.Loadable<S> annotation,
                                MethodDescription source,
                                ParameterDescription target,
                                Implementation.Target implementationTarget,
                                Assigner assigner,
                                Assigner.Typing typing) {
    Object value = bind(annotation, source, target);
    if (value == null) {
        return new ParameterBinding.Anonymous(DefaultValue.of(target.getType()));
    }
    StackManipulation stackManipulation;
    TypeDescription suppliedType;
    if (value instanceof Boolean) {
        stackManipulation = IntegerConstant.forValue((Boolean) value);
        suppliedType = new TypeDescription.ForLoadedType(boolean.class);
    } else if (value instanceof Byte) {
        stackManipulation = IntegerConstant.forValue((Byte) value);
        suppliedType = new TypeDescription.ForLoadedType(byte.class);
    } else if (value instanceof Short) {
        stackManipulation = IntegerConstant.forValue((Short) value);
        suppliedType = new TypeDescription.ForLoadedType(short.class);
    } else if (value instanceof Character) {
        stackManipulation = IntegerConstant.forValue((Character) value);
        suppliedType = new TypeDescription.ForLoadedType(char.class);
    } else if (value instanceof Integer) {
        stackManipulation = IntegerConstant.forValue((Integer) value);
        suppliedType = new TypeDescription.ForLoadedType(int.class);
    } else if (value instanceof Long) {
        stackManipulation = LongConstant.forValue((Long) value);
        suppliedType = new TypeDescription.ForLoadedType(long.class);
    } else if (value instanceof Float) {
        stackManipulation = FloatConstant.forValue((Float) value);
        suppliedType = new TypeDescription.ForLoadedType(float.class);
    } else if (value instanceof Double) {
        stackManipulation = DoubleConstant.forValue((Double) value);
        suppliedType = new TypeDescription.ForLoadedType(double.class);
    } else if (value instanceof String) {
        stackManipulation = new TextConstant((String) value);
        suppliedType = TypeDescription.STRING;
    } else if (value instanceof Class) {
        stackManipulation = ClassConstant.of(new TypeDescription.ForLoadedType((Class<?>) value));
        suppliedType = TypeDescription.CLASS;
    } else if (value instanceof TypeDescription) {
        stackManipulation = ClassConstant.of((TypeDescription) value);
        suppliedType = TypeDescription.CLASS;
    } else if (JavaType.METHOD_HANDLE.getTypeStub().isInstance(value)) {
        stackManipulation = JavaConstant.MethodHandle.ofLoaded(value).asStackManipulation();
        suppliedType = JavaType.METHOD_HANDLE.getTypeStub();
    } else if (value instanceof JavaConstant.MethodHandle) {
        stackManipulation = new JavaConstantValue((JavaConstant.MethodHandle) value);
        suppliedType = JavaType.METHOD_HANDLE.getTypeStub();
    } else if (JavaType.METHOD_TYPE.getTypeStub().isInstance(value)) {
        stackManipulation = new JavaConstantValue(JavaConstant.MethodType.ofLoaded(value));
        suppliedType = JavaType.METHOD_HANDLE.getTypeStub();
    } else if (value instanceof JavaConstant.MethodType) {
        stackManipulation = new JavaConstantValue((JavaConstant.MethodType) value);
        suppliedType = JavaType.METHOD_HANDLE.getTypeStub();
    } else {
        throw new IllegalStateException("Not able to save in class's constant pool: " + value);
    }
    return new ParameterBinding.Anonymous(new StackManipulation.Compound(
            stackManipulation,
            assigner.assign(suppliedType.asGenericType(), target.getType(), typing)
    ));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:67,代码来源:TargetMethodAnnotationDrivenBinder.java


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