summaryrefslogtreecommitdiff
path: root/container-compiler-plugin/src/main/java/io/trygvis/container/compiler/MyProcessor.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-compiler-plugin/src/main/java/io/trygvis/container/compiler/MyProcessor.java')
-rw-r--r--container-compiler-plugin/src/main/java/io/trygvis/container/compiler/MyProcessor.java31
1 files changed, 24 insertions, 7 deletions
diff --git a/container-compiler-plugin/src/main/java/io/trygvis/container/compiler/MyProcessor.java b/container-compiler-plugin/src/main/java/io/trygvis/container/compiler/MyProcessor.java
index 729a0ee..6843659 100644
--- a/container-compiler-plugin/src/main/java/io/trygvis/container/compiler/MyProcessor.java
+++ b/container-compiler-plugin/src/main/java/io/trygvis/container/compiler/MyProcessor.java
@@ -12,8 +12,10 @@ import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.DeclaredType;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
+import javax.persistence.Entity;
import java.util.HashSet;
import java.util.Set;
@@ -29,16 +31,19 @@ public class MyProcessor implements Processor {
@Override
public Set<String> getSupportedOptions() {
+ System.out.println("io.trygvis.container.compiler.MyProcessor.getSupportedOptions");
return emptySet();
}
@Override
public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.RELEASE_5;
+ System.out.println("io.trygvis.container.compiler.MyProcessor.getSupportedSourceVersion");
+ return SourceVersion.RELEASE_7;
}
@Override
public void init(ProcessingEnvironment processingEnv) {
+ System.out.println("io.trygvis.container.compiler.MyProcessor.init");
this.processingEnv = processingEnv;
elements = processingEnv.getElementUtils();
types = processingEnv.getTypeUtils();
@@ -46,32 +51,44 @@ public class MyProcessor implements Processor {
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
+ System.out.println("io.trygvis.container.compiler.MyProcessor.getCompletions");
return emptyList();
}
@Override
public Set<String> getSupportedAnnotationTypes() {
- return new HashSet<>(asList(Transactional.class.getName(), Log.class.getName()));
+ System.out.println("io.trygvis.container.compiler.MyProcessor.getSupportedAnnotationTypes");
+ return new HashSet<>(asList(
+ Transactional.class.getName(),
+ Log.class.getName(),
+ Entity.class.getName()));
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- Set<? extends Element> transactional = roundEnv.getElementsAnnotatedWith(Transactional.class);
+ System.out.println("io.trygvis.container.compiler.MyProcessor.process");
+ System.out.println("annotations = " + annotations);
+// Set<? extends Element> transactional = roundEnv.getElementsAnnotatedWith(Transactional.class);
TypeElement tx = elements.getTypeElement(Transactional.class.getCanonicalName());
- TypeElement log = elements.getTypeElement(Transactional.class.getCanonicalName());
+ TypeElement log = elements.getTypeElement(Log.class.getCanonicalName());
+ TypeElement entity = elements.getTypeElement(Entity.class.getCanonicalName());
- for (Element element : transactional) {
+ for (Element element : roundEnv.getRootElements()) {
try {
System.out.println("Processing: " + element);
for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
+ DeclaredType annotationType = annotationMirror.getAnnotationType();
- if (types.isSameType(tx.asType(), annotationMirror.getAnnotationType())) {
+ if (types.isSameType(tx.asType(), annotationType)) {
new TransactionalHandler(processingEnv).processTransactional((TypeElement) element);
}
- if (types.isSameType(log.asType(), annotationMirror.getAnnotationType())) {
+ if (types.isSameType(log.asType(), annotationType)) {
new LogHandler(processingEnv).processLog((TypeElement) element);
}
+ if (types.isSameType(entity.asType(), annotationType)) {
+ new EntityHandler(processingEnv).processEntity((TypeElement) element);
+ }
}
} catch (RuntimeException e) {
throw e;