Author: hardy.ferentschik
Date: 2009-11-19 03:51:35 -0500 (Thu, 19 Nov 2009)
New Revision: 18009
Added:
validator/trunk/hibernate-validator-annotation-processor/
validator/trunk/hibernate-validator-annotation-processor/pom.xml
validator/trunk/hibernate-validator-annotation-processor/src/
validator/trunk/hibernate-validator-annotation-processor/src/main/
validator/trunk/hibernate-validator-annotation-processor/src/main/java/
validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/
validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/
validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/
validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/
validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/ConstraintValidationProcessor.java
validator/trunk/hibernate-validator-annotation-processor/src/main/resources/
validator/trunk/hibernate-validator-annotation-processor/src/test/
validator/trunk/hibernate-validator-annotation-processor/src/test/java/
validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/
validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/
validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/
validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/
Modified:
validator/trunk/pom.xml
Log:
HV-269 created project shell for the annotation processor
Added: validator/trunk/hibernate-validator-annotation-processor/pom.xml
===================================================================
--- validator/trunk/hibernate-validator-annotation-processor/pom.xml
(rev 0)
+++ validator/trunk/hibernate-validator-annotation-processor/pom.xml 2009-11-19 08:51:35
UTC (rev 18009)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>hibernate-validator-parent</artifactId>
+ <groupId>org.hibernate</groupId>
+ <version>4.0.3-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator-annotation-processor</artifactId>
+ <name>Hibernate Validator Annotation Processor</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.8</version>
+ <classifier>jdk15</classifier>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added:
validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/ConstraintValidationProcessor.java
===================================================================
---
validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/ConstraintValidationProcessor.java
(rev 0)
+++
validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/ConstraintValidationProcessor.java 2009-11-19
08:51:35 UTC (rev 18009)
@@ -0,0 +1,68 @@
+// $Id: JPAMetaModelEntityProcessor.java 17946 2009-11-06 18:23:48Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.ap;
+
+
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Messager;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import static javax.lang.model.SourceVersion.RELEASE_6;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+
+import javax.tools.Diagnostic;
+
+
+/**
+ * Annotation processor for validating Bean Validation constraints.
+ *
+ * @author Hardy Ferentschik
+ */
+@SupportedAnnotationTypes("*")
+@SupportedSourceVersion(RELEASE_6)
+public class ConstraintValidationProcessor extends AbstractProcessor {
+ private static final Boolean ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS =
Boolean.FALSE;
+ private Messager messager;
+
+ public void init(ProcessingEnvironment env) {
+ super.init( env );
+ messager = env.getMessager();
+ messager.printMessage( Diagnostic.Kind.NOTE, "Init Processor " + this );
+ }
+
+ @Override
+ public boolean process(final Set<? extends TypeElement> annotations,
+ final RoundEnvironment roundEnvironment) {
+
+ if ( roundEnvironment.processingOver() ) {
+ messager.printMessage( Diagnostic.Kind.NOTE, "Last processing round." );
+ return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
+ }
+
+ Set<? extends Element> elements = roundEnvironment.getRootElements();
+ for ( Element element : elements ) {
+ messager.printMessage( Diagnostic.Kind.NOTE, "Processing " +
element.toString() );
+ }
+
+ return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
+ }
+}
Modified: validator/trunk/pom.xml
===================================================================
--- validator/trunk/pom.xml 2009-11-19 01:34:35 UTC (rev 18008)
+++ validator/trunk/pom.xml 2009-11-19 08:51:35 UTC (rev 18009)
@@ -40,6 +40,7 @@
<module>hibernate-validator-archetype</module>
<module>hibernate-validator-legacy</module>
<module>hibernate-validator-tck-runner</module>
+ <module>hibernate-validator-annotation-processor</module>
</modules>
<dependencyManagement>