[hibernate-commits] Hibernate SVN: r11102 - in branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate: reflection and 5 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Jan 25 08:22:47 EST 2007


Author: nusco
Date: 2007-01-25 08:22:47 -0500 (Thu, 25 Jan 2007)
New Revision: 11102

Modified:
   branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java
   branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java
   branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/ReflectionManager.java
   branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaReflectionManager.java
   branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/TypeEnvironmentFactory.java
   branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/xml/EJB3OverridenAnnotationReader.java
   branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/xml/EJB3ReflectionManager.java
   branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/ClassValidator.java
   branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/event/ValidateEventListener.java
Log:
Cleaning up of dependencies and misc refactorings in X layer.

Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java	2007-01-25 11:41:38 UTC (rev 11101)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java	2007-01-25 13:22:47 UTC (rev 11102)
@@ -162,7 +162,7 @@
 	private static final Log log = LogFactory.getLog( AnnotationBinder.class );
 
 	public static void bindDefaults(ExtendedMappings mappings) {
-		Map defaults = ( (EJB3ReflectionManager) mappings.getReflectionManager() ).getDefaults();
+		Map defaults = mappings.getReflectionManager().getDefaults();
 		{
 			List<SequenceGenerator> anns = (List<SequenceGenerator>) defaults.get( SequenceGenerator.class );
 			if (anns != null) {

Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java	2007-01-25 11:41:38 UTC (rev 11101)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java	2007-01-25 13:22:47 UTC (rev 11102)
@@ -228,7 +228,6 @@
 		hbmDocuments = new ArrayList<Document>();
 		namingStrategy = EJB3NamingStrategy.INSTANCE;
 		setEntityResolver( new EJB3DTDEntityResolver() );
-        // TODO
 		reflectionManager = new EJB3ReflectionManager();
 	}
 

Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/ReflectionManager.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/ReflectionManager.java	2007-01-25 11:41:38 UTC (rev 11101)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/ReflectionManager.java	2007-01-25 13:22:47 UTC (rev 11102)
@@ -2,6 +2,7 @@
 
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Method;
+import java.util.Map;
 
 /**
  * The entry point to the reflection layer (a.k.a. the X* layer).
@@ -24,4 +25,6 @@
 	public <T> boolean equals(XClass class1, Class<T> class2);
 
     public AnnotationReader buildAnnotationReader(AnnotatedElement annotatedElement);
+
+    public Map getDefaults();
 }

Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaReflectionManager.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaReflectionManager.java	2007-01-25 11:41:38 UTC (rev 11101)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaReflectionManager.java	2007-01-25 13:22:47 UTC (rev 11102)
@@ -52,17 +52,6 @@
 
 	private final TypeEnvironmentFactory typeEnvs = new TypeEnvironmentFactory();
 
-	public JavaReflectionManager() {
-		reset();
-	}
-
-	public void reset() {
-		xClasses.clear();
-		packagesToXPackages.clear();
-		xProperties.clear();
-		xMethods.clear();
-	}
-
 	public XClass toXClass(Class clazz) {
 		return toXClass( clazz, IdentityTypeEnvironment.INSTANCE );
 	}
@@ -189,4 +178,8 @@
     public AnnotationReader buildAnnotationReader(AnnotatedElement annotatedElement) {
         return new JavaAnnotationReader(annotatedElement);
     }
+    
+    public Map getDefaults() {
+        return new HashMap();
+    }
 }

Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/TypeEnvironmentFactory.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/TypeEnvironmentFactory.java	2007-01-25 11:41:38 UTC (rev 11101)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/TypeEnvironmentFactory.java	2007-01-25 13:22:47 UTC (rev 11102)
@@ -16,18 +16,22 @@
  */
 public class TypeEnvironmentFactory {
 
-	private final Map<Type, TypeEnvironment> typeToEnvironment = new HashMap<Type, TypeEnvironment>();
-
 	/**
 	 * @return Returns a type environment suitable for resolving types occurring
 	 *         in subclasses of the context class.
 	 */
 	public TypeEnvironment getEnvironment(Class context) {
-		return doGetEnvironment( context );
+		if ( context == null ) {
+        	return IdentityTypeEnvironment.INSTANCE;
+        }
+        return createEnvironment( context );
 	}
 
 	public TypeEnvironment getEnvironment(Type context) {
-		return doGetEnvironment( context );
+		if ( context == null ) {
+        	return IdentityTypeEnvironment.INSTANCE;
+        }
+        return createEnvironment( context );
 	}
 
 	public TypeEnvironment getEnvironment(Type t, TypeEnvironment context) {
@@ -38,18 +42,6 @@
 		return CompoundTypeEnvironment.create( new ApproximatingTypeEnvironment(), context );
 	}
 
-	private TypeEnvironment doGetEnvironment(Type context) {
-		if ( context == null ) {
-			return IdentityTypeEnvironment.INSTANCE;
-		}
-		TypeEnvironment result = typeToEnvironment.get( context );
-		if ( result == null ) {
-			result = createEnvironment( context );
-			typeToEnvironment.put( context, result );
-		}
-		return result;
-	}
-
 	private TypeEnvironment createEnvironment(Type context) {
 		return new TypeSwitch<TypeEnvironment>() {
 			@Override

Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/xml/EJB3OverridenAnnotationReader.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/xml/EJB3OverridenAnnotationReader.java	2007-01-25 11:41:38 UTC (rev 11101)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/xml/EJB3OverridenAnnotationReader.java	2007-01-25 13:22:47 UTC (rev 11102)
@@ -269,6 +269,7 @@
 			if ( className != null && propertyName == null ) {
 				//is a class
 				Element tree = xmlContext.getXMLTree( className, null );
+                // FIXME: this variable is never used. why? is this a bug with overriding that didn't show up yet?
 				Annotation[] annotations = getJavaAnnotations();
 				List<Annotation> annotationList = new ArrayList<Annotation>( annotations.length + 5 );
                 annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 );
@@ -278,48 +279,27 @@
 						annotationList.add( annotation );
 					}
 				}
-				Annotation current = getEntity( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getMappedSuperclass( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getEmbeddable( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getTable( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getSecondaryTables( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getPrimaryKeyJoinColumns( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getIdClass( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getInheritance( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getDiscriminatorValue( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getDiscriminatorColumn( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getSequenceGenerator( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getTableGenerator( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getNamedQueries( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getNamedNativeQueries( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getSqlResultSetMappings( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getExcludeDefaultListeners( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getExcludeSuperclassListeners( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getAccessType( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getAttributeOverrides( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getAssociationOverrides( tree, defaults );
-				if ( current != null ) annotationList.add( current );
-				current = getEntityListeners( tree, defaults );
-				if ( current != null ) annotationList.add( current );
+				addIfNotNull( annotationList, getEntity( tree, defaults ) );
+				addIfNotNull( annotationList, getMappedSuperclass( tree, defaults ) );
+				addIfNotNull( annotationList, getEmbeddable( tree, defaults ) );
+				addIfNotNull( annotationList, getTable( tree, defaults ) );
+				addIfNotNull( annotationList, getSecondaryTables( tree, defaults ) );
+				addIfNotNull( annotationList, getPrimaryKeyJoinColumns( tree, defaults ) );
+				addIfNotNull( annotationList, getIdClass( tree, defaults ) );
+				addIfNotNull( annotationList, getInheritance( tree, defaults ) );
+				addIfNotNull( annotationList, getDiscriminatorValue( tree, defaults ) );
+				addIfNotNull( annotationList, getDiscriminatorColumn( tree, defaults ) );
+				addIfNotNull( annotationList, getSequenceGenerator( tree, defaults ) );
+				addIfNotNull( annotationList, getTableGenerator( tree, defaults ) );
+				addIfNotNull( annotationList, getNamedQueries( tree, defaults ) );
+				addIfNotNull( annotationList, getNamedNativeQueries( tree, defaults ) );
+				addIfNotNull( annotationList, getSqlResultSetMappings( tree, defaults ) );
+				addIfNotNull( annotationList, getExcludeDefaultListeners( tree, defaults ) );
+				addIfNotNull( annotationList, getExcludeSuperclassListeners( tree, defaults ) );
+				addIfNotNull( annotationList, getAccessType( tree, defaults ) );
+				addIfNotNull( annotationList, getAttributeOverrides( tree, defaults ) );
+				addIfNotNull( annotationList, getAssociationOverrides( tree, defaults ) );
+				addIfNotNull( annotationList, getEntityListeners( tree, defaults ) );
                 //FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time
                 this.annotations = annotationList.toArray( new Annotation[ annotationList.size() ] );
                 for (Annotation ann : this.annotations) {
@@ -345,7 +325,7 @@
 				else {
 					if ( defaults.canUseJavaAnnotations() ) {
 						Annotation annotation = getJavaAnnotation( AccessType.class );
-						if ( annotation != null ) annotationList.add( annotation );
+						addIfNotNull(annotationList, annotation);
 					}
 					getId( annotationList, defaults );
 					getEmbeddedId( annotationList, defaults );
@@ -356,12 +336,9 @@
 					getAssociation( OneToOne.class, annotationList, defaults );
 					getAssociation( OneToMany.class, annotationList, defaults );
 					getAssociation( ManyToMany.class, annotationList, defaults );
-					Annotation current = getSequenceGenerator( elementsForProperty, defaults );
-					if ( current != null ) annotationList.add( current );
-					current = getTableGenerator( elementsForProperty, defaults );
-					if ( current != null ) annotationList.add( current );
-					current = getAttributeOverrides( elementsForProperty, defaults );
-					if ( current != null ) annotationList.add( current );
+					addIfNotNull(annotationList, getSequenceGenerator( elementsForProperty, defaults ));
+					addIfNotNull(annotationList, getTableGenerator( elementsForProperty, defaults ));
+					addIfNotNull(annotationList, getAttributeOverrides( elementsForProperty, defaults ));
 
 				}
 				processEventAnnotations(annotationList, defaults);
@@ -380,6 +357,16 @@
 		}
 	}
 
+    /**
+     * Addes the Annotation to the list (only if it's not null) and then returns it.
+     */
+    private Annotation addIfNotNull(List<Annotation> annotationList, Annotation element) {
+        if ( element != null ) {
+            annotationList.add( element );
+        }
+        return element;
+    }
+
     //TODO mutualize the next 2 methods
     private Annotation getTableGenerator(List<Element> elementsForProperty, XMLContext.Default defaults) {
         for (Element element : elementsForProperty) {
@@ -454,19 +441,19 @@
 		}
 		if ( ! eventElement && defaults.canUseJavaAnnotations() ) {
 			Annotation ann = getJavaAnnotation(PrePersist.class);
-			if (ann != null) annotationList.add( ann );
+			addIfNotNull(annotationList, ann);
 			ann = getJavaAnnotation(PreRemove.class);
-			if (ann != null) annotationList.add( ann );
+			addIfNotNull(annotationList, ann);
 			ann = getJavaAnnotation(PreUpdate.class);
-			if (ann != null) annotationList.add( ann );
+			addIfNotNull(annotationList, ann);
 			ann = getJavaAnnotation(PostPersist.class);
-			if (ann != null) annotationList.add( ann );
+			addIfNotNull(annotationList, ann);
 			ann = getJavaAnnotation(PostRemove.class);
-			if (ann != null) annotationList.add( ann );
+			addIfNotNull(annotationList, ann);
 			ann = getJavaAnnotation(PostUpdate.class);
-			if (ann != null) annotationList.add( ann );
+			addIfNotNull(annotationList, ann);
 			ann = getJavaAnnotation(PostLoad.class);
-			if (ann != null) annotationList.add( ann );
+			addIfNotNull(annotationList, ann);
 		}
 	}
 
@@ -601,7 +588,7 @@
 				getJoinTable( annotationList, element, defaults );
 				buildJoinColumns( annotationList, element, defaults );
 				Annotation annotation = getPrimaryKeyJoinColumns( element, defaults );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				copyBooleanAttribute( ad, element, "optional" );
 				copyStringAttribute( ad, element, "mapped-by", false );
 				getOrderBy( annotationList, element, defaults );
@@ -614,71 +601,71 @@
 			if ( annotation != null ) {
 				annotationList.add( annotation );
 				annotation = overridesDefaultsInJoinTable( annotation, defaults );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( JoinColumn.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( JoinColumns.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( PrimaryKeyJoinColumn.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( PrimaryKeyJoinColumns.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( MapKey.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( OrderBy.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AttributeOverride.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AttributeOverrides.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AssociationOverride.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AssociationOverrides.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Lob.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Enumerated.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Temporal.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Column.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Columns.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 			}
 			else if ( isJavaAnnotationPresent( CollectionOfElements.class ) ) {
 				annotation = overridesDefaultsInJoinTable( getJavaAnnotation( CollectionOfElements.class ), defaults );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( JoinColumn.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( JoinColumns.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( PrimaryKeyJoinColumn.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( PrimaryKeyJoinColumns.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( MapKey.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( OrderBy.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AttributeOverride.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AttributeOverrides.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AssociationOverride.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AssociationOverrides.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Lob.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Enumerated.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Temporal.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Column.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Columns.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 			}
 		}
 	}
@@ -743,13 +730,13 @@
 			if ( annotation != null ) {
 				annotationList.add( annotation );
 				annotation = getJavaAnnotation( AttributeOverride.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AttributeOverrides.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AssociationOverride.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AssociationOverrides.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 			}
 		}
 	}
@@ -773,7 +760,7 @@
 		for ( Element element : elementsForProperty ) {
 			if ( "version".equals( element.getName() ) ) {
 				Annotation annotation = buildColumns( element );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				getTemporal( annotationList, element );
 				AnnotationDescriptor basic = new AnnotationDescriptor( Version.class );
 				annotationList.add( AnnotationFactory.create( basic ) );
@@ -785,11 +772,11 @@
 			if ( annotation != null ) {
 				annotationList.add( annotation );
 				annotation = getJavaAnnotation( Column.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Columns.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Temporal.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 			}
 		}
 	}
@@ -798,7 +785,7 @@
 		for ( Element element : elementsForProperty ) {
 			if ( "basic".equals( element.getName() ) ) {
 				Annotation annotation = buildColumns( element );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				getTemporal( annotationList, element );
 				getLob( annotationList, element );
 				getEnumerated( annotationList, element );
@@ -811,25 +798,25 @@
 		if ( elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations() ) {
 			//no annotation presence constraint, basic is the default
 			Annotation annotation = getJavaAnnotation( Basic.class );
-			if ( annotation != null ) annotationList.add( annotation );
+			addIfNotNull(annotationList, annotation);
 			annotation = getJavaAnnotation( Lob.class );
-			if ( annotation != null ) annotationList.add( annotation );
+			addIfNotNull(annotationList, annotation);
 			annotation = getJavaAnnotation( Enumerated.class );
-			if ( annotation != null ) annotationList.add( annotation );
+			addIfNotNull(annotationList, annotation);
 			annotation = getJavaAnnotation( Temporal.class );
-			if ( annotation != null ) annotationList.add( annotation );
+			addIfNotNull(annotationList, annotation);
 			annotation = getJavaAnnotation( Column.class );
-			if ( annotation != null ) annotationList.add( annotation );
+			addIfNotNull(annotationList, annotation);
 			annotation = getJavaAnnotation( Columns.class );
-			if ( annotation != null ) annotationList.add( annotation );
+			addIfNotNull(annotationList, annotation);
 			annotation = getJavaAnnotation( AttributeOverride.class );
-			if ( annotation != null ) annotationList.add( annotation );
+			addIfNotNull(annotationList, annotation);
 			annotation = getJavaAnnotation( AttributeOverrides.class );
-			if ( annotation != null ) annotationList.add( annotation );
+			addIfNotNull(annotationList, annotation);
 			annotation = getJavaAnnotation( AssociationOverride.class );
-			if ( annotation != null ) annotationList.add( annotation );
+			addIfNotNull(annotationList, annotation);
 			annotation = getJavaAnnotation( AssociationOverrides.class );
-			if ( annotation != null ) annotationList.add( annotation );
+			addIfNotNull(annotationList, annotation);
 		}
 	}
 
@@ -875,9 +862,9 @@
 			if ( "embedded-id".equals( element.getName() ) ) {
 				if ( isProcessingId( defaults ) ) {
 					Annotation annotation = getAttributeOverrides( element, defaults );
-					if ( annotation != null ) annotationList.add( annotation );
+					addIfNotNull(annotationList, annotation);
 					annotation = getAssociationOverrides( element, defaults );
-					if ( annotation != null ) annotationList.add( annotation );
+					addIfNotNull(annotationList, annotation);
 					AnnotationDescriptor ad = new AnnotationDescriptor( EmbeddedId.class );
 					annotationList.add( AnnotationFactory.create( ad ) );
 				}
@@ -903,25 +890,25 @@
 			if ( annotation != null ) {
 				annotationList.add( annotation );
 				annotation = getJavaAnnotation( Column.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Columns.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( GeneratedValue.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Temporal.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( TableGenerator.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( SequenceGenerator.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AttributeOverride.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AttributeOverrides.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AssociationOverride.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AssociationOverrides.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 			}
 		}
 	}
@@ -953,15 +940,15 @@
 				boolean processId = isProcessingId( defaults );
 				if ( processId ) {
 					Annotation annotation = buildColumns( element );
-					if ( annotation != null ) annotationList.add( annotation );
+					addIfNotNull(annotationList, annotation);
 					annotation = buildGeneratedValue( element );
-					if ( annotation != null ) annotationList.add( annotation );
+					addIfNotNull(annotationList, annotation);
 					getTemporal( annotationList, element );
 					//FIXME: fix the priority of xml over java for generator names
 					annotation = getTableGenerator( element, defaults );
-					if ( annotation != null ) annotationList.add( annotation );
+					addIfNotNull(annotationList, annotation);
 					annotation = getSequenceGenerator( element, defaults );
-					if ( annotation != null ) annotationList.add( annotation );
+					addIfNotNull(annotationList, annotation);
 					AnnotationDescriptor id = new AnnotationDescriptor( Id.class );
 					annotationList.add( AnnotationFactory.create( id ) );
 				}
@@ -985,25 +972,25 @@
 			if ( annotation != null ) {
 				annotationList.add( annotation );
 				annotation = getJavaAnnotation( Column.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Columns.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( GeneratedValue.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( Temporal.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( TableGenerator.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( SequenceGenerator.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AttributeOverride.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AttributeOverrides.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AssociationOverride.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 				annotation = getJavaAnnotation( AssociationOverrides.class );
-				if ( annotation != null ) annotationList.add( annotation );
+				addIfNotNull(annotationList, annotation);
 			}
 		}
 	}

Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/xml/EJB3ReflectionManager.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/xml/EJB3ReflectionManager.java	2007-01-25 11:41:38 UTC (rev 11101)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/xml/EJB3ReflectionManager.java	2007-01-25 13:22:47 UTC (rev 11102)
@@ -22,10 +22,6 @@
     
     private XMLContext xmlContext = new XMLContext();
     private HashMap defaults = null;
-
-    public EJB3ReflectionManager() {
-        System.out.println("hello");
-    }
     
     public AnnotationReader buildAnnotationReader(AnnotatedElement annotatedElement) {
         if ( xmlContext.hasContext() ) {

Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/ClassValidator.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/ClassValidator.java	2007-01-25 11:41:38 UTC (rev 11101)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/ClassValidator.java	2007-01-25 13:22:47 UTC (rev 11102)
@@ -120,7 +120,6 @@
 			Class<T> beanClass, ResourceBundle resourceBundle, MessageInterpolator interpolator,
             Map<XClass, ClassValidator> childClassValidators, ReflectionManager reflectionManager
     ) {
-        // TODO
         this.reflectionManager = reflectionManager != null ? reflectionManager : new EJB3ReflectionManager();
         XClass beanXClass = this.reflectionManager.toXClass( beanClass );
 		this.beanClass = beanClass;
@@ -652,7 +651,6 @@
 		this.messageBundle = rb;
 		this.userInterpolator = (MessageInterpolator) ois.readObject();
 		this.defaultMessageBundle = ResourceBundle.getBundle( DEFAULT_VALIDATOR_MESSAGE );
-        // TODO
 		reflectionManager = new EJB3ReflectionManager();
 		initValidator( reflectionManager.toXClass( beanClass ), new HashMap<XClass, ClassValidator>() );
 	}

Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/event/ValidateEventListener.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/event/ValidateEventListener.java	2007-01-25 11:41:38 UTC (rev 11101)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/event/ValidateEventListener.java	2007-01-25 13:22:47 UTC (rev 11102)
@@ -78,7 +78,6 @@
                 reflectionManager = ( (AnnotationConfiguration) cfg).getReflectionManager();
             }
             else {
-                // TODO
                 reflectionManager = new EJB3ReflectionManager();
             }
             while ( classes.hasNext() ) {




More information about the hibernate-commits mailing list