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