Hibernate SVN: r17021 - beanvalidation/trunk/validation-api/src/main/java/javax/validation.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-07-07 12:46:18 -0400 (Tue, 07 Jul 2009)
New Revision: 17021
Removed:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/PathBuilder.java
Log:
remove PathBuilder
Deleted: beanvalidation/trunk/validation-api/src/main/java/javax/validation/PathBuilder.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/PathBuilder.java 2009-07-07 16:38:30 UTC (rev 17020)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/PathBuilder.java 2009-07-07 16:46:18 UTC (rev 17021)
@@ -1,149 +0,0 @@
-package javax.validation;
-
-/**
- * Define a fluent API to build a Path object and define
- * its sub nodes.
- * A Path object accepted by a given Bean Validation provider
- * must be built by a PathBuilder provided by this Bean
- * Validation provider. In other words, Path implementations
- * are not portable across implementations.
- *
- * <pre>PathBuilder builder = ...;
- * // addresses["home"].inhabitants[].lastname
- * Path path = builder.path("addresses")
- * .addSubNode("inhabitants")
- * .inIterable()
- * .atKey("home")
- * .addSubNode("lastname")
- * .inIterable()
- * .build();
- * </pre>
- *
- * Once a Path object is returned ( by calling #build() ),
- * instances of the fluent API should no longer be used
- * and an IllegalStateException is raised upon any of the
- * method call.
- *
- * @author Emmanuel Bernard
- */
-public interface PathBuilder {
-
- /**
- * Add a subNode to the path.
- *
- * name describes a single property. In particular,
- * dot (.) are not allowed.
- *
- * @param name property
- * @return a builder representing this node
- */
- NodeBuilderDefinedContext addSubNode(String name);
-
- /**
- * Represent a node whose context is known
- * (ie index, key and isInIterable)
- */
- interface NodeBuilderDefinedContext {
-
- /**
- * Add a subNode to the path.
- *
- * <code>name</code> describes a single property. In particular,
- * dot (.) are not allowed.
- *
- * @param name property <code>name</code>
- * @return @return a builder representing node <code>name</code>
- */
- NodeBuilderCustomizableContext addSubNode(String name);
-
- /**
- * Return a Path object whose state is represented by
- * the path builder.
- * Once a Path object is returned ( by calling #build() ),
- * instances of the fluent API should no longer be used
- * and an IllegalStateException is raised upon any of the
- * method call.
- */
- Path build();
- }
-
- /**
- * Represent a subnode whose context is
- * configurable (ie index, key and isInIterable)
- */
- interface NodeBuilderCustomizableContext {
-
- /**
- * Mark the node as being in an Iterable or a Map
- * @return a builder representing iterable details
- */
- NodeContextBuilder inIterable();
-
- /**
- * Add a subNode to the path.
- *
- * <code>name</code> describes a single property. In particular,
- * dot (.) are not allowed.
- *
- * @param name property <code>name</code>
- * @return a builder representing this node
- */
- NodeBuilderCustomizableContext addSubNode(String name);
-
- /**
- * Return a Path object whose state is represented by
- * the path builder.
- * Once a Path object is returned ( by calling #build() ),
- * instances of the fluent API should no longer be used
- * and an IllegalStateException is raised upon any of the
- * method call.
- */
- Path build();
- }
-
- /**
- * Represent refinement choices for a node which is
- * in an Iterator or Map.
- * If the iterator is an indexed collection or a map,
- * the index or the key should be set.
- */
- interface NodeContextBuilder {
-
- /**
- * Define the key the object is into the Map
- *
- * @param key map key
- * @return a builder representing the current node
- */
- NodeBuilderDefinedContext atKey(Object key);
-
- /**
- * Define the index the object is into the List or array
- *
- * @param index index
- * @return a builder representing the current node
- */
- NodeBuilderDefinedContext atIndex(Integer index);
-
- /**
- * Add a subNode to the path.
- *
- * <code>name</code> describes a single property. In particular,
- * dot (.) are not allowed.
- *
- * @param name property <code>name</code>
- * @return a builder representing this node
- */
- NodeBuilderCustomizableContext addSubNode(String name);
-
- /**
- * Return a Path object whose state is represented by
- * the path builder.
- * Once a Path object is returned ( by calling #build() ),
- * instances of the fluent API should no longer be used
- * and an IllegalStateException is raised upon any of the
- * method call.
- */
- Path build();
- }
-}
16 years, 2 months
Hibernate SVN: r17020 - core/trunk.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-07-07 12:38:30 -0400 (Tue, 07 Jul 2009)
New Revision: 17020
Removed:
core/trunk/cache-jbosscache2/
Log:
HHH-4029 - Remove cache-jbosscache2 module
16 years, 2 months
Hibernate SVN: r17019 - in jpamodelgen/trunk: generator/src/main/java/org/hibernate/jpa/metamodel/ap and 8 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-07 12:34:06 -0400 (Tue, 07 Jul 2009)
New Revision: 17019
Added:
jpamodelgen/trunk/generator/src/main/xsd/persistence.xsd
jpamodelgen/trunk/test/src/main/resources/META-INF/persistence.xml
jpamodelgen/trunk/test/src/test/
jpamodelgen/trunk/test/src/test/java/
jpamodelgen/trunk/test/src/test/java/QueryTest.java
Removed:
jpamodelgen/trunk/test/src/main/java/Test.java
jpamodelgen/trunk/test/src/main/java/model/metamodel/
Modified:
jpamodelgen/trunk/generator/pom.xml
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JpaAnnotationsConstants.java
jpamodelgen/trunk/test/pom.xml
Log:
started parsing persistence.xml
Modified: jpamodelgen/trunk/generator/pom.xml
===================================================================
--- jpamodelgen/trunk/generator/pom.xml 2009-07-07 16:33:04 UTC (rev 17018)
+++ jpamodelgen/trunk/generator/pom.xml 2009-07-07 16:34:06 UTC (rev 17019)
@@ -14,16 +14,6 @@
<groupId>org.hibernate.java-persistence</groupId>
<artifactId>jpa-api</artifactId>
</dependency>
-
- <!--
- Test dependencies
- -->
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- <classifier>jdk15</classifier>
- </dependency>
</dependencies>
<build>
<defaultGoal>test</defaultGoal>
Modified: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-07-07 16:33:04 UTC (rev 17018)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-07-07 16:34:06 UTC (rev 17019)
@@ -5,6 +5,7 @@
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
@@ -36,138 +37,119 @@
import org.hibernate.jpa.metamodel.xml.jaxb.Entity;
import org.hibernate.jpa.metamodel.xml.jaxb.EntityMappings;
import org.hibernate.jpa.metamodel.xml.jaxb.ObjectFactory;
+import org.hibernate.jpa.metamodel.xml.jaxb.Persistence;
//@SupportedAnnotationTypes("javax.persistence.Entity")
@SupportedAnnotationTypes("*")
@SupportedSourceVersion(RELEASE_6)
public class JPAMetaModelEntityProcessor extends AbstractProcessor {
- private static final Map<String, IMetaEntity> metaEntities = new HashMap<String, IMetaEntity>();
+ private static final String PATH_SEPARATOR = "/";
+ private static final String PERSISTENCE_XML = "/META-INF/persistence.xml";
- private boolean ormProcessed = false;
+ private final Map<String, IMetaEntity> metaEntities = new HashMap<String, IMetaEntity>();
+ private boolean xmlProcessed = false;
- public JPAMetaModelEntityProcessor() {
- }
-
public void init(ProcessingEnvironment env) {
super.init( env );
processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, "Init Processor " + this );
}
- private void parsingOrmXmls() {
- //make sure that we process ORM files only once per round
- if ( ormProcessed ) {
- return;
+ @Override
+ public boolean process(final Set<? extends TypeElement> annotations,
+ final RoundEnvironment roundEnvironment) {
+
+ if ( roundEnvironment.processingOver() ) {
+ //assuming that when processing is over, we are done and clear resources like ORM parsing
+ //we could keep some ORM parsing in memory but how to detect that a file has changed / not changed?
+ xmlProcessed = false;
+ metaEntities.clear();
+ processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, "Clear ORM processing resources" );
+ return false;
}
- parsingOrmXml( "/META-INF", "orm.xml" );
- //simulate 20 different ORM files to parse
- //Removed since these causes issues in Eclipse APT
- //for (int i = 1 ; i <= 20 ; i++) parsingOrmXml("/model" + i , "orm.xml");
- ormProcessed = true;
- }
+ if ( !processingRoundConstainsEntities( annotations ) ) {
+ processingEnv.getMessager()
+ .printMessage( Diagnostic.Kind.NOTE, "Current processing round does not contain entities" );
+ return true;
+ }
- /**
- * Tries to check whether a orm.xml file exists and parses it using JAXB
- */
- private void parsingOrmXml(String pkg, String name) {
+ writeProcessingDiagnostics( annotations, roundEnvironment );
- InputStream ormStream = getInputStreamForResource( pkg, name );
+ parsePersistenceXml();
- String resource = getFullResourcePath( pkg, name );
- if ( ormStream == null ) {
- processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, resource + " not found." );
- return;
+ Set<? extends Element> elements = roundEnvironment.getRootElements();
+ for ( Element element : elements ) {
+ handleRootElementAnnotationMirrors( element );
}
- try {
- JAXBContext jc = JAXBContext.newInstance( ObjectFactory.class );
- Unmarshaller unmarshaller = jc.createUnmarshaller();
- EntityMappings mappings = ( EntityMappings ) unmarshaller.unmarshal( ormStream );
- Collection<Entity> entities = mappings.getEntity();
- String packageName = mappings.getPackage();
- for ( Entity entity : entities ) {
- String fullyQualifiedClassName = packageName + "." + entity.getClazz();
- Elements utils = processingEnv.getElementUtils();
- XmlMetaEntity metaEntity = new XmlMetaEntity(
- entity, packageName, utils.getTypeElement( fullyQualifiedClassName )
- );
- writeFile( metaEntity );
- // keep track of alreay processed entities
- metaEntities.put( fullyQualifiedClassName, metaEntity );
+ return true;
+ }
+
+ private boolean processingRoundConstainsEntities(Set<? extends TypeElement> annotations) {
+ for ( TypeElement type : annotations ) {
+ if ( type.getQualifiedName().toString().equals( javax.persistence.Entity.class.getName() ) ) {
+ return true;
}
}
- catch ( JAXBException e ) {
- processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, "Error unmarshalling orm.xml" );
- e.printStackTrace();
- }
- catch ( Exception e ) {
- processingEnv.getMessager().printMessage(
- Diagnostic.Kind.ERROR,
- "Problem while reading " + resource + " " + e.getMessage()
- );
- e.printStackTrace();
- //TODO: too bad you can't mark resources as having issues
- }
+ return false;
}
- private InputStream getInputStreamForResource(String pkg, String name) {
- String resource = getFullResourcePath( pkg, name );
- processingEnv.getMessager()
- .printMessage( Diagnostic.Kind.NOTE, "Checking for " + resource );
- InputStream ormStream;
- try {
- FileObject fileObject = processingEnv.getFiler().getResource( StandardLocation.CLASS_OUTPUT, pkg, name );
- ormStream = fileObject.openInputStream();
+ private void parsePersistenceXml() {
+ if ( xmlProcessed ) {
+ return;
}
- catch ( IOException e1 ) {
- processingEnv.getMessager()
- .printMessage(
- Diagnostic.Kind.WARNING,
- "Could not load " + resource + " using Filer.getResource(). Trying classpath..."
- );
- ormStream = this.getClass().getResourceAsStream( resource );
+
+ Persistence persistence = parseXml( PERSISTENCE_XML, Persistence.class );
+
+ if ( persistence != null ) {
+ List<Persistence.PersistenceUnit> persistenceUnits = persistence.getPersistenceUnit();
+ for ( Persistence.PersistenceUnit unit : persistenceUnits ) {
+ List<String> mappingFiles = unit.getMappingFile();
+ for ( String mappingFile : mappingFiles ) {
+ parsingOrmXml( mappingFile );
+ }
+ }
}
- return ormStream;
+ xmlProcessed = true;
}
- private String getFullResourcePath(String pkg, String name) {
- return pkg + "/" + name;
- }
- @Override
- public boolean process(final Set<? extends TypeElement> aAnnotations,
- final RoundEnvironment aRoundEnvironment) {
+ private void parsingOrmXml(String resource) {
- writeInitialProcessingDiagnostics( aAnnotations, aRoundEnvironment );
-
- if ( aRoundEnvironment.processingOver() ) {
- //assuming that when processing is over, we are done and clear resources like ORM parsing
- //we could keep some ORM parsing in memory but how to detect that a file has changed / not changed?
- ormProcessed = false;
- metaEntities.clear();
- processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, "Clear ORM processing resources" );
- return false;
+ EntityMappings mappings = parseXml( resource, EntityMappings.class );
+ if ( mappings == null ) {
+ return;
}
+ Collection<Entity> entities = mappings.getEntity();
+ String packageName = mappings.getPackage();
+ for ( Entity entity : entities ) {
+ String fullyQualifiedClassName = packageName + "." + entity.getClazz();
+ Elements utils = processingEnv.getElementUtils();
+ XmlMetaEntity metaEntity = new XmlMetaEntity(
+ entity, packageName, utils.getTypeElement( fullyQualifiedClassName )
+ );
- parsingOrmXmls();
+ if ( metaEntities.containsKey( fullyQualifiedClassName ) ) {
+ processingEnv.getMessager().printMessage(
+ Diagnostic.Kind.WARNING,
+ fullyQualifiedClassName + " was already processed once. Skipping second occurance."
+ );
+ }
- Set<? extends Element> elements = aRoundEnvironment.getRootElements();
- for ( Element element : elements ) {
- handleRootElementAnnotationMirrors( element );
+ writeFile( metaEntity );
+ metaEntities.put( fullyQualifiedClassName, metaEntity );
}
-
- return true;
}
- private void writeInitialProcessingDiagnostics(Set<? extends TypeElement> aAnnotations, RoundEnvironment aRoundEnvironment) {
+ private void writeProcessingDiagnostics(Set<? extends TypeElement> annotations, RoundEnvironment roundEnvironment) {
StringBuilder sb = new StringBuilder();
sb.append( "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" );
- sb.append( new Date().toLocaleString() );
+ sb.append( new SimpleDateFormat().format( new Date() ) );
sb.append( "\n" );
- sb.append( "Processing annotations " ).append( aAnnotations ).append( " on:" );
+ sb.append( "Processing annotations " ).append( annotations ).append( " on:" );
- Set<? extends Element> elements = aRoundEnvironment.getRootElements();
+ Set<? extends Element> elements = roundEnvironment.getRootElements();
sb.append( "\n" );
for ( Element element : elements ) {
sb.append( element.toString() );
@@ -235,8 +217,10 @@
}
/**
- * Generate everything after import statements
+ * Generate everything after import statements.
*
+ * @param entity The meta entity for which to write the body
+ *
* @return body content
*/
private StringBuffer generateBody(IMetaEntity entity) {
@@ -270,4 +254,79 @@
}
}
}
+
+ private InputStream getInputStreamForResource(String resource) {
+ String pkg = getPackage( resource );
+ String name = getRelativeName( resource );
+ processingEnv.getMessager()
+ .printMessage( Diagnostic.Kind.NOTE, "Checking for " + resource );
+ InputStream ormStream;
+ try {
+ FileObject fileObject = processingEnv.getFiler().getResource( StandardLocation.CLASS_OUTPUT, pkg, name );
+ ormStream = fileObject.openInputStream();
+ }
+ catch ( IOException e1 ) {
+ processingEnv.getMessager()
+ .printMessage(
+ Diagnostic.Kind.WARNING,
+ "Could not load " + resource + " using Filer.getResource(). Trying classpath..."
+ );
+ ormStream = this.getClass().getResourceAsStream( resource );
+ }
+ return ormStream;
+ }
+
+ /**
+ * Tries to open the specified xml file and return an instance of the specified class using JAXB.
+ *
+ * @param resource the xml file name
+ * @param clazz The type of jaxb node to return
+ *
+ * @return The top level jaxb instance contained in the xml file or {@code null} in case the file could not be found.
+ */
+ private <T> T parseXml(String resource, Class<T> clazz) {
+
+ InputStream stream = getInputStreamForResource( resource );
+
+ if ( stream == null ) {
+ processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, resource + " not found." );
+ return null;
+ }
+ try {
+ JAXBContext jc = JAXBContext.newInstance( ObjectFactory.class );
+ Unmarshaller unmarshaller = jc.createUnmarshaller();
+ return clazz.cast( unmarshaller.unmarshal( stream ) );
+ }
+ catch ( JAXBException e ) {
+ processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, "Error unmarshalling " + resource );
+ e.printStackTrace();
+ return null;
+ }
+ catch ( Exception e ) {
+ processingEnv.getMessager().printMessage(
+ Diagnostic.Kind.ERROR,
+ "Problem while reading " + resource + " " + e.getMessage()
+ );
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ private String getPackage(String resourceName) {
+ if ( !resourceName.contains( PATH_SEPARATOR ) ) {
+ return "";
+ }
+ else {
+ return resourceName.substring( 0, resourceName.lastIndexOf( PATH_SEPARATOR ) );
+ }
+ }
+
+ private String getRelativeName(String resourceName) {
+ if ( !resourceName.contains( PATH_SEPARATOR ) ) {
+ return resourceName;
+ }
+ else {
+ return resourceName.substring( resourceName.lastIndexOf( PATH_SEPARATOR ) + 1 );
+ }
+ }
}
Modified: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JpaAnnotationsConstants.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JpaAnnotationsConstants.java 2009-07-07 16:33:04 UTC (rev 17018)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JpaAnnotationsConstants.java 2009-07-07 16:34:06 UTC (rev 17019)
@@ -1,33 +1,27 @@
package org.hibernate.jpa.metamodel.ap;
-public class JpaAnnotationsConstants
-{
- public static final String ANNOTATION_KEY_ALLOCATION_SIZE = "allocationSize()";
- public static final String ANNOTATION_KEY_COLUMN_DEFINITION = "columnDefinition()";
- public static final String ANNOTATION_KEY_DISCRIMINATOR_TYPE =
- "discriminatorType()";
- public static final String ANNOTATION_KEY_INITIAL_VALUE = "initialValue()";
- public static final String ANNOTATION_KEY_GENERATOR = "generator()";
- public static final String ANNOTATION_KEY_INSERTABLE = "insertable()";
- public static final String ANNOTATION_KEY_INVERSE_JOIN_COLUMNS =
- "inverseJoinColumns()";
- public static final String ANNOTATION_KEY_JOIN_COLUMNS = "joinColumns()";
- public static final String ANNOTATION_KEY_LENGTH = "length()";
- public static final String ANNOTATION_KEY_MAPPED_BY = "mappedBy()";
- public static final String ANNOTATION_KEY_NAME = "name()";
- public static final String ANNOTATION_KEY_NULLABLE = "nullable()";
- public static final String ANNOTATION_KEY_QUERY = "query()";
- public static final String ANNOTATION_KEY_REFERENCED_COLUMN_NAME =
- "referencedColumnName()";
- public static final String ANNOTATION_KEY_SEQUENCE_NAME = "sequenceName()";
- public static final String ANNOTATION_KEY_STRATEGY = "strategy()";
- public static final String ANNOTATION_TARGET_ENTITY = "targetEntity()";
- public static final String ANNOTATION_KEY_VALUE = "value()";
-
- public static final String JPA_VERSION = "1.0";
+public class JpaAnnotationsConstants {
+ public static final String ANNOTATION_KEY_ALLOCATION_SIZE = "allocationSize()";
+ public static final String ANNOTATION_KEY_COLUMN_DEFINITION = "columnDefinition()";
+ public static final String ANNOTATION_KEY_DISCRIMINATOR_TYPE = "discriminatorType()";
+ public static final String ANNOTATION_KEY_INITIAL_VALUE = "initialValue()";
+ public static final String ANNOTATION_KEY_GENERATOR = "generator()";
+ public static final String ANNOTATION_KEY_INSERTABLE = "insertable()";
+ public static final String ANNOTATION_KEY_INVERSE_JOIN_COLUMNS = "inverseJoinColumns()";
+ public static final String ANNOTATION_KEY_JOIN_COLUMNS = "joinColumns()";
+ public static final String ANNOTATION_KEY_LENGTH = "length()";
+ public static final String ANNOTATION_KEY_MAPPED_BY = "mappedBy()";
+ public static final String ANNOTATION_KEY_NAME = "name()";
+ public static final String ANNOTATION_KEY_NULLABLE = "nullable()";
+ public static final String ANNOTATION_KEY_QUERY = "query()";
+ public static final String ANNOTATION_KEY_REFERENCED_COLUMN_NAME = "referencedColumnName()";
+ public static final String ANNOTATION_KEY_SEQUENCE_NAME = "sequenceName()";
+ public static final String ANNOTATION_KEY_STRATEGY = "strategy()";
+ public static final String ANNOTATION_TARGET_ENTITY = "targetEntity()";
+ public static final String ANNOTATION_KEY_VALUE = "value()";
- public static final String PROCESSOR_USER_OPTION_XML_OVERRIDE =
- "xmlOverrideAnnotations";
- public static final String PROCESSOR_USER_OPTION_UPPER_COLUMN_NAMES =
- "useUpperCaseColumnNames";
+ public static final String JPA_VERSION = "1.0";
+
+ public static final String PROCESSOR_USER_OPTION_XML_OVERRIDE = "xmlOverrideAnnotations";
+ public static final String PROCESSOR_USER_OPTION_UPPER_COLUMN_NAMES = "useUpperCaseColumnNames";
}
Added: jpamodelgen/trunk/generator/src/main/xsd/persistence.xsd
===================================================================
--- jpamodelgen/trunk/generator/src/main/xsd/persistence.xsd (rev 0)
+++ jpamodelgen/trunk/generator/src/main/xsd/persistence.xsd 2009-07-07 16:34:06 UTC (rev 17019)
@@ -0,0 +1,247 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- persistence.xml schema -->
+<xsd:schema targetNamespace="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:persistence="http://java.sun.com/xml/ns/persistence"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="2.0">
+ <xsd:annotation>
+ <xsd:documentation>
+ @(#)persistence_2_0.xsd 1.0 August 27 2008
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:annotation>
+ <xsd:documentation><![CDATA[
+This is the XML Schema for the persistence configuration file.
+The file must be named "META-INF/persistence.xml" in the
+persistence archive.
+Persistence configuration files must indicate
+the persistence schema by using the persistence namespace:
+http://java.sun.com/xml/ns/persistence
+and indicate the version of the schema by
+using the version element as shown below:
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+version="2.0">
+...
+</persistence>
+]]></xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleType name="versionType">
+ <xsd:restriction base="xsd:token">
+ <xsd:pattern value="[0-9]+(\.[0-9]+)*"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:element name="persistence">
+ <xsd:complexType>
+ <xsd:sequence>
+ <!-- **************************************************** -->
+ <xsd:element name="persistence-unit"
+ minOccurs="1" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:documentation>Configuration of a persistence unit.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <!-- **************************************************** -->
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ Description of this persistence unit.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- **************************************************** -->
+ <xsd:element name="provider" type="xsd:string"
+ minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ Provider class that supplies EntityManagers for this
+ persistence unit.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- **************************************************** -->
+ <xsd:element name="jta-data-source" type="xsd:string"
+ minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ The container-specific name of the JTA datasource to use.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- **************************************************** -->
+ <xsd:element name="non-jta-data-source" type="xsd:string"
+ minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ The container-specific name of a non-JTA datasource to use.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- **************************************************** -->
+ <xsd:element name="mapping-file" type="xsd:string"
+ minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>File containing mapping information. Loaded as a resource
+ by the persistence provider.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- **************************************************** -->
+ <xsd:element name="jar-file" type="xsd:string"
+ minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>
+ Jar file that should be scanned for entities.
+ Not applicable to Java SE persistence units.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- **************************************************** -->
+ <xsd:element name="class" type="xsd:string"
+ minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>
+ Class to scan for annotations. It should be annotated
+ with either @Entity, @Embeddable or @MappedSuperclass.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- **************************************************** -->
+ <xsd:element name="exclude-unlisted-classes" type="xsd:boolean"
+ default="false" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ When set to true then only listed classes and jars will
+ be scanned for persistent classes, otherwise the enclosing
+ jar or directory will also be scanned. Not applicable to
+ Java SE persistence units.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- **************************************************** -->
+ <xsd:element name="caching"
+ type="persistence:persistence-unit-caching-type"
+ minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ Defines whether caching is enabled for the
+ persistence unit if caching is supported by the
+ persistence provider. When set to ALL, all entities
+ will be cached. When set to NONE, no entities will
+ be cached. When set to ENABLE_SELECTIVE, only entities
+ specified as cacheable will be cached. When set toDISABLE_SELECTIVE, entities specified as not cacheable
+ will not be cached.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- **************************************************** -->
+ <xsd:element
+ name="validation-mode"
+ type="persistence:persistence-unit-validation-mode-type"
+ minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ Specifies the validation mode to be used for the
+ persistence unit.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- **************************************************** -->
+ <xsd:element name="properties" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ A list of vendor-specific properties.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="property"
+ minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>
+ A name-value pair.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:attribute name="name" type="xsd:string"
+ use="required"/>
+ <xsd:attribute name="value" type="xsd:string"
+ use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <!-- **************************************************** -->
+ <xsd:attribute name="name" type="xsd:string" use="required">
+ <xsd:annotation>
+ <xsd:documentation>
+ Name used in code to reference this persistence unit.
+ </xsd:documentation>
+ </xsd:annotation></xsd:attribute>
+ <!-- **************************************************** -->
+ <xsd:attribute name="transaction-type"
+ type="persistence:persistence-unit-transaction-type">
+ <xsd:annotation>
+ <xsd:documentation>
+ Type of transactions used by EntityManagers from this
+ persistence unit.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="version" type="persistence:versionType"
+ fixed="2.0" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="persistence-unit-transaction-type">
+ <xsd:annotation>
+ <xsd:documentation>
+ public enum TransactionType { JTA, RESOURCE_LOCAL };
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="JTA"/>
+ <xsd:enumeration value="RESOURCE_LOCAL"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="persistence-unit-caching-type">
+ <xsd:annotation>
+ <xsd:documentation>
+ public enum CachingType { ALL, NONE, ENABLE_SELECTIVE,
+ DISABLE_SELECTIVE};
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="ALL"/>
+ <xsd:enumeration value="NONE"/>
+ <xsd:enumeration value="ENABLE_SELECTIVE"/>
+ <xsd:enumeration value="DISABLE_SELECTIVE"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="persistence-unit-validation-mode-type">
+ <xsd:annotation>
+ <xsd:documentation>public enum ValidationMode { AUTO, CALLBACK, NONE};
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="AUTO"/>
+ <xsd:enumeration value="CALLBACK"/>
+ <xsd:enumeration value="NONE"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+</xsd:schema>
\ No newline at end of file
Modified: jpamodelgen/trunk/test/pom.xml
===================================================================
--- jpamodelgen/trunk/test/pom.xml 2009-07-07 16:33:04 UTC (rev 17018)
+++ jpamodelgen/trunk/test/pom.xml 2009-07-07 16:34:06 UTC (rev 17019)
@@ -17,16 +17,12 @@
<artifactId>hibernate-jpamodel-generator</artifactId>
<version>${version}</version>
</dependency>
-
- <!--
- Test dependencies
- -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <scope>test</scope>
+ <version>5.8</version>
<classifier>jdk15</classifier>
- </dependency>
+ </dependency>
</dependencies>
<build>
<defaultGoal>test</defaultGoal>
Deleted: jpamodelgen/trunk/test/src/main/java/Test.java
===================================================================
--- jpamodelgen/trunk/test/src/main/java/Test.java 2009-07-07 16:33:04 UTC (rev 17018)
+++ jpamodelgen/trunk/test/src/main/java/Test.java 2009-07-07 16:34:06 UTC (rev 17019)
@@ -1,143 +0,0 @@
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.Set;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Expression;
-import javax.persistence.criteria.Join;
-import static javax.persistence.criteria.JoinType.INNER;
-import javax.persistence.criteria.ListJoin;
-import javax.persistence.criteria.Path;
-import javax.persistence.criteria.QueryBuilder;
-import javax.persistence.criteria.Root;
-
-import model.Item;
-import model.Order;
-import model.Product;
-import model.metamodel.Item_;
-import model.metamodel.Order_;
-import model.metamodel.Product_;
-import model.metamodel.Shop_;
-
-/**
- * Writing queries involves passing typesafe, statically cached, metamodel
- * objects to the query builder in order to create the various parts of
- * the query. The typesafe metamodel objects were validated at init time,
- * so it is impossible to build invalid queries in the application code.
- */
-public class Test {
-
- QueryBuilder qb;
-
- public void test() {
- CriteriaQuery q = qb.create();
-
- Root<Order> order = q.from(Order.class);
- Join<Item, Product> product = order.join(Order_.items)
- .join(Item_.product);
-
- Path<BigDecimal> price = product.get(Product_.price);
- Path<Boolean> filled = order.get(Order_.filled);
- Path<Date> date = order.get(Order_.date);
-
- q.select(order, product)
- .where( qb.and( qb.gt(price, 100.00), qb.not(filled) ) )
- .order( qb.asc(price), qb.desc(date) );
- }
-
- public void testUntypesafe() {
- CriteriaQuery q = qb.create();
-
- Root<Order> order = q.from(Order.class);
- Join<Item, Product> product = order.join("items")
- .join("product");
-
- Path<BigDecimal> price = product.get("price");
- Path<Boolean> filled = order.get("filled");
- Path<Date> date = order.get("date");
-
- q.select(order, product)
- .where( qb.and( qb.gt(price, 100.00), qb.not(filled) ) )
- .order( qb.asc(price), qb.desc(date) );
- }
-
- /**
- * Navigation by joining
- */
- public void test2() {
- CriteriaQuery q = qb.create();
-
- Root<Product> product = q.from(Product.class);
- Join<Item, Order> order = product.join(Product_.items)
- .join(Item_.order);
-
- q.select(product)
- .where( qb.equal(order.get(Order_.id), 12345l) );
- }
-
- public void testMap() {
- CriteriaQuery q = qb.create();
-
- Root<Item> item = q.from(Item.class);
- Join<Item, Order> io = item.join(Item_.namedOrders);
-
- }
-
- /**
- * Navigation by compound Path
- */
- public void test3() {
- CriteriaQuery q = qb.create();
-
- Root<Item> item = q.from(Item.class);
- Path<String> shopName = item.get(Item_.order)
- .get(Order_.shop)
- .get(Shop_.name);
- q.select(item)
- .where( qb.equal(shopName, "amazon.com") );
- }
-
-// public void test4() {
-// CriteriaQuery q = qb.create();
-//
-// Root<Order> order = q.from(Order.class);
-// ListJoin<Order, String> note = order.join(Order_.notes);
-// Expression<Set<Item>> items = order.get(Order_.items);
-// order.fetch(Order_.items, JoinType.INNER);
-//
-// q.select(note)
-// .where( qb.and( qb.lt(note.index(), 10), qb.isNotEmpty(items) ) );
-// }
-
- public void test4Untypesafe() {
- CriteriaQuery q = qb.create();
-
- Root<Order> order = q.from(Order.class);
- ListJoin<Order, String> note = order.joinList("notes");
- Expression<Set<Item>> items = order.get("items");
- order.fetch("items", INNER);
-
- q.select(note)
- .where( qb.and( qb.lt(note.index(), 10), qb.isNotEmpty(items) ) );
- }
-
- /*public void test5() {
- Expression<Long> l= null;
- Expression<Integer> i= null;
- Expression<Float> x= null;
- Expression<Float> y= null;
-
- Expression<Number> n;
- Expression<Float> f;
- Expression<String> s = null;
-
- n = qb.quot(l, i);
-
- f = qb.sum(x, y);
-
- n = qb.quot(x, y);
-
- javax.jpa.criteria.Order o = qb.asc(n);
- javax.jpa.criteria.Order p = qb.ascending(s);
- }*/
-
-}
Added: jpamodelgen/trunk/test/src/main/resources/META-INF/persistence.xml
===================================================================
--- jpamodelgen/trunk/test/src/main/resources/META-INF/persistence.xml (rev 0)
+++ jpamodelgen/trunk/test/src/main/resources/META-INF/persistence.xml 2009-07-07 16:34:06 UTC (rev 17019)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence.xsd" version="2.0">
+ <persistence-unit name="annotation-processor" transaction-type="JTA">
+ <description>Test persistence unit</description>
+ <mapping-file>/META-INF/orm.xml</mapping-file>
+ </persistence-unit>
+</persistence>
Copied: jpamodelgen/trunk/test/src/test/java/QueryTest.java (from rev 17010, jpamodelgen/trunk/test/src/main/java/Test.java)
===================================================================
--- jpamodelgen/trunk/test/src/test/java/QueryTest.java (rev 0)
+++ jpamodelgen/trunk/test/src/test/java/QueryTest.java 2009-07-07 16:34:06 UTC (rev 17019)
@@ -0,0 +1,143 @@
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Set;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Expression;
+import javax.persistence.criteria.Join;
+import static javax.persistence.criteria.JoinType.INNER;
+import javax.persistence.criteria.ListJoin;
+import javax.persistence.criteria.Path;
+import javax.persistence.criteria.QueryBuilder;
+import javax.persistence.criteria.Root;
+
+import model.Item;
+import model.Order;
+import model.Product;
+import model.metamodel.Item_;
+import model.metamodel.Order_;
+import model.metamodel.Product_;
+import model.metamodel.Shop_;
+
+/**
+ * Writing queries involves passing typesafe, statically cached, metamodel
+ * objects to the query builder in order to create the various parts of
+ * the query. The typesafe metamodel objects were validated at init time,
+ * so it is impossible to build invalid queries in the application code.
+ */
+public class QueryTest {
+
+ QueryBuilder qb;
+
+ public void test() {
+ CriteriaQuery q = qb.create();
+
+ Root<Order> order = q.from(Order.class);
+ Join<Item, Product> product = order.join(Order_.items)
+ .join(Item_.product);
+
+ Path<BigDecimal> price = product.get(Product_.price);
+ Path<Boolean> filled = order.get(Order_.filled);
+ Path<Date> date = order.get(Order_.date);
+
+ q.select(order, product)
+ .where( qb.and( qb.gt(price, 100.00), qb.not(filled) ) )
+ .order( qb.asc(price), qb.desc(date) );
+ }
+
+ public void testUntypesafe() {
+ CriteriaQuery q = qb.create();
+
+ Root<Order> order = q.from(Order.class);
+ Join<Item, Product> product = order.join("items")
+ .join("product");
+
+ Path<BigDecimal> price = product.get("price");
+ Path<Boolean> filled = order.get("filled");
+ Path<Date> date = order.get("date");
+
+ q.select(order, product)
+ .where( qb.and( qb.gt(price, 100.00), qb.not(filled) ) )
+ .order( qb.asc(price), qb.desc(date) );
+ }
+
+ /**
+ * Navigation by joining
+ */
+ public void test2() {
+ CriteriaQuery q = qb.create();
+
+ Root<Product> product = q.from(Product.class);
+ Join<Item, Order> order = product.join(Product_.items)
+ .join(Item_.order);
+
+ q.select(product)
+ .where( qb.equal(order.get(Order_.id), 12345l) );
+ }
+
+ public void testMap() {
+ CriteriaQuery q = qb.create();
+
+ Root<Item> item = q.from(Item.class);
+ Join<Item, Order> io = item.join(Item_.namedOrders);
+
+ }
+
+ /**
+ * Navigation by compound Path
+ */
+ public void test3() {
+ CriteriaQuery q = qb.create();
+
+ Root<Item> item = q.from(Item.class);
+ Path<String> shopName = item.get(Item_.order)
+ .get(Order_.shop)
+ .get(Shop_.name);
+ q.select(item)
+ .where( qb.equal(shopName, "amazon.com") );
+ }
+
+// public void test4() {
+// CriteriaQuery q = qb.create();
+//
+// Root<Order> order = q.from(Order.class);
+// ListJoin<Order, String> note = order.join(Order_.notes);
+// Expression<Set<Item>> items = order.get(Order_.items);
+// order.fetch(Order_.items, JoinType.INNER);
+//
+// q.select(note)
+// .where( qb.and( qb.lt(note.index(), 10), qb.isNotEmpty(items) ) );
+// }
+
+ public void test4Untypesafe() {
+ CriteriaQuery q = qb.create();
+
+ Root<Order> order = q.from(Order.class);
+ ListJoin<Order, String> note = order.joinList("notes");
+ Expression<Set<Item>> items = order.get("items");
+ order.fetch("items", INNER);
+
+ q.select(note)
+ .where( qb.and( qb.lt(note.index(), 10), qb.isNotEmpty(items) ) );
+ }
+
+ /*public void test5() {
+ Expression<Long> l= null;
+ Expression<Integer> i= null;
+ Expression<Float> x= null;
+ Expression<Float> y= null;
+
+ Expression<Number> n;
+ Expression<Float> f;
+ Expression<String> s = null;
+
+ n = qb.quot(l, i);
+
+ f = qb.sum(x, y);
+
+ n = qb.quot(x, y);
+
+ javax.jpa.criteria.Order o = qb.asc(n);
+ javax.jpa.criteria.Order p = qb.ascending(s);
+ }*/
+
+}
16 years, 2 months
Hibernate SVN: r17018 - in core/trunk: cache-jbosscache2 and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-07-07 12:33:04 -0400 (Tue, 07 Jul 2009)
New Revision: 17018
Added:
core/trunk/cache-jbosscache/pom.xml
Removed:
core/trunk/cache-jbosscache2/pom.xml
Log:
HHH-4028 - Move current cache-jbosscache2 module content to cache-jbosscache
Copied: core/trunk/cache-jbosscache/pom.xml (from rev 17017, core/trunk/cache-jbosscache2/pom.xml)
===================================================================
--- core/trunk/cache-jbosscache/pom.xml (rev 0)
+++ core/trunk/cache-jbosscache/pom.xml 2009-07-07 16:33:04 UTC (rev 17018)
@@ -0,0 +1,161 @@
+<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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-parent</artifactId>
+ <version>3.5.0-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jbosscache2</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Hibernate JBossCache3.x Integration</name>
+ <description>Integration of Hibernate with JBossCache 3 (based on JBossCache2.x+ APIs)</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ <version>3.1.0.GA</version>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-testing</artifactId>
+ <version>${version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.2</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- this is optional on core :( and needed for testing -->
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </testResource>
+ <testResource>
+ <filtering>true</filtering>
+ <directory>src/test/resources</directory>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <!-- Skip a long-running test of a prototype class -->
+ <exclude>**/ClusteredConcurrentTimestampRegionTestCase.java</exclude>
+ </excludes>
+ <systemProperties>
+ <property>
+ <name>hibernate.test.validatefailureexpected</name>
+ <value>true</value>
+ </property>
+ <property>
+ <name>jgroups.bind_addr</name>
+ <value>${jgroups.bind_addr}</value>
+ </property>
+ <!-- There are problems with multicast and IPv6 on some
+ OS/JDK combos, so we tell Java to use IPv4. If you
+ have problems with multicast when running the tests
+ you can try setting this to 'false', although typically
+ that won't be helpful.
+ -->
+ <property>
+ <name>java.net.preferIPv4Stack</name>
+ <value>true</value>
+ </property>
+ <!-- Tell JGroups to only wait a short time for PING
+ responses before determining coordinator. Speeds cluster
+ formation during integration tests. (This is too
+ low a value for a real system; only use for tests.)
+ -->
+ <property>
+ <name>jgroups.ping.timeout</name>
+ <value>500</value>
+ </property>
+ <!-- Tell JGroups to only require one PING response
+ before determining coordinator. Speeds cluster
+ formation during integration tests. (This is too
+ low a value for a real system; only use for tests.)
+ -->
+ <property>
+ <name>jgroups.ping.num_initial_members</name>
+ <value>1</value>
+ </property>
+ <!-- Disable the JGroups message bundling feature
+ to speed tests and avoid FLUSH issue -->
+ <property>
+ <name>jgroups.udp.enable_bundling</name>
+ <value>false</value>
+ </property>
+ </systemProperties>
+ <skipExec>${skipUnitTests}</skipExec>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+ <skipUnitTests>true</skipUnitTests>
+ <!--
+ Following is the default jgroups mcast address. If you find the testsuite runs very slowly, there
+ may be problems with multicast on the interface JGroups uses by default on your machine. You can
+ try to resolve setting 'jgroups.bind_addr' as a system-property to the jvm launching maven and
+ setting the value to an interface where you know multicast works
+ -->
+ <jgroups.bind_addr>127.0.0.1</jgroups.bind_addr>
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>test</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <properties>
+ <skipUnitTests>false</skipUnitTests>
+ </properties>
+ </profile>
+ </profiles>
+</project>
Deleted: core/trunk/cache-jbosscache2/pom.xml
===================================================================
--- core/trunk/cache-jbosscache2/pom.xml 2009-07-07 16:32:02 UTC (rev 17017)
+++ core/trunk/cache-jbosscache2/pom.xml 2009-07-07 16:33:04 UTC (rev 17018)
@@ -1,161 +0,0 @@
-<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/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-jbosscache2</artifactId>
- <packaging>jar</packaging>
-
- <name>Hibernate JBossCache3.x Integration</name>
- <description>Integration of Hibernate with JBossCache 3 (based on JBossCache2.x+ APIs)</description>
-
- <dependencies>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.cache</groupId>
- <artifactId>jbosscache-core</artifactId>
- <version>3.1.0.GA</version>
- </dependency>
-
- <!-- test dependencies -->
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-testing</artifactId>
- <version>${version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <version>1.8.0.2</version>
- <scope>test</scope>
- </dependency>
- <!-- this is optional on core :( and needed for testing -->
- <dependency>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <testResources>
- <testResource>
- <filtering>false</filtering>
- <directory>src/test/java</directory>
- <includes>
- <include>**/*.xml</include>
- </includes>
- </testResource>
- <testResource>
- <filtering>true</filtering>
- <directory>src/test/resources</directory>
- </testResource>
- </testResources>
-
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <!-- Skip a long-running test of a prototype class -->
- <exclude>**/ClusteredConcurrentTimestampRegionTestCase.java</exclude>
- </excludes>
- <systemProperties>
- <property>
- <name>hibernate.test.validatefailureexpected</name>
- <value>true</value>
- </property>
- <property>
- <name>jgroups.bind_addr</name>
- <value>${jgroups.bind_addr}</value>
- </property>
- <!-- There are problems with multicast and IPv6 on some
- OS/JDK combos, so we tell Java to use IPv4. If you
- have problems with multicast when running the tests
- you can try setting this to 'false', although typically
- that won't be helpful.
- -->
- <property>
- <name>java.net.preferIPv4Stack</name>
- <value>true</value>
- </property>
- <!-- Tell JGroups to only wait a short time for PING
- responses before determining coordinator. Speeds cluster
- formation during integration tests. (This is too
- low a value for a real system; only use for tests.)
- -->
- <property>
- <name>jgroups.ping.timeout</name>
- <value>500</value>
- </property>
- <!-- Tell JGroups to only require one PING response
- before determining coordinator. Speeds cluster
- formation during integration tests. (This is too
- low a value for a real system; only use for tests.)
- -->
- <property>
- <name>jgroups.ping.num_initial_members</name>
- <value>1</value>
- </property>
- <!-- Disable the JGroups message bundling feature
- to speed tests and avoid FLUSH issue -->
- <property>
- <name>jgroups.udp.enable_bundling</name>
- <value>false</value>
- </property>
- </systemProperties>
- <skipExec>${skipUnitTests}</skipExec>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <properties>
- <skipUnitTests>true</skipUnitTests>
- <!--
- Following is the default jgroups mcast address. If you find the testsuite runs very slowly, there
- may be problems with multicast on the interface JGroups uses by default on your machine. You can
- try to resolve setting 'jgroups.bind_addr' as a system-property to the jvm launching maven and
- setting the value to an interface where you know multicast works
- -->
- <jgroups.bind_addr>127.0.0.1</jgroups.bind_addr>
- </properties>
-
- <profiles>
- <profile>
- <id>test</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <properties>
- <skipUnitTests>false</skipUnitTests>
- </properties>
- </profile>
- </profiles>
-</project>
16 years, 2 months
Hibernate SVN: r17017 - in core/trunk: cache-jbosscache2 and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-07-07 12:32:02 -0400 (Tue, 07 Jul 2009)
New Revision: 17017
Added:
core/trunk/cache-jbosscache/src/
Removed:
core/trunk/cache-jbosscache2/src/
Log:
HHH-4028 - Move current cache-jbosscache2 module content to cache-jbosscache
Copied: core/trunk/cache-jbosscache/src (from rev 17016, core/trunk/cache-jbosscache2/src)
16 years, 2 months
Hibernate SVN: r17016 - core/trunk/cache-jbosscache.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-07-07 12:27:07 -0400 (Tue, 07 Jul 2009)
New Revision: 17016
Removed:
core/trunk/cache-jbosscache/pom.xml
Log:
HHH-4027 - Remove current cache-jbosscache module content
Deleted: core/trunk/cache-jbosscache/pom.xml
===================================================================
--- core/trunk/cache-jbosscache/pom.xml 2009-07-07 16:26:49 UTC (rev 17015)
+++ core/trunk/cache-jbosscache/pom.xml 2009-07-07 16:27:07 UTC (rev 17016)
@@ -1,87 +0,0 @@
-<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/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-jbosscache</artifactId>
- <packaging>jar</packaging>
-
- <name>Hibernate JBossCache Integration</name>
- <description>Integration of Hibernate with JBossCache (based on JBossCache1.x APIs)</description>
-
- <dependencies>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-cache</artifactId>
- <version>1.4.1.GA</version>
- </dependency>
- <!-- jboss-cache (the one from the jboss repo, anyway) does not properly define its dependencies -->
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-system</artifactId>
- <version>4.0.2</version>
- </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-common</artifactId>
- <version>4.0.2</version>
- </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-minimal</artifactId>
- <version>4.0.2</version>
- </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-j2se</artifactId>
- <version>200504122039</version>
- </dependency>
- <dependency>
- <groupId>concurrent</groupId>
- <artifactId>concurrent</artifactId>
- <version>1.3.4</version>
- </dependency>
- <dependency>
- <groupId>jgroups</groupId>
- <artifactId>jgroups-all</artifactId>
- <version>2.2.7</version>
- </dependency>
-
- <!-- testing deps -->
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-testing</artifactId>
- <version>${version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <version>1.8.0.2</version>
- <scope>test</scope>
- </dependency>
- <!-- these are optional on core... :( -->
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
16 years, 2 months
Hibernate SVN: r17015 - core/trunk/cache-jbosscache.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-07-07 12:26:49 -0400 (Tue, 07 Jul 2009)
New Revision: 17015
Removed:
core/trunk/cache-jbosscache/src/
Log:
HHH-4027 - Remove current cache-jbosscache module content
16 years, 2 months
Hibernate SVN: r17014 - beanvalidation/trunk/validation-api/src/main/java/javax/validation.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-07-07 12:00:50 -0400 (Tue, 07 Jul 2009)
New Revision: 17014
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
Log:
improve slightly CVC.ErrorBuilder based on PathBuilder's experience
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-07-07 13:27:52 UTC (rev 17013)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-07-07 16:00:50 UTC (rev 17014)
@@ -69,15 +69,15 @@
*
* // create new error in the "street" subnode of the default path the constraint is located on
* context.buildErrorWithMessageTemplate( "way too long" )
- * .inSubNode( "street" )
+ * .addSubNode( "street" )
* .addError();
*
* //create new error in the "addresses["home"].city.name subnode of the default path the constraint is located on
* context.buildErrorWithMessageTemplate( "this detail is wrong" )
- * .inSubNode( "addresses" )
- * .inSubNode( "country" )
+ * .addSubNode( "addresses" )
+ * .addSubNode( "country" )
* .inIterable().atKey( "home" )
- * .inSubNode( "name" )
+ * .addSubNode( "name" )
* .addError();
* }
* </pre>
16 years, 2 months
Hibernate SVN: r17013 - in jpamodelgen/trunk: generator/src/main/java/org/hibernate/jpa/metamodel/ap and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-07 09:27:52 -0400 (Tue, 07 Jul 2009)
New Revision: 17013
Added:
jpamodelgen/trunk/test/src/main/java/model/metamodel/
Modified:
jpamodelgen/trunk/generator/
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaEntity.java
jpamodelgen/trunk/test/
jpamodelgen/trunk/test/pom.xml
jpamodelgen/trunk/test/src/main/java/model/Order.java
Log:
Cleanup and made current example work.
Property changes on: jpamodelgen/trunk/generator
___________________________________________________________________
Name: svn:ignore
+ target
Modified: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-07-07 13:05:37 UTC (rev 17012)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-07-07 13:27:52 UTC (rev 17013)
@@ -1,14 +1,24 @@
package org.hibernate.jpa.metamodel.ap;
-
-
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.annotation.Generated;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.FilerException;
+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 java.io.*;
-import java.util.*;
-
-import javax.annotation.Generated;
-import javax.annotation.processing.*;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
@@ -28,209 +38,236 @@
import org.hibernate.jpa.metamodel.xml.jaxb.ObjectFactory;
//@SupportedAnnotationTypes("javax.persistence.Entity")
-@SupportedAnnotationTypes("*") // TODO: this is not very effective
+@SupportedAnnotationTypes("*")
@SupportedSourceVersion(RELEASE_6)
public class JPAMetaModelEntityProcessor extends AbstractProcessor {
- //private static final String ORM_XML_LOCATION = "/META-INF/orm.xml";
+ private static final Map<String, IMetaEntity> metaEntities = new HashMap<String, IMetaEntity>();
- private static final Map<String, IMetaEntity> metaEntities = new HashMap<String, IMetaEntity>();
+ private boolean ormProcessed = false;
- private boolean ormProcessed = false;
+ public JPAMetaModelEntityProcessor() {
+ }
- public JPAMetaModelEntityProcessor() {
- System.out.println("Created Processor " + this);
- }
+ public void init(ProcessingEnvironment env) {
+ super.init( env );
+ processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, "Init Processor " + this );
+ }
- public void init(ProcessingEnvironment env) {
- super.init(env);
- System.out.println("Init Processor " + this);
- }
-
- private void parsingOrmXmls() {
- //make sure that we process ORM files only once per round
- if (ormProcessed) return;
- parsingOrmXml("/META-INF", "orm.xml");
- //simulate 20 different ORM files to parse
- //Removed since these causes issues in Eclipse APT
- //for (int i = 1 ; i <= 20 ; i++) parsingOrmXml("/model" + i , "orm.xml");
-
- ormProcessed = true;
- }
+ private void parsingOrmXmls() {
+ //make sure that we process ORM files only once per round
+ if ( ormProcessed ) {
+ return;
+ }
+ parsingOrmXml( "/META-INF", "orm.xml" );
+ //simulate 20 different ORM files to parse
+ //Removed since these causes issues in Eclipse APT
+ //for (int i = 1 ; i <= 20 ; i++) parsingOrmXml("/model" + i , "orm.xml");
- /**
- * Tries to check whether a orm.xml file exists and parses it using JAXB
- */
- private void parsingOrmXml(String pkg, String name) {
- String resource = pkg +"/"+name;
- processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "XYZ Checking for " + resource);
-
- InputStream ormStream = null;
- try {
- FileObject resource2 = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, pkg, name);
- ormStream = resource2.openInputStream();
- } catch (IOException e1) {
- processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, "Could not locate " + resource + " via APT api");
- //TODO: possible remove this fallback since it should not be needed.
- ormStream = this.getClass().getResourceAsStream(resource);
+ ormProcessed = true;
+ }
+
+ /**
+ * Tries to check whether a orm.xml file exists and parses it using JAXB
+ */
+ private void parsingOrmXml(String pkg, String name) {
+
+ InputStream ormStream = getInputStreamForResource( pkg, name );
+
+ String resource = getFullResourcePath( pkg, name );
+ if ( ormStream == null ) {
+ processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, resource + " not found." );
+ return;
}
-
- if (ormStream == null) {
- processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, resource + " not found.");
- return;
- }
- try {
- JAXBContext jc = JAXBContext.newInstance(ObjectFactory.class);
- Unmarshaller unmarshaller = jc.createUnmarshaller();
- EntityMappings mappings = (EntityMappings) unmarshaller.unmarshal(ormStream);
- Collection<Entity> entities = mappings.getEntity();
- String packageName = mappings.getPackage();
- for (Entity entity : entities) {
- String fullyQualifiedClassName = packageName + "." + entity.getClazz();
- Elements utils = processingEnv.getElementUtils();
- XmlMetaEntity metaEntity = new XmlMetaEntity(entity, packageName, utils.getTypeElement(fullyQualifiedClassName));
- writeFile(metaEntity);
+ try {
+ JAXBContext jc = JAXBContext.newInstance( ObjectFactory.class );
+ Unmarshaller unmarshaller = jc.createUnmarshaller();
+ EntityMappings mappings = ( EntityMappings ) unmarshaller.unmarshal( ormStream );
+ Collection<Entity> entities = mappings.getEntity();
+ String packageName = mappings.getPackage();
+ for ( Entity entity : entities ) {
+ String fullyQualifiedClassName = packageName + "." + entity.getClazz();
+ Elements utils = processingEnv.getElementUtils();
+ XmlMetaEntity metaEntity = new XmlMetaEntity(
+ entity, packageName, utils.getTypeElement( fullyQualifiedClassName )
+ );
+ writeFile( metaEntity );
- // keep track of alreay processed entities
- metaEntities.put(fullyQualifiedClassName, metaEntity);
- }
- } catch (JAXBException e) {
- processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Error unmarshalling orm.xml");
- e.printStackTrace();
- } catch (Exception e) {
- processingEnv.getMessager().printMessage(
- Diagnostic.Kind.ERROR,
- "Problem while reading " + resource + " " + e.getMessage());
- e.printStackTrace();
- //TODO: too bad you can't mark resources as having issues
- }
- }
+ // keep track of alreay processed entities
+ metaEntities.put( fullyQualifiedClassName, metaEntity );
+ }
+ }
+ catch ( JAXBException e ) {
+ processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, "Error unmarshalling orm.xml" );
+ e.printStackTrace();
+ }
+ catch ( Exception e ) {
+ processingEnv.getMessager().printMessage(
+ Diagnostic.Kind.ERROR,
+ "Problem while reading " + resource + " " + e.getMessage()
+ );
+ e.printStackTrace();
+ //TODO: too bad you can't mark resources as having issues
+ }
+ }
- /**
- * Process JPA-specific annotations in Java entity classes.
- *
- * @param aAnnotations Matching annotations to be processed.
- * @param aRoundEnvironment Annotation processing round environment.
- * @return
- */
- @Override
- public boolean process(final Set<? extends TypeElement> aAnnotations,
- final RoundEnvironment aRoundEnvironment) {
+ private InputStream getInputStreamForResource(String pkg, String name) {
+ String resource = getFullResourcePath( pkg, name );
+ processingEnv.getMessager()
+ .printMessage( Diagnostic.Kind.NOTE, "Checking for " + resource );
+ InputStream ormStream;
+ try {
+ FileObject fileObject = processingEnv.getFiler().getResource( StandardLocation.CLASS_OUTPUT, pkg, name );
+ ormStream = fileObject.openInputStream();
+ }
+ catch ( IOException e1 ) {
+ processingEnv.getMessager()
+ .printMessage(
+ Diagnostic.Kind.WARNING,
+ "Could not load " + resource + " using Filer.getResource(). Trying classpath..."
+ );
+ ormStream = this.getClass().getResourceAsStream( resource );
+ }
+ return ormStream;
+ }
- processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Processing annotations:" + aAnnotations);
+ private String getFullResourcePath(String pkg, String name) {
+ return pkg + "/" + name;
+ }
- StringBuilder sb = new StringBuilder("xxx" + new Date().toLocaleString());
- Set<? extends Element> elements = aRoundEnvironment.getRootElements();
- sb.append("\n\n");
- for (Element element : elements) {
- sb.append(element.toString());
- sb.append("\n");
- handleRootElementAnnotationMirrors(element);
- }
+ @Override
+ public boolean process(final Set<? extends TypeElement> aAnnotations,
+ final RoundEnvironment aRoundEnvironment) {
- sb.append("xxx");
- processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, sb.toString());
+ writeInitialProcessingDiagnostics( aAnnotations, aRoundEnvironment );
+ if ( aRoundEnvironment.processingOver() ) {
+ //assuming that when processing is over, we are done and clear resources like ORM parsing
+ //we could keep some ORM parsing in memory but how to detect that a file has changed / not changed?
+ ormProcessed = false;
+ metaEntities.clear();
+ processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, "Clear ORM processing resources" );
+ return false;
+ }
- if (aRoundEnvironment.processingOver()) {
- //assuming that when processing is over, we are done and clear resources like ORM parsing
- //we could keep some ORM parsing in memory but how to detect that a file has changed / not changed?
- ormProcessed = false;
- metaEntities.clear();
- processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Clear ORM processing resources");
- return false;
- }
- parsingOrmXmls();
- for (Element element : elements) {
- handleRootElementAnnotationMirrors(element);
- }
+ parsingOrmXmls();
- return true;
- }
+ Set<? extends Element> elements = aRoundEnvironment.getRootElements();
+ for ( Element element : elements ) {
+ handleRootElementAnnotationMirrors( element );
+ }
- private void handleRootElementAnnotationMirrors(final Element element) {
+ return true;
+ }
- List<? extends AnnotationMirror> annotationMirrors = element
- .getAnnotationMirrors();
+ private void writeInitialProcessingDiagnostics(Set<? extends TypeElement> aAnnotations, RoundEnvironment aRoundEnvironment) {
+ StringBuilder sb = new StringBuilder();
+ sb.append( "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" );
+ sb.append( new Date().toLocaleString() );
+ sb.append( "\n" );
+ sb.append( "Processing annotations " ).append( aAnnotations ).append( " on:" );
- for (AnnotationMirror mirror : annotationMirrors) {
- final String annotationType = mirror.getAnnotationType().toString();
+ Set<? extends Element> elements = aRoundEnvironment.getRootElements();
+ sb.append( "\n" );
+ for ( Element element : elements ) {
+ sb.append( element.toString() );
+ sb.append( "\n" );
+ }
+ sb.append( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" );
+ processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, sb.toString() );
+ }
- if (element.getKind() == ElementKind.CLASS &&
- annotationType.equals(javax.persistence.Entity.class.getName())) {
- MetaEntity metaEntity = new MetaEntity(processingEnv, (TypeElement) element);
- writeFile(metaEntity);
- }
- }
- }
+ private void handleRootElementAnnotationMirrors(final Element element) {
- private void writeFile(IMetaEntity entity) {
+ List<? extends AnnotationMirror> annotationMirrors = element
+ .getAnnotationMirrors();
- try {
- String metaModelPackage = entity.getPackageName();
+ for ( AnnotationMirror mirror : annotationMirrors ) {
+ final String annotationType = mirror.getAnnotationType().toString();
- StringBuffer body = generateBody(entity);
+ if ( element.getKind() == ElementKind.CLASS &&
+ annotationType.equals( javax.persistence.Entity.class.getName() ) ) {
+ MetaEntity metaEntity = new MetaEntity( processingEnv, ( TypeElement ) element );
+ writeFile( metaEntity );
+ }
+ }
+ }
- FileObject fo = processingEnv.getFiler().createSourceFile(
- metaModelPackage + "." + entity.getSimpleName() + "_");
- OutputStream os = fo.openOutputStream();
- PrintWriter pw = new PrintWriter(os);
+ private void writeFile(IMetaEntity entity) {
- pw.println("package " + metaModelPackage + ";");
+ try {
+ String metaModelPackage = entity.getPackageName();
- pw.println();
+ StringBuffer body = generateBody( entity );
- pw.println(entity.generateImports());
+ FileObject fo = processingEnv.getFiler().createSourceFile(
+ metaModelPackage + "." + entity.getSimpleName() + "_"
+ );
+ OutputStream os = fo.openOutputStream();
+ PrintWriter pw = new PrintWriter( os );
- pw.println(body);
+ pw.println( "package " + metaModelPackage + ";" );
- pw.flush();
- pw.close();
+ pw.println();
- } catch (FilerException filerEx) {
- processingEnv.getMessager().printMessage(
- Diagnostic.Kind.ERROR,
- "Problem with Processing Environment Filer: "
- + filerEx.getMessage());
- } catch (IOException ioEx) {
- processingEnv.getMessager().printMessage(
- Diagnostic.Kind.ERROR,
- "Problem opening file to write MetaModel for " + entity.getSimpleName()
- + ioEx.getMessage());
- }
- }
+ pw.println( entity.generateImports() );
- /**
- * Generate everything after import statements
- *
- * @return body content
- */
- private StringBuffer generateBody(IMetaEntity entity) {
+ pw.println( body );
- StringWriter sw = new StringWriter();
- PrintWriter pw = null;
- try {
+ pw.flush();
+ pw.close();
- pw = new PrintWriter(sw);
+ }
+ catch ( FilerException filerEx ) {
+ processingEnv.getMessager().printMessage(
+ Diagnostic.Kind.ERROR,
+ "Problem with Processing Environment Filer: "
+ + filerEx.getMessage()
+ );
+ }
+ catch ( IOException ioEx ) {
+ processingEnv.getMessager().printMessage(
+ Diagnostic.Kind.ERROR,
+ "Problem opening file to write MetaModel for " + entity.getSimpleName()
+ + ioEx.getMessage()
+ );
+ }
+ }
- pw.println("@" + entity.importType(Generated.class.getName()) + "(\"JPA MetaModel for " + entity.getQualifiedName() + "\")");
+ /**
+ * Generate everything after import statements
+ *
+ * @return body content
+ */
+ private StringBuffer generateBody(IMetaEntity entity) {
- pw.println("@" + entity.importType("javax.persistence.metamodel.TypesafeMetamodel") + "(" + entity.getSimpleName() + ".class)");
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = null;
+ try {
- pw.println("public abstract class " + entity.getSimpleName() + "_" + " {");
+ pw = new PrintWriter( sw );
- pw.println();
+ pw.println( "@" + entity.importType( Generated.class.getName() ) + "(\"JPA MetaModel for " + entity.getQualifiedName() + "\")" );
- List<IMetaMember> members = entity.getMembers();
+ pw.println( "@" + entity.importType( "javax.persistence.metamodel.TypesafeMetamodel" ) + "(" + entity.getSimpleName() + ".class)" );
- for (IMetaMember metaMember : members) {
- pw.println(" " + metaMember.getDeclarationString());
- }
- pw.println();
- pw.println("}");
- return sw.getBuffer();
- } finally {
- if (pw != null) pw.close();
- }
- }
+ pw.println( "public abstract class " + entity.getSimpleName() + "_" + " {" );
+
+ pw.println();
+
+ List<IMetaMember> members = entity.getMembers();
+
+ for ( IMetaMember metaMember : members ) {
+ pw.println( " " + metaMember.getDeclarationString() );
+ }
+ pw.println();
+ pw.println( "}" );
+ return sw.getBuffer();
+ }
+ finally {
+ if ( pw != null ) {
+ pw.close();
+ }
+ }
+ }
}
Modified: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaEntity.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaEntity.java 2009-07-07 13:05:37 UTC (rev 17012)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaEntity.java 2009-07-07 13:27:52 UTC (rev 17013)
@@ -1,13 +1,9 @@
package org.hibernate.jpa.metamodel.ap.annotation;
-import org.hibernate.jpa.metamodel.ap.*;
-
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
-
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
@@ -21,197 +17,212 @@
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
import javax.lang.model.util.SimpleTypeVisitor6;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Id;
import javax.tools.Diagnostic.Kind;
+import org.hibernate.jpa.metamodel.ap.IMetaEntity;
+import org.hibernate.jpa.metamodel.ap.IMetaMember;
+import org.hibernate.jpa.metamodel.ap.ImportContext;
+import org.hibernate.jpa.metamodel.ap.ImportContextImpl;
+import org.hibernate.jpa.metamodel.ap.TypeUtils;
+
public class MetaEntity implements IMetaEntity {
- final TypeElement element;
- final protected ProcessingEnvironment pe;
+ final TypeElement element;
+ final protected ProcessingEnvironment pe;
- final ImportContext importContext;
+ final ImportContext importContext;
- public MetaEntity(ProcessingEnvironment pe, TypeElement element) {
- this.element = element;
- this.pe = pe;
- importContext = new ImportContextImpl(getPackageName().toString());
- }
+ public MetaEntity(ProcessingEnvironment pe, TypeElement element) {
+ this.element = element;
+ this.pe = pe;
+ importContext = new ImportContextImpl( getPackageName() );
+ }
- public String getSimpleName() {
- return element.getSimpleName().toString();
- }
+ public String getSimpleName() {
+ return element.getSimpleName().toString();
+ }
- public Element getOriginalElement() {
- return element;
- }
+ public Element getOriginalElement() {
+ return element;
+ }
- public String getQualifiedName() {
- return element.getQualifiedName().toString();
- }
+ public String getQualifiedName() {
+ return element.getQualifiedName().toString();
+ }
- public String getPackageName() {
- PackageElement packageOf = pe.getElementUtils().getPackageOf(element);
- return pe.getElementUtils().getName(packageOf.getQualifiedName() + ".metamodel").toString();
- }
+ public String getPackageName() {
+ PackageElement packageOf = pe.getElementUtils().getPackageOf( element );
+ return pe.getElementUtils().getName( packageOf.getQualifiedName() + ".metamodel" ).toString();
+ }
- public List<IMetaMember> getMembers() {
+ public List<IMetaMember> getMembers() {
- List<IMetaMember> members = new ArrayList<IMetaMember>();
+ List<IMetaMember> members = new ArrayList<IMetaMember>();
- if (useFields()) {
+ if ( useFields() ) {
- List<? extends Element> myMembers = ElementFilter.fieldsIn(element.getEnclosedElements());
+ List<? extends Element> myMembers = ElementFilter.fieldsIn( element.getEnclosedElements() );
- System.out.println("Scanning " + myMembers.size() + " field s for " + element.toString());
+ pe.getMessager()
+ .printMessage( Kind.NOTE, "Scanning " + myMembers.size() + " field s for " + element.toString() );
- for (Element mymember : myMembers) {
+ for ( Element mymember : myMembers ) {
- MetaMember result = mymember.asType().accept(new TypeVisitor(this), mymember);
- if (result != null) {
- members.add(result);
- } else {
- pe.getMessager().printMessage(Kind.WARNING, "Could not find valid info for JPA property", mymember);
- }
- }
+ MetaMember result = mymember.asType().accept( new TypeVisitor( this ), mymember );
+ if ( result != null ) {
+ members.add( result );
+ }
+ else {
+ pe.getMessager()
+ .printMessage( Kind.WARNING, "Could not find valid info for JPA property", mymember );
+ }
+ }
- } else {
+ }
+ else {
- List<? extends Element> myMembers = ElementFilter.methodsIn(element.getEnclosedElements());
+ List<? extends Element> myMembers = ElementFilter.methodsIn( element.getEnclosedElements() );
- System.out.println("Scanning " + myMembers.size() + " methods for " + element.toString());
- for (Element mymember : myMembers) {
+ pe.getMessager()
+ .printMessage( Kind.NOTE, "Scanning " + myMembers.size() + " methods for " + element.toString() );
+ for ( Element mymember : myMembers ) {
- MetaMember result = mymember.asType().accept(new TypeVisitor(this), mymember);
- if (result != null) {
- members.add(result);
- } else {
- //pe.getMessager().printMessage(Kind.WARNING, "Not a valid JPA property", mymember);
- }
- }
+ MetaMember result = mymember.asType().accept( new TypeVisitor( this ), mymember );
+ if ( result != null ) {
+ members.add( result );
+ }
+ else {
+ //pe.getMessager().printMessage(Kind.WARNING, "Not a valid JPA property", mymember);
+ }
+ }
- }
+ }
- if (members.size() == 0) {
- pe.getMessager().printMessage(Kind.WARNING, "No properties found on " + element, element);
- }
- return members;
- }
+ if ( members.size() == 0 ) {
+ pe.getMessager().printMessage( Kind.WARNING, "No properties found on " + element, element );
+ }
+ return members;
+ }
- //TODO: Find more efficient way to identify wether we should use fields or properties
- private boolean useFields() {
- List<? extends Element> myMembers = element.getEnclosedElements();
- for (Element element : myMembers) {
- List<? extends AnnotationMirror> entityAnnotations =
- pe.getElementUtils().getAllAnnotationMirrors(element);
+ //TODO: Find more efficient way to identify wether we should use fields or properties
+ private boolean useFields() {
+ List<? extends Element> myMembers = element.getEnclosedElements();
+ for ( Element element : myMembers ) {
+ List<? extends AnnotationMirror> entityAnnotations =
+ pe.getElementUtils().getAllAnnotationMirrors( element );
- for (Iterator<?> iterator = entityAnnotations.iterator(); iterator
- .hasNext();) {
- AnnotationMirror annotationMirror = (AnnotationMirror) iterator
- .next();
+ for ( Object entityAnnotation : entityAnnotations ) {
+ AnnotationMirror annotationMirror = ( AnnotationMirror ) entityAnnotation;
- final String annotationType = annotationMirror.getAnnotationType().toString();
+ final String annotationType = annotationMirror.getAnnotationType().toString();
- if (annotationType.equals(javax.persistence.Id.class.getName()) ||
- annotationType.equals(javax.persistence.EmbeddedId.class.getName())) {
- if (element.getKind() == ElementKind.FIELD) {
- return true;
- }
- }
- }
- }
+ if ( annotationType.equals( Id.class.getName() ) ||
+ annotationType.equals( EmbeddedId.class.getName() ) ) {
+ if ( element.getKind() == ElementKind.FIELD ) {
+ return true;
+ }
+ }
+ }
+ }
- return false;
- }
+ return false;
+ }
- static Map<String, String> COLLECTIONS = new HashMap<String, String>();
+ static Map<String, String> COLLECTIONS = new HashMap<String, String>();
- static {
- COLLECTIONS.put("java.util.Collection", "javax.persistence.metamodel.Collection");
- COLLECTIONS.put("java.util.Set", "javax.persistence.metamodel.Set");
- COLLECTIONS.put("java.util.List", "javax.persistence.metamodel.List");
- COLLECTIONS.put("java.util.Map", "javax.persistence.metamodel.Map");
- }
+ static {
+ COLLECTIONS.put( "java.util.Collection", "javax.persistence.metamodel.Collection" );
+ COLLECTIONS.put( "java.util.Set", "javax.persistence.metamodel.Set" );
+ COLLECTIONS.put( "java.util.List", "javax.persistence.metamodel.List" );
+ COLLECTIONS.put( "java.util.Map", "javax.persistence.metamodel.Map" );
+ }
- class TypeVisitor extends SimpleTypeVisitor6<MetaMember, Element> {
+ class TypeVisitor extends SimpleTypeVisitor6<MetaMember, Element> {
- MetaEntity parent;
+ MetaEntity parent;
- TypeVisitor(MetaEntity parent) {
- this.parent = parent;
- }
+ TypeVisitor(MetaEntity parent) {
+ this.parent = parent;
+ }
- @Override
- protected MetaMember defaultAction(TypeMirror e, Element p) {
- return super.defaultAction(e, p);
- }
+ @Override
+ protected MetaMember defaultAction(TypeMirror e, Element p) {
+ return super.defaultAction( e, p );
+ }
- @Override
- public MetaMember visitPrimitive(PrimitiveType t, Element p) {
- return new MetaAttribute(parent, p, TypeUtils.toTypeString(t));
- }
+ @Override
+ public MetaMember visitPrimitive(PrimitiveType t, Element p) {
+ return new MetaAttribute( parent, p, TypeUtils.toTypeString( t ) );
+ }
- @Override
- public MetaMember visitDeclared(DeclaredType t, Element p) {
- TypeElement e = (TypeElement) pe.getTypeUtils().asElement(t);
+ @Override
+ public MetaMember visitDeclared(DeclaredType t, Element p) {
+ TypeElement e = ( TypeElement ) pe.getTypeUtils().asElement( t );
- String collection = COLLECTIONS.get(e.getQualifiedName().toString()); // WARNING: .toString() is necessary here since Name equals does not compare to String
- if (collection != null) {
- if (collection.equals("javax.persistence.metamodel.Map")) {
- return new MetaMap(parent, p, collection, getKeyType(t), getElementType(t));
- } else {
- return new MetaCollection(parent, p, collection, getElementType(t));
- }
- } else {
- return new MetaAttribute(parent, p, e.getQualifiedName().toString());
- }
- }
+ String collection = COLLECTIONS.get( e.getQualifiedName().toString() ); // WARNING: .toString() is necessary here since Name equals does not compare to String
+ if ( collection != null ) {
+ if ( collection.equals( "javax.persistence.metamodel.Map" ) ) {
+ return new MetaMap( parent, p, collection, getKeyType( t ), getElementType( t ) );
+ }
+ else {
+ return new MetaCollection( parent, p, collection, getElementType( t ) );
+ }
+ }
+ else {
+ return new MetaAttribute( parent, p, e.getQualifiedName().toString() );
+ }
+ }
- @Override
- public MetaMember visitExecutable(ExecutableType t, Element p) {
- String string = p.getSimpleName().toString();
+ @Override
+ public MetaMember visitExecutable(ExecutableType t, Element p) {
+ String string = p.getSimpleName().toString();
- // TODO: implement proper property get/is/boolean detection
- if (string.startsWith("get") || string.startsWith("is")) {
- TypeMirror returnType = t.getReturnType();
+ // TODO: implement proper property get/is/boolean detection
+ if ( string.startsWith( "get" ) || string.startsWith( "is" ) ) {
+ TypeMirror returnType = t.getReturnType();
- return returnType.accept(this, p);
- } else {
- return null;
- }
- }
- }
+ return returnType.accept( this, p );
+ }
+ else {
+ return null;
+ }
+ }
+ }
- public String generateImports() {
- return importContext.generateImports();
- }
+ public String generateImports() {
+ return importContext.generateImports();
+ }
- public String importType(String fqcn) {
- return importContext.importType(fqcn);
- }
+ public String importType(String fqcn) {
+ return importContext.importType( fqcn );
+ }
- public String staticImport(String fqcn, String member) {
- return importContext.staticImport(fqcn, member);
- }
+ public String staticImport(String fqcn, String member) {
+ return importContext.staticImport( fqcn, member );
+ }
- public String importType(Name qualifiedName) {
- return importType(qualifiedName.toString());
- }
+ public String importType(Name qualifiedName) {
+ return importType( qualifiedName.toString() );
+ }
- private String getKeyType(DeclaredType t) {
- System.out.println("key type" + t);
- return t.getTypeArguments().get(0).toString();
- }
+ private String getKeyType(DeclaredType t) {
+ return t.getTypeArguments().get( 0 ).toString();
+ }
- private String getElementType(DeclaredType declaredType) {
- if (declaredType.getTypeArguments().size() == 1) {
- return declaredType.getTypeArguments().get(0).toString();
- } else {
- return declaredType.getTypeArguments().get(1).toString();
- }
- }
+ private String getElementType(DeclaredType declaredType) {
+ if ( declaredType.getTypeArguments().size() == 1 ) {
+ return declaredType.getTypeArguments().get( 0 ).toString();
+ }
+ else {
+ return declaredType.getTypeArguments().get( 1 ).toString();
+ }
+ }
}
Property changes on: jpamodelgen/trunk/test
___________________________________________________________________
Name: svn:ignore
+ target
Modified: jpamodelgen/trunk/test/pom.xml
===================================================================
--- jpamodelgen/trunk/test/pom.xml 2009-07-07 13:05:37 UTC (rev 17012)
+++ jpamodelgen/trunk/test/pom.xml 2009-07-07 13:27:52 UTC (rev 17013)
@@ -38,18 +38,18 @@
</resources>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
- <id>process__annotations</id>
- <phase>generate-sources</phase>
+ <id>process_annotations</id>
+ <phase>process-resources</phase>
<configuration>
<tasks>
<property name="target.dir" value="target/generated-sources"/>
<mkdir dir="${target.dir}"/>
<javac srcdir="src/main/java" destdir="${target.dir}" failonerror="false">
- <compilerarg value="-proc:only"/>
+ <compilerarg value="-proc:only"/>
<classpath>
<path refid="maven.compile.classpath"/>
</classpath>
@@ -89,7 +89,27 @@
</execution>
</executions>
</plugin>
-
+ <!--plugin>
+ <groupId>org.bsc.maven</groupId>
+ <artifactId>maven-processor-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <id>process</id>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ <phase>generate-sources</phase>
+ <configuration>
+ <outputDirectory>target/generated-sources</outputDirectory>
+ <processors>
+ <processor>org.hibernate.jpa.metamodel.ap.JPAMetaModelEntityProcessor</processor>
+ </processors>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies/>
+ </plugin-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Modified: jpamodelgen/trunk/test/src/main/java/model/Order.java
===================================================================
--- jpamodelgen/trunk/test/src/main/java/model/Order.java 2009-07-07 13:05:37 UTC (rev 17012)
+++ jpamodelgen/trunk/test/src/main/java/model/Order.java 2009-07-07 13:27:52 UTC (rev 17013)
@@ -8,21 +8,21 @@
import java.util.List;
import java.util.Set;
-@Entity
+//@Entity
public class Order {
- @Id
+ //@Id
long id;
- @OneToMany
+ //@OneToMany
Set<Item> items;
boolean filled;
Date date;
- @OneToMany
+ //@OneToMany
List<String> notes;
- @ManyToOne
+ //@ManyToOne
Shop shop;
}
16 years, 2 months
Hibernate SVN: r17012 - beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-07-07 09:05:37 -0400 (Tue, 07 Jul 2009)
New Revision: 17012
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/PathBuilder.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java
Log:
improve slightly CVC.ErrorBuilder based on PathBuilder's experience
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-07-07 12:02:51 UTC (rev 17011)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-07-07 13:05:37 UTC (rev 17012)
@@ -101,12 +101,15 @@
*/
interface ErrorBuilder {
/**
- * Add a subNode to the path the error will be associated to
+ * Add a subNode to the path the error will be associated to.
*
- * @param name property
- * @return a builder representing the first level node
+ * <code>name</code> describes a single property. In particular,
+ * dot (.) are not allowed.
+ *
+ * @param name property name
+ * @return a builder representing node <code>name</code>
*/
- NodeBuilder inSubNode(String name);
+ NodeBuilderDefinedContext addSubNode(String name);
/**
* Add the new error report to be generated if the
@@ -119,24 +122,28 @@
ConstraintValidatorContext addError();
/**
- * Represent asubnode whose context is known
+ * Represent a subnode whose context is known
* (ie index, key and isInIterable)
*/
- interface NodeBuilder {
+ interface NodeBuilderDefinedContext {
+
/**
- * Add a subNode to the path the error will be associated to
+ * Add a subNode to the path the error will be associated to.
*
- * @param name property
+ * <code>name</code> describes a single property. In particular,
+ * dot (.) are not allowed.
+ *
+ * @param name property <code>name</code>
* @return a builder representing this node
*/
- InIterableNodeBuilder inSubNode(String name);
+ NodeBuilderCustomizableContext addSubNode(String name);
/**
* Add the new error report to be generated if the
* constraint validator mark the value as invalid.
* Methods of the ErrorBuilder instance this object comes
* from and the error builder nested
- * objects returns IllegalStateException from now on.
+ * objects returns IllegalStateException after this call.
*
* @return ConstraintValidatorContext instance the ErrorBuilder comes from
*/
@@ -147,27 +154,32 @@
* Represent a subnode whose context is
* configurable (ie index, key and isInIterable)
*/
- interface InIterableNodeBuilder {
+ interface NodeBuilderCustomizableContext {
+
/**
* Mark the node as being in an Iterable or a Map
+ *
* @return a builder representing iterable details
*/
- InIterablePropertiesBuilder inIterable();
+ NodeContextBuilder inIterable();
/**
- * Add a subNode to the path the error will be associated to
+ * Add a subNode to the path the error will be associated to.
*
- * @param name property
+ * <code>name</code> describes a single property. In particular,
+ * dot (.) are not allowed.
+ *
+ * @param name property <code>name</code>
* @return a builder representing this node
*/
- InIterableNodeBuilder inSubNode(String name);
+ NodeBuilderCustomizableContext addSubNode(String name);
/**
* Add the new error report to be generated if the
* constraint validator mark the value as invalid.
* Methods of the ErrorBuilder instance this object comes
* from and the error builder nested
- * objects returns IllegalStateException from now on.
+ * objects returns IllegalStateException after this call.
*
* @return ConstraintValidatorContext instance the ErrorBuilder comes from
*/
@@ -175,19 +187,20 @@
}
/**
- * Represent choices for a node which is
+ * Represent refinement choices for a node which is
* in an Iterator or Map.
* If the iterator is an indexed collection or a map,
* the index or the key should be set.
*/
- interface InIterablePropertiesBuilder {
+ interface NodeContextBuilder {
+
/**
* Define the key the object is into the Map
*
* @param key map key
* @return a builder representing the current node
*/
- NodeBuilder atKey(Object key);
+ NodeBuilderDefinedContext atKey(Object key);
/**
* Define the index the object is into the List or array
@@ -195,22 +208,25 @@
* @param index index
* @return a builder representing the current node
*/
- NodeBuilder atIndex(Integer index);
+ NodeBuilderDefinedContext atIndex(Integer index);
/**
- * Add a subNode to the path the error will be associated to
+ * Add a subNode to the path the error will be associated to.
*
- * @param name property
+ * <code>name</code> describes a single property. In particular,
+ * dot (.) are not allowed.
+ *
+ * @param name property <code>name</code>
* @return a builder representing this node
*/
- InIterableNodeBuilder inSubNode(String name);
+ NodeBuilderCustomizableContext addSubNode(String name);
/**
* Add the new error report to be generated if the
* constraint validator mark the value as invalid.
* Methods of the ErrorBuilder instance this object comes
* from and the error builder nested
- * objects returns IllegalStateException from now on.
+ * objects returns IllegalStateException after this call.
*
* @return ConstraintValidatorContext instance the ErrorBuilder comes from
*/
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/PathBuilder.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/PathBuilder.java 2009-07-07 12:02:51 UTC (rev 17011)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/PathBuilder.java 2009-07-07 13:05:37 UTC (rev 17012)
@@ -37,23 +37,24 @@
* @param name property
* @return a builder representing this node
*/
- PathBuilder.NodeBuilderWithDefinedContext addSubNode(String name);
+ NodeBuilderDefinedContext addSubNode(String name);
/**
* Represent a node whose context is known
* (ie index, key and isInIterable)
*/
- interface NodeBuilderWithDefinedContext {
+ interface NodeBuilderDefinedContext {
+
/**
* Add a subNode to the path.
*
- * name describes a single property. In particular,
+ * <code>name</code> describes a single property. In particular,
* dot (.) are not allowed.
*
- * @param name property
- * @return a builder representing this node
+ * @param name property <code>name</code>
+ * @return @return a builder representing node <code>name</code>
*/
- NodeBuilderWithCustomizableContext addSubNode(String name);
+ NodeBuilderCustomizableContext addSubNode(String name);
/**
* Return a Path object whose state is represented by
@@ -70,7 +71,8 @@
* Represent a subnode whose context is
* configurable (ie index, key and isInIterable)
*/
- interface NodeBuilderWithCustomizableContext {
+ interface NodeBuilderCustomizableContext {
+
/**
* Mark the node as being in an Iterable or a Map
* @return a builder representing iterable details
@@ -80,13 +82,13 @@
/**
* Add a subNode to the path.
*
- * name describes a single property. In particular,
+ * <code>name</code> describes a single property. In particular,
* dot (.) are not allowed.
*
- * @param name property
+ * @param name property <code>name</code>
* @return a builder representing this node
*/
- NodeBuilderWithCustomizableContext addSubNode(String name);
+ NodeBuilderCustomizableContext addSubNode(String name);
/**
* Return a Path object whose state is represented by
@@ -106,13 +108,14 @@
* the index or the key should be set.
*/
interface NodeContextBuilder {
+
/**
* Define the key the object is into the Map
*
* @param key map key
* @return a builder representing the current node
*/
- NodeBuilderWithDefinedContext atKey(Object key);
+ NodeBuilderDefinedContext atKey(Object key);
/**
* Define the index the object is into the List or array
@@ -120,18 +123,18 @@
* @param index index
* @return a builder representing the current node
*/
- NodeBuilderWithDefinedContext atIndex(Integer index);
+ NodeBuilderDefinedContext atIndex(Integer index);
/**
* Add a subNode to the path.
*
- * name describes a single property. In particular,
+ * <code>name</code> describes a single property. In particular,
* dot (.) are not allowed.
*
- * @param name property
+ * @param name property <code>name</code>
* @return a builder representing this node
*/
- NodeBuilderWithCustomizableContext addSubNode(String name);
+ NodeBuilderCustomizableContext addSubNode(String name);
/**
* Return a Path object whose state is represented by
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java 2009-07-07 12:02:51 UTC (rev 17011)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java 2009-07-07 13:05:37 UTC (rev 17012)
@@ -42,7 +42,7 @@
if ( errorMessages != null ) {
for ( Map.Entry<String, String> entry : errorMessages.entrySet() ) {
constraintValidatorContext.buildErrorWithMessageTemplate( entry.getKey() )
- .inSubNode( entry.getValue() ).addError();
+ .addSubNode( entry.getValue() ).addError();
}
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java 2009-07-07 12:02:51 UTC (rev 17011)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java 2009-07-07 13:05:37 UTC (rev 17012)
@@ -96,7 +96,7 @@
propertyPath = path;
}
- public NodeBuilder inSubNode(String name) {
+ public NodeBuilderDefinedContext addSubNode(String name) {
PathImpl path = PathImpl.createNewRootPath();
path.addNode( new NodeImpl( name ) );
return new NodeBuilderImpl( messageTemplate, path );
@@ -108,7 +108,7 @@
}
}
- class NodeBuilderImpl implements ErrorBuilder.NodeBuilder {
+ class NodeBuilderImpl implements ErrorBuilder.NodeBuilderDefinedContext {
String messageTemplate;
PathImpl propertyPath;
@@ -117,7 +117,7 @@
propertyPath = path;
}
- public ErrorBuilder.InIterableNodeBuilder inSubNode(String name) {
+ public ErrorBuilder.NodeBuilderCustomizableContext addSubNode(String name) {
NodeImpl node = new NodeImpl( name );
propertyPath.addNode( node );
return new InIterableNodeBuilderImpl( messageTemplate, propertyPath );
@@ -129,7 +129,7 @@
}
}
- class InIterableNodeBuilderImpl implements ErrorBuilder.InIterableNodeBuilder {
+ class InIterableNodeBuilderImpl implements ErrorBuilder.NodeBuilderCustomizableContext {
String messageTemplate;
PathImpl propertyPath;
@@ -138,11 +138,11 @@
propertyPath = path;
}
- public ErrorBuilder.InIterablePropertiesBuilder inIterable() {
+ public ErrorBuilder.NodeContextBuilder inIterable() {
return new InIterablePropertiesBuilderImpl( messageTemplate, propertyPath );
}
- public ErrorBuilder.InIterableNodeBuilder inSubNode(String name) {
+ public ErrorBuilder.NodeBuilderCustomizableContext addSubNode(String name) {
Path.Node node = new NodeImpl( name );
propertyPath.addNode( node );
return this;
@@ -154,7 +154,7 @@
}
}
- class InIterablePropertiesBuilderImpl implements ErrorBuilder.InIterablePropertiesBuilder {
+ class InIterablePropertiesBuilderImpl implements ErrorBuilder.NodeContextBuilder {
String messageTemplate;
PathImpl propertyPath;
@@ -164,17 +164,17 @@
propertyPath.getLeafNode().setInIterable( true );
}
- public ErrorBuilder.NodeBuilder atKey(Object key) {
+ public ErrorBuilder.NodeBuilderDefinedContext atKey(Object key) {
propertyPath.getLeafNode().setKey( key );
return new NodeBuilderImpl( messageTemplate, propertyPath );
}
- public ErrorBuilder.NodeBuilder atIndex(Integer index) {
+ public ErrorBuilder.NodeBuilderDefinedContext atIndex(Integer index) {
propertyPath.getLeafNode().setIndex( index );
return new NodeBuilderImpl( messageTemplate, propertyPath );
}
- public ErrorBuilder.InIterableNodeBuilder inSubNode(String name) {
+ public ErrorBuilder.NodeBuilderCustomizableContext addSubNode(String name) {
Path.Node node = new NodeImpl( name );
propertyPath.addNode( node );
return new InIterableNodeBuilderImpl( messageTemplate, propertyPath );
16 years, 2 months