
act.aaa.AnnotationUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of act-aaa Show documentation
Show all versions of act-aaa Show documentation
Provides Authentication/Authorization/Accounting service for Actframework based on osgl-aaa
The newest version!
package act.aaa;
/*-
* #%L
* ACT AAA Plugin
* %%
* Copyright (C) 2015 - 2017 ActFramework
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import org.osgl.util.E;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
/*
* Disclaim: the code is copied from SpringFramework AnnotationUtils
*/
public class AnnotationUtil {
public static A findAnnotation(Class> clazz, Class annotationType) {
E.NPE(clazz, "Class must not be null");
A annotation = clazz.getAnnotation(annotationType);
if (annotation != null) {
return annotation;
}
for (Class> ifc : clazz.getInterfaces()) {
annotation = findAnnotation(ifc, annotationType);
if (annotation != null) {
return annotation;
}
}
if (!Annotation.class.isAssignableFrom(clazz)) {
for (Annotation ann : clazz.getAnnotations()) {
annotation = findAnnotation(ann.annotationType(), annotationType);
if (annotation != null) {
return annotation;
}
}
}
Class> superClass = clazz.getSuperclass();
if (superClass == null || superClass.equals(Object.class)) {
return null;
}
return findAnnotation(superClass, annotationType);
}
public static A findAnnotation(Method m, Class c) {
return m.getAnnotation(c);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy