當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。