本文整理汇总了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);
}
};
}
示例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());
}
}
示例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));
}
示例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());
}
示例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)
));
}