Search in sources :

Example 1 with AnnotationImpl

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();
}
Also used : AnnotationImpl(javassist.bytecode.annotation.AnnotationImpl)

Example 2 with AnnotationImpl

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() + "'");
}
Also used : CtClass(javassist.CtClass) GwtTestRpcException(com.googlecode.gwt.test.exceptions.GwtTestRpcException) StringMemberValue(javassist.bytecode.annotation.StringMemberValue) AnnotationImpl(javassist.bytecode.annotation.AnnotationImpl) RemoteServiceRelativePath(com.google.gwt.user.client.rpc.RemoteServiceRelativePath)

Aggregations

AnnotationImpl (javassist.bytecode.annotation.AnnotationImpl)2 RemoteServiceRelativePath (com.google.gwt.user.client.rpc.RemoteServiceRelativePath)1 GwtTestRpcException (com.googlecode.gwt.test.exceptions.GwtTestRpcException)1 CtClass (javassist.CtClass)1 StringMemberValue (javassist.bytecode.annotation.StringMemberValue)1