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


Java MethodInfo.annotations方法代码示例

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


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

示例1: getHttpVerb

import org.jboss.jandex.MethodInfo; //导入方法依赖的package包/类
private String getHttpVerb(MethodInfo method) {
	getLog().debug("Getting http verb from method:");
	getLog().debug(method.name());

	List<AnnotationInstance> methodAnnotations = method.annotations();
	for (AnnotationInstance annotation : methodAnnotations) {
		DotName annotationName = annotation.name();
		if (!annotationName.equals(PATH_ANNOTATION)) {
			if (annotationName.equals(GET_ANNOTATION))
				return "GET ";
			if (annotationName.equals(POST_ANNOTATION))
				return "POST ";
			if (annotationName.equals(PUT_ANNOTATION))
				return "PUT ";
			if (annotationName.equals(DELETE_ANNOTATION))
				return "DELETE ";
			if (annotationName.equals(OPTIONS_ANNOTATION))
				return "OPTIONS ";
			if (annotationName.equals(HEAD_ANNOTATION))
				return "HEAD ";
		}
	}
	return null;
}
 
开发者ID:ContaAzul,项目名称:jaxrs-path-analyzer,代码行数:25,代码来源:PathAnalyzer.java

示例2: createParameterAnnotationMap

import org.jboss.jandex.MethodInfo; //导入方法依赖的package包/类
/**
 * Create a map for parameter annotations. The key id the index (zero based) of the parameter and the
 * value is a list of all annotations.
 * 
 * @param method
 *            Method to create a map for.
 * 
 * @return Map with parameter index (key) and list of annotations (value).
 */
public static Map<Integer, List<AnnotationInstance>> createParameterAnnotationMap(
        final MethodInfo method) {
    final Map<Integer, List<AnnotationInstance>> result = new HashMap<>();
    for (AnnotationInstance ai : method.annotations()) {
        final AnnotationTarget at = ai.target();
        if (at.kind() == AnnotationTarget.Kind.METHOD_PARAMETER) {
            final MethodParameterInfo mp = at.asMethodParameter();
            final int pos = (int) mp.position();
            List<AnnotationInstance> list = result.get(pos);
            if (list == null) {
                list = new ArrayList<>();
                result.put(pos, list);
            }
            list.add(ai);
        }
    }
    return result;
}
 
开发者ID:fuinorg,项目名称:units4j,代码行数:28,代码来源:Utils.java

示例3: containsPathAnnotation

import org.jboss.jandex.MethodInfo; //导入方法依赖的package包/类
private boolean containsPathAnnotation(MethodInfo method) {
	List<AnnotationInstance> annotations = method.annotations();
	for (AnnotationInstance annotation : annotations) {
		DotName annotationName = annotation.name();
		if (annotationName.equals(PATH_ANNOTATION)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:ContaAzul,项目名称:jaxrs-path-analyzer,代码行数:11,代码来源:PathAnalyzer.java

示例4: getProducer

import org.jboss.jandex.MethodInfo; //导入方法依赖的package包/类
private String getProducer(MethodInfo method) {
	getLog().debug("Getting producer from method:");
	getLog().debug(method.name());

	List<AnnotationInstance> methodAnnotations = method.annotations();
	for (AnnotationInstance annotation : methodAnnotations) {
		DotName annotationName = annotation.name();
		if (annotationName.equals(PRODUCES_ANNOTATION)) {
			return "PRODUCES(".concat(getValueFromAnnotation(annotation)).concat(") ");
		}

	}
	return null;
}
 
开发者ID:ContaAzul,项目名称:jaxrs-path-analyzer,代码行数:15,代码来源:PathAnalyzer.java

示例5: getConsumer

import org.jboss.jandex.MethodInfo; //导入方法依赖的package包/类
private String getConsumer(MethodInfo method) {
	getLog().debug("Getting producer from method:");
	getLog().debug(method.name());

	List<AnnotationInstance> methodAnnotations = method.annotations();
	for (AnnotationInstance annotation : methodAnnotations) {
		DotName annotationName = annotation.name();
		if (annotationName.equals(CONSUMES_ANNOTATION))
			return "CONSUMES(".concat(getValueFromAnnotation(annotation)).concat(") ");
	}
	return null;
}
 
开发者ID:ContaAzul,项目名称:jaxrs-path-analyzer,代码行数:13,代码来源:PathAnalyzer.java

示例6: createMethodAnnotationList

import org.jboss.jandex.MethodInfo; //导入方法依赖的package包/类
/**
 * Creates the list of annotations found only on the method (not on parameters).
 * 
 * @param method
 *            Method to create a list for.
 * 
 * @return List of annotations.
 */
public static List<AnnotationInstance> createMethodAnnotationList(final MethodInfo method) {
    final List<AnnotationInstance> result = new ArrayList<>();
    for (AnnotationInstance ai : method.annotations()) {
        final AnnotationTarget at = ai.target();
        if (at.kind() == AnnotationTarget.Kind.METHOD) {
            result.add(ai);
        }
    }
    return result;
}
 
开发者ID:fuinorg,项目名称:units4j,代码行数:19,代码来源:Utils.java

示例7: createMethod

import org.jboss.jandex.MethodInfo; //导入方法依赖的package包/类
static void createMethod(ClassWriter cw, String implName, String clientInterfaceName, MethodInfo method, int lineNum, String baseUrl) {
    MethodVisitor mv;

    {
        mv = cw.visitMethod(ACC_PUBLIC, method.name(), buildMethodDef(method), null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(lineNum++, l0);
        mv.visitLdcInsn(Type.getType(buildTypeDef(clientInterfaceName)));
        mv.visitTypeInsn(NEW, "org/jboss/resteasy/client/jaxrs/ResteasyClientBuilder");
        mv.visitInsn(DUP);
        mv.visitMethodInsn(INVOKESPECIAL, "org/jboss/resteasy/client/jaxrs/ResteasyClientBuilder", "<init>", "()V", false);
        mv.visitMethodInsn(INVOKEVIRTUAL, "org/jboss/resteasy/client/jaxrs/ResteasyClientBuilder", "build", "()Lorg/jboss/resteasy/client/jaxrs/ResteasyClient;", false);
        mv.visitLdcInsn(baseUrl);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLineNumber(lineNum++, l1);
        mv.visitMethodInsn(INVOKEVIRTUAL, "org/jboss/resteasy/client/jaxrs/ResteasyClient", "target", "(Ljava/lang/String;)Lorg/jboss/resteasy/client/jaxrs/ResteasyWebTarget;", false);
        Label l2 = new Label();
        mv.visitLabel(l2);
        mv.visitLineNumber(lineNum - 2, l2);
        mv.visitMethodInsn(INVOKESTATIC, "org/wildfly/swarm/cdi/jaxrsapi/deployment/ProxyBuilder", "builder", "(Ljava/lang/Class;Ljavax/ws/rs/client/WebTarget;)Lorg/wildfly/swarm/cdi/jaxrsapi/deployment/ProxyBuilder;", false);
        Label l3 = new Label();
        mv.visitLabel(l3);
        mv.visitLineNumber(lineNum++, l3);
        mv.visitMethodInsn(INVOKEVIRTUAL, "org/wildfly/swarm/cdi/jaxrsapi/deployment/ProxyBuilder", "build", "()Ljava/lang/Object;", false);
        mv.visitTypeInsn(CHECKCAST, clientInterfaceName.replace('.', '/'));
        for (int i = 1; i <= method.parameters().size(); i++) {
            mv.visitVarInsn(ALOAD, i);
        }
        Label l4 = new Label();
        mv.visitLabel(l4);
        mv.visitLineNumber(lineNum++, l4);
        mv.visitMethodInsn(INVOKEINTERFACE, clientInterfaceName.replace('.', '/'), method.name(), buildMethodDef(method), true);
        Label l5 = new Label();
        mv.visitLabel(l5);
        if (method.returnType().kind().equals(org.jboss.jandex.Type.Kind.VOID)) {
            mv.visitLineNumber(lineNum++, l5);
            mv.visitInsn(RETURN);
        } else {
            mv.visitLineNumber(lineNum - 4, l5);
            mv.visitInsn(ARETURN);
        }
        Label l6 = new Label();
        mv.visitLabel(l6);
        int methodParams = 0;
        mv.visitLocalVariable("this", buildTypeDef(implName), null, l0, l6, methodParams++);
        for (AnnotationInstance anno : method.annotations()) {
            if (anno.name().toString().contains("QueryParam") || anno.name().toString().contains("PathParam")) {
                short position = anno.target().asMethodParameter().position();
                org.jboss.jandex.Type parameterType = anno.target().asMethodParameter().method().parameters().get(position);
                mv.visitLocalVariable(String.valueOf(anno.value().value()), buildTypeDef(parameterType.name().toString()), null, l0, l6, methodParams++);
            }
        }
        mv.visitMaxs(3, methodParams);
        lineNum += 4;
        mv.visitEnd();
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:61,代码来源:ClientServiceFactory.java


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