use of javassist.bytecode.annotation.AnnotationImpl in project gwt-test-utils by gwt-test-utils.
the class JavassistUtils method getAnnotation.
@SuppressWarnings("unchecked")
public static <T extends Annotation> javassist.bytecode.annotation.Annotation getAnnotation(CtClass ctClass, Class<T> annotationClass) throws ClassNotFoundException {
T proxiedAnnot = (T) ctClass.getAnnotation(annotationClass);
if (proxiedAnnot == null) {
return null;
} else if (!Proxy.isProxyClass(proxiedAnnot.getClass())) {
return null;
}
AnnotationImpl impl = (AnnotationImpl) Proxy.getInvocationHandler(proxiedAnnot);
return impl.getAnnotation();
}
use of javassist.bytecode.annotation.AnnotationImpl in project gwt-test-utils by gwt-test-utils.
the class RemoteServiceCreateHandler method getRemoveServiceRelativePath.
private String getRemoveServiceRelativePath(Class<?> clazz) {
CtClass ctClass = GwtClassPool.getCtClass((clazz));
Object[] annotations = ctClass.getAvailableAnnotations();
for (Object o : annotations) {
if (Proxy.isProxyClass(o.getClass())) {
AnnotationImpl annotation = (AnnotationImpl) Proxy.getInvocationHandler(o);
if (annotation.getTypeName().equals(RemoteServiceRelativePath.class.getName())) {
return ((StringMemberValue) annotation.getAnnotation().getMemberValue("value")).getValue();
}
}
}
throw new GwtTestRpcException("Cannot find the '@" + RemoteServiceRelativePath.class.getSimpleName() + "' annotation on RemoteService interface '" + clazz.getName() + "'");
}
Aggregations