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


Java Method.getAnnotations方法代码示例

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


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

示例1: findSecurityAttribute

import java.lang.reflect.Method; //导入方法依赖的package包/类
private SecurityAttribute findSecurityAttribute(Method method, Class<?> targetClass)
{
	SecurityAttribute attr = new SecurityAttribute();
	Annotation[] annotations = method.getAnnotations();
	boolean have = addAnnotationAttrs(annotations, attr, targetClass);

	if( !have )
	{
		return null;
	}
	if( DebugSettings.isDebuggingMode() && method.getDeclaringClass().isInterface() )
	{
		LOGGER.error("**************************************************"); //$NON-NLS-1$
		LOGGER.error("Please move these to the implementation:" + method); //$NON-NLS-1$
		LOGGER.error("**************************************************"); //$NON-NLS-1$
	}
	if( attr.getOnCallmode() == OnCallMode.DOMAIN )
	{
		attr.setDomainArg(getDomainObjectParameter(method));
	}
	return attr;
}
 
开发者ID:equella,项目名称:Equella,代码行数:23,代码来源:SecurityAttributeSource.java

示例2: getCompatibleStepNameFrom

import java.lang.reflect.Method; //导入方法依赖的package包/类
private Optional<String> getCompatibleStepNameFrom(Method testMethod) {
    Annotation[] annotations = testMethod.getAnnotations();
    for (Annotation annotation : annotations) {
        if (isACompatibleStep(annotation)) {
            try {
                String annotationType = annotation.annotationType()
                        .getSimpleName();
                String annotatedValue = (String) annotation.getClass()
                        .getMethod("value").invoke(annotation);
                if (StringUtils.isEmpty(annotatedValue)) {
                    return Optional.absent();
                } else {
                    return Optional.of(annotationType + " " + StringUtils
                            .uncapitalize(annotatedValue));
                }

            } catch (Exception ignoredException) {
            }
        }
    }
    return Optional.absent();
}
 
开发者ID:tapack,项目名称:satisfy,代码行数:23,代码来源:SatisfyAnnotatedStepDescription.java

示例3: checkMethodAnnotation

import java.lang.reflect.Method; //导入方法依赖的package包/类
private void checkMethodAnnotation(Class clazz, Method method){
    Map<String, AnnotationClazz> urlMap = (Map<String, AnnotationClazz>) annotationObjectMap.get(AnnotationObjectType.URL);
    if(urlMap == null){
        urlMap = new HashMap<>();
    }
    Annotation[] annotations = method.getAnnotations();
    for (int i=0;i<annotations.length;i++){
        if (annotations[i].annotationType().equals(RequestMapping.class)){
            String uri = ((RequestMapping)annotations[i]).uri();
            HttpMethod.Type type = ((RequestMapping)annotations[i]).method();
            String URI = getURIKey(type, uri);
            AnnotationClazz annotationClazz = AnnotationClazz.builder().clazzName(clazz.getName()).methodName(method.getName()).build();
            urlMap.put(URI, annotationClazz);
        }
    }
    annotationObjectMap.put(AnnotationObjectType.URL, urlMap);
}
 
开发者ID:caoyj1991,项目名称:Core-Java,代码行数:18,代码来源:FrameworkAnnotationResolver.java

示例4: getActionAnnoValue

import java.lang.reflect.Method; //导入方法依赖的package包/类
public static String getActionAnnoValue(Method method) {
    Action actionAnno;
    actionAnno = method.getAnnotation(Action.class);
    if (actionAnno != null) {
        return actionAnno.value();
    }
    Annotation[] annotations = method.getAnnotations();
    for (int i = annotations.length - 1; i >= 0; i--) {
        Annotation anno = annotations[i];
        if (!AnnotationUtil.isActionAnnotation(anno)) {
            continue;
        }
        actionAnno = anno.annotationType().getAnnotation(Action.class);
        if (actionAnno != null) {
            return actionAnno.value();
        }
    }
    return null;
}
 
开发者ID:febit,项目名称:febit,代码行数:20,代码来源:AnnotationUtil.java

示例5: getHttpMethods

import java.lang.reflect.Method; //导入方法依赖的package包/类
public static List<String> getHttpMethods(Method method) {
    List<String> httpMethods = new ArrayList<>();
    String httpMethod = getHttpMethod(method.getAnnotation(HttpMethod.class));
    if (httpMethod != null) {
        httpMethods.add(httpMethod);
    }
    for (Annotation anno : method.getAnnotations()) {
        httpMethod = getHttpMethod(anno);
        if (httpMethod != null) {
            httpMethods.add(httpMethod);
        }
        if (AnnotationUtil.isActionAnnotation(anno)) {
            for (Annotation interAnnotation : anno.annotationType().getAnnotations()) {
                httpMethod = getHttpMethod(interAnnotation);
                if (httpMethod != null) {
                    httpMethods.add(httpMethod);
                }
            }
        }
    }
    return httpMethods;
}
 
开发者ID:febit,项目名称:febit,代码行数:23,代码来源:AnnotationUtil.java

示例6: findAnnotationFromMethod

import java.lang.reflect.Method; //导入方法依赖的package包/类
public static Annotation findAnnotationFromMethod(Method method,
    Class<? extends Annotation> annotation) {
  for (Annotation targetAnnotation : method.getAnnotations()) {
    if (annotation.isAssignableFrom(targetAnnotation.annotationType())) {
      return targetAnnotation;
    } else {
      continue;
    }
  }
  return null;
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:12,代码来源:ReflectUtils.java

示例7: recieve

import java.lang.reflect.Method; //导入方法依赖的package包/类
@Hidden
public void recieve(int port,int paramBufferSize,int maxFileSize) {
    ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
    serverSocketChannel.socket().bind(new InetSocketAddress(port));
    ByteBuffer parameters = ByteBuffer.allocate(paramBufferSize);
    ByteBuffer content = ByteBuffer.allocate(maxFileSize);
    CharBuffer buffer = CharBuffer.allocate(paramBufferSize);
    List < ScheduledFuture > futures = new ArrayList < ScheduledFuture > ();
    ExecutorService executorService = Executors.newFixedThreadPool(maxAgents);
    int currentConnections;
    Method[] methods=servlet.class.getDeclaredMethods();
    List<String> methodNames=new ArrayList<String>();
    ConcurrentHashMap<String,Method> hashMap=new ConcurrentHashMap<String,Method>();
    SocketChannel[] sections;
    for(Method method:methods){
        Annotation[] annotations=method.getAnnotations();
        if(Arrays.asList(annotations).contains(Hidden.class)){
            continue;
        }
        else{
        hashMap.put(method.getName(),method);
        methodNames.add(method.getName());
        }
    }
    Runnable serverThread = () -> {
       /* socketChannel.read(parameters);
        if (params[0].equals("put")) {
            socketChannel.read(content);
            
        }
        buffer = buff.asCharBuffer();
        String str = buffer.toString();
        String[] params = str.split(":");
        if (params[0].equals("put")) {       
            java.nio.file.Path p = Paths.get(tempPath + params[2]);
            Files.write(p, content.array());
            this.put(params);
            Files.delete(p);
        } else if (params[0].equals("get")) {
            ByteBuffer b = this.get(params);
            socketChannel.write(b);
        } else if (params[0].equals("remove")) {
            this.remove(params);
        }
        futures.remove(i);*/
        
    };
    while (acceptingConnections) {
        socketChannel[0] = serverSocketChannel.accept();
        if (socketChannel != null) {
            ScheduledFuture future = executorService.submit(serverThread);
            i = futures.size();
            futures.add(future);
        }
    }
}
 
开发者ID:EventHorizon27,项目名称:dataset-lib,代码行数:57,代码来源:AppServer.java

示例8: Builder

import java.lang.reflect.Method; //导入方法依赖的package包/类
Builder(SuperVolley volley, Method method) {
    this.volley = volley;
    this.method = method;
    this.methodAnnotations = method.getAnnotations();
    this.parameterTypes = method.getGenericParameterTypes();
    this.parameterAnnotationsArray = method.getParameterAnnotations();
}
 
开发者ID:octaware,项目名称:super-volley,代码行数:8,代码来源:ServiceMethod.java

示例9: invokeMethodWithAnnotation

import java.lang.reflect.Method; //导入方法依赖的package包/类
private void invokeMethodWithAnnotation(Object testCase, Class<?> annotation)
        throws IllegalAccessException, InvocationTargetException {
    for (Method m : testCase.getClass().getDeclaredMethods()) {
        for (Annotation a : m.getAnnotations()) {
            if (annotation.isAssignableFrom(a.annotationType())) {
                m.invoke(testCase);
            }
        }
    }
}
 
开发者ID:dryganets,项目名称:vogar,代码行数:11,代码来源:Junit4.java

示例10: add

import java.lang.reflect.Method; //导入方法依赖的package包/类
/** Add {@link MutableMetric} for a method annotated with {@link Metric} */
private void add(Object source, Method method) {
  for (Annotation annotation : method.getAnnotations()) {
    if (!(annotation instanceof Metric)) {
      continue;
    }
    factory.newForMethod(source, method, (Metric) annotation, registry);
    hasAtMetric = true;
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:11,代码来源:MetricsSourceBuilder.java

示例11: checkObject

import java.lang.reflect.Method; //导入方法依赖的package包/类
@Override
public boolean checkObject(Object v) {

    if(Build.VERSION.SDK_INT<Build.VERSION_CODES.JELLY_BEAN_MR1)
        return true;
    if(AgentWebX5Config.WEBVIEW_TYPE== AgentWebX5Config.WEBVIEW_AGENTWEB_SAFE_TYPE)
        return true;
    boolean tag=false;
    Class clazz=v.getClass();

    Method[] mMethods= clazz.getMethods();

    for(Method mMethod:mMethods){

        Annotation[]mAnnotations= mMethod.getAnnotations();

        for(Annotation mAnnotation:mAnnotations){

            if(mAnnotation instanceof JavascriptInterface){
                tag=true;
                break;
            }

        }
        if(tag)
            break;
    }

    return tag;
}
 
开发者ID:Justson,项目名称:AgentWebX5,代码行数:31,代码来源:JsBaseInterfaceHolder.java

示例12: with

import java.lang.reflect.Method; //导入方法依赖的package包/类
public Model with(String... fields) {
    List<String> methods = new ArrayList<>();
    methods.addAll(Arrays.asList(fields));

    Class<? extends Model> iClass = instance().getClass();

    for (Method method : iClass.getMethods()) {
        if (!methods.contains(method.getName())) {
            continue;
        }

        if (method.getAnnotations().length == 0) {
            continue;
        }

        boolean isQueryHandler = false;
        for (Annotation an : method.getAnnotations()) {
            if (an.annotationType().getName().equals(QueryScope.class.getName())) {
                isQueryHandler = true;
                break;
            }
        }

        if (isQueryHandler) {
            try {
                method.setAccessible(true);
                method.invoke(instance(), builder);
            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
                Logger.getLogger(Model.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    return this;
}
 
开发者ID:avaire,项目名称:avaire,代码行数:36,代码来源:Model.java

示例13: getAnnotations

import java.lang.reflect.Method; //导入方法依赖的package包/类
public static Annotation[] getAnnotations(Method method) {
    Method originMethod = null;
    try {
        originMethod = getOriginMethod(method);
        return originMethod.getAnnotations();
    } catch (NoSuchMethodException e) {
         throw new RuntimeException(e);
    }
}
 
开发者ID:omsfuk,项目名称:Samurai,代码行数:10,代码来源:AnnotationUtil.java

示例14: hasAnnotation

import java.lang.reflect.Method; //导入方法依赖的package包/类
public static boolean hasAnnotation(Method method, Class<? extends Annotation> annoClass) {
    if (method.getAnnotation(annoClass) != null) {
        return true;
    }
    for (Annotation anno : method.getAnnotations()) {
        if (!isActionAnnotation(anno)) {
            continue;
        }
        if (anno.annotationType().getAnnotation(annoClass) != null) {
            return true;
        }
    }
    return false;
}
 
开发者ID:febit,项目名称:febit,代码行数:15,代码来源:AnnotationUtil.java

示例15: MinijaxGetterDescriptor

import java.lang.reflect.Method; //导入方法依赖的package包/类
public MinijaxGetterDescriptor(final Method getter) {
    super(getter.getDeclaringClass(), getter.getAnnotatedReturnType(), getter.getAnnotations());
    this.getter = getter;
    propertyName = getter.getName().substring(3, 4).toLowerCase() + getter.getName().substring(4);
}
 
开发者ID:minijax,项目名称:minijax,代码行数:6,代码来源:MinijaxGetterDescriptor.java


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