[gatein-issues] [JBoss JIRA] Commented: (GTNPORTAL-66) Processor for the annotations reading groovy templates

Luca Stancapiano (JIRA) jira-events at lists.jboss.org
Thu Nov 12 18:47:05 EST 2009


    [ https://jira.jboss.org/jira/browse/GTNPORTAL-66?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12494413#action_12494413 ] 

Luca Stancapiano commented on GTNPORTAL-66:
-------------------------------------------

I localized the problem. Here I reproduce it:

we have two projects:  

scripting - it contains the annotation processor
--------------------------------------------------------------

[sviluppo at cicius scripting]$ find
.
./target
./target/classes
./src
./src/main
./src/main/java
./src/main/java/org
./src/main/java/org/exoplatform
./src/main/java/org/exoplatform/annotation
./src/main/java/org/exoplatform/annotation/processor
./src/main/java/org/exoplatform/annotation/processor/GroovyAnnotationProcessor.java
./src/main/resources
./src/main/resources/META-INF
./src/main/resources/META-INF/services
./src/main/resources/META-INF/services/javax.annotation.processing.Processor

here the annotation processor:


package org.exoplatform.annotation.processor;

import java.util.Set;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;

@SupportedAnnotationTypes(value = { "org.exoplatform.webui.config.annotation.ComponentConfig" })
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class GroovyAnnotationProcessor extends AbstractProcessor {

	@Override
	public boolean process(Set<? extends TypeElement> annotations,
			RoundEnvironment roundEnv) {
		return true;
	}
}

here the javax.annotation.processing.Processor descriptor file:

org.exoplatform.annotation.processor.GroovyAnnotationProcessor




core - it contains an annotation and an annotated class
-------------------------------------------------------------------------

[sviluppo at cicius core]$ find
.
./target
./target/classes
./src
./src/main
./src/main/java
./src/main/java/org
./src/main/java/org/exoplatform
./src/main/java/org/exoplatform/webui
./src/main/java/org/exoplatform/webui/config
./src/main/java/org/exoplatform/webui/config/annotation
./src/main/java/org/exoplatform/webui/config/annotation/EventConfig.java
./src/main/java/org/exoplatform/webui/event
./src/main/java/org/exoplatform/webui/event/Event.java

Here an annotation:

package org.exoplatform.webui.config.annotation;

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

import org.exoplatform.webui.event.Event.Phase;

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface EventConfig {
   Phase phase() default Phase.PROCESS;
}

and here a class containing a enum (Phase) used in the annotation:

package org.exoplatform.webui.event;


public class Event<T>
{
   static public enum Phase {
      ANY, DECODE, PROCESS, RENDER
   }

}

Here the compiling operations:

[sviluppo at cicius java]$ pwd
/utenze/sviluppo/prova/scripting/src/main/java

[sviluppo at cicius java]$ javac -d ../../../target/classes org/exoplatform/annotation/processor/GroovyAnnotationProcessor.java

[sviluppo at cicius java]$ cd ../../../target/classes
[sviluppo at cicius classes]$ jar cvf exo.portal.component.scripting-3.0.0-CR01-SNAPSHOT.jar *
aggiunto manifesto
la voce META-INF/ sarà ignorata
aggiunta in corso di: META-INF/services/ (in = 0) (out = 0) (archiviato 0%)
aggiunta in corso di: META-INF/services/javax.annotation.processing.Processor (in = 62) (out = 50) (compresso 19%)
aggiunta in corso di: org/ (in = 0) (out = 0) (archiviato 0%)
aggiunta in corso di: org/exoplatform/ (in = 0) (out = 0) (archiviato 0%)
aggiunta in corso di: org/exoplatform/annotation/ (in = 0) (out = 0) (archiviato 0%)
aggiunta in corso di: org/exoplatform/annotation/processor/ (in = 0) (out = 0) (archiviato 0%)
aggiunta in corso di: org/exoplatform/annotation/processor/GroovyAnnotationProcessor.class (in = 819) (out = 434) (compresso 47%)

[sviluppo at cicius java]$ cd ../../../core/src/main/java

[sviluppo at cicius java]$ javac -cp ../../../../scripting/target/classes/exo.portal.component.scripting-3.0.0-CR01-SNAPSHOT.jar org/exoplatform/webui/event/Event.java org/exoplatform/webui/config/annotation/EventConfig.java



org/exoplatform/webui/config/annotation/EventConfig.java:13: incompatible types
found   : org.exoplatform.webui.event.Event.Phase
required: org.exoplatform.webui.event.Event.Phase
   Phase phase() default Phase.PROCESS;
                              ^
1 error


If we put off the 'default Phase.PROCESS;' code, the compile succeed.

if we put off the exo.portal.component.scripting-3.0.0-CR01-SNAPSHOT.jar from the classpath the compile succeed too.

I find strange that there is a different java syntax when you compile a enum together an annotation processor. It could be a javac bug

> Processor for the annotations reading groovy templates
> ------------------------------------------------------
>
>                 Key: GTNPORTAL-66
>                 URL: https://jira.jboss.org/jira/browse/GTNPORTAL-66
>             Project: GateIn Portal
>          Issue Type: Task
>          Components: Common integration
>    Affects Versions: 3.0.0-Beta01, 3.0.0-Beta02
>         Environment: jdk 1.6.0_07, jboss 5.1, mvn 2.2.1
>            Reporter: Luca Stancapiano
>            Priority: Minor
>             Fix For: 3.0.0-CR01
>
>         Attachments: GroovyAnnotationProcessor.java
>
>
> maybe useful a mechanism that validates the groovy templates passed in the org.exoplatform.webui.config.annotation.ComponentConfig annotation declared in the exo.portal.webui.core project.
> This annotation is actually used in the exo.portal.component.dashboard project.
> Using the Pluggable Annotation Processing API for java 6 (here some detail of the technology: http://www.javabeat.net/articles/14-java-60-features-part-2-pluggable-annotation-proce-1.html) we can validate the groovy templates so we are not forced to load them at runtime and we avoid a boring testing navigations.
> The idea is introduce the Pluggable Annotation Processing in the pom.xml so we validate the templates through the 'mvn install' command

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the gatein-issues mailing list