tags:

views:

11

answers:

1

I defined an annotation as follows

import java.lang.annotation.ElementType
import java.lang.annotation.Inherited
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import java.lang.annotation.Target

/**
* Annotation for any object that exposed a remote interface
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Remote {
String label()
}

and i'm trying to use it this way

import com.yascie.annotation.Remote

@Remote("Bar")  
class Foo {
    String name
    String value
    static String code
}

I keep getting though an error saying that the annotation is missing element label

java.lang.annotation.IncompleteAnnotationException: Remote missing element label

Now when i tried to inspect the annotation object i can see that a label method is available trough a proxy but i can't access it. Any ideas ?

Remote annotation = objectClass.clazz.getAnnotation(Remote.class);
annotation.metaClass.methods.each {println it}

public final java.lang.String $Proxy14.label()
  • ken
+1  A: 

You have two options. If you want to use the @Remote("Bar") syntax then you need to change the label() method to value() since that's the method name for the default property for annotations when the name isn't specified.

If you want it to be called label() though, specify it as @Remote(label="Bar")

Burt Beckwith