On Dec 22, 8:04 pm, "[email protected]" <[email protected]>
wrote:
> am implementing a generator to generate code using Apache Velocity.
> The question is that you use the JClassType.getMetaData () to get the
> annotations in the code. Some extraction of my code:
> GearsDataStoreGenerator extends Generator{
> public String generate (TreeLogger logger,
> GeneratorContext context, String typeName) throws
> UnableToCompleteException
> { TypeOracle typeOracle = context.getTypeOracle();
> JClassType requestedClass = typeOracle.getType(typeName);
> requestedClass.getMetaData(ANNOTATION_TABLE); // GWT 1.7
> returns the annotation metadata! GWT 2.0 returns nothing!
> ....
> So GWT 1.7 version works perfect. But from version 2.0 stopped
> working. Reading the sources of the method I detected the following
> change:
> GWT 2.0
> @Deprecated
> public final String[][] getMetaData(String tagName) {
> return TypeOracle.NO_STRING_ARR_ARR;
> }
> GWT 1.7
> public abstract String[][] getMetaData(String tagName);
> In the context help of the method, talks about how to replace it:
> ...
> @deprecated
> Javadoc comment metadata has been deprecated in favor of proper Java
> annotations. See HasAnnotations.getAnnotation(Class) for equivalent
> functionality.
> Someone could help me with some example of
> HasAnnotations.getAnnotation
> (Class) ??
> It think I have to use @Target(ElementType.ANNOTATION_TYPE)?
JClassType implements HasAnnotation, so you just have to replace your
call to getMetaData to a call to getAnnotation, replacing the name of
your annotation with its actual class, e.g.
public @interface Table {
String[] value();
}
@Table({ "foo", "bar", "baz" })
public class MyTable { }
JClassType sourceType = ...;
Table tableAnnotation = sourceType.getAnnotation(Table.class);
for (String v : tableAnnotation.value()) {
// will loop over "foo", "bar" and "baz"
}
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.