Author: epbernard
Date: 2007-01-27 18:37:06 -0500 (Sat, 27 Jan 2007)
New Revision: 11111
Added:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/event/JPAValidateListener.java
Removed:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/event/JPAValidateEventListener.java
Log:
ANN-546 better name
Deleted:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/event/JPAValidateEventListener.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/event/JPAValidateEventListener.java 2007-01-27
16:24:20 UTC (rev 11110)
+++
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/event/JPAValidateEventListener.java 2007-01-27
23:37:06 UTC (rev 11111)
@@ -1,47 +0,0 @@
-//$Id: $
-package org.hibernate.validator.event;
-
-import java.lang.ref.WeakReference;
-import java.util.Map;
-import java.util.WeakHashMap;
-import javax.persistence.PrePersist;
-import javax.persistence.PreUpdate;
-
-import org.hibernate.validator.ClassValidator;
-
-/**
- * @author Emmanuel Bernard
- */
-public class JPAValidateEventListener {
- //No need for weakReference if the event listener is loaded by the same CL than
- //the entities, but in a shared env this is not the case
- //TODO check that this can be hot redeployable
- private static final Map<Class, WeakReference<ClassValidator>> validators;
- private static final ClassValidator<JPAValidateEventListener> NO_VALIDATOR;
- static {
- validators = new WeakHashMap<Class, WeakReference<ClassValidator>>();
- NO_VALIDATOR = new
ClassValidator<JPAValidateEventListener>(JPAValidateEventListener.class);
- }
-
- @PrePersist
- @PreUpdate
- @SuppressWarnings( "unchecked" )
- public void onChange(Object object) {
- if (object == null) return;
- Class entity = object.getClass();
- WeakReference<ClassValidator> weakValidator = validators.get(entity);
- ClassValidator validator = weakValidator != null ? weakValidator.get() : null;
- if ( validator == null ) {
- //initialize
- //TODO reuse the same reflection manager?
- validator = new ClassValidator(entity);
- if ( ! validator.hasValidationRules() ) {
- validator = NO_VALIDATOR;
- }
- validators.put( entity, new WeakReference<ClassValidator>(validator) );
- }
- if ( validator != NO_VALIDATOR ) {
- validator.assertValid( object );
- }
- }
-}
Copied:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/event/JPAValidateListener.java
(from rev 11110,
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/event/JPAValidateEventListener.java)
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/event/JPAValidateListener.java
(rev 0)
+++
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/event/JPAValidateListener.java 2007-01-27
23:37:06 UTC (rev 11111)
@@ -0,0 +1,47 @@
+//$Id: $
+package org.hibernate.validator.event;
+
+import java.lang.ref.WeakReference;
+import java.util.Map;
+import java.util.WeakHashMap;
+import javax.persistence.PrePersist;
+import javax.persistence.PreUpdate;
+
+import org.hibernate.validator.ClassValidator;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class JPAValidateListener {
+ //No need for weakReference if the event listener is loaded by the same CL than
+ //the entities, but in a shared env this is not the case
+ //TODO check that this can be hot redeployable
+ private static final Map<Class, WeakReference<ClassValidator>> validators;
+ private static final ClassValidator<JPAValidateListener> NO_VALIDATOR;
+ static {
+ validators = new WeakHashMap<Class, WeakReference<ClassValidator>>();
+ NO_VALIDATOR = new ClassValidator<JPAValidateListener>(
JPAValidateListener.class);
+ }
+
+ @PrePersist
+ @PreUpdate
+ @SuppressWarnings( "unchecked" )
+ public void onChange(Object object) {
+ if (object == null) return;
+ Class entity = object.getClass();
+ WeakReference<ClassValidator> weakValidator = validators.get(entity);
+ ClassValidator validator = weakValidator != null ? weakValidator.get() : null;
+ if ( validator == null ) {
+ //initialize
+ //TODO reuse the same reflection manager?
+ validator = new ClassValidator(entity);
+ if ( ! validator.hasValidationRules() ) {
+ validator = NO_VALIDATOR;
+ }
+ validators.put( entity, new WeakReference<ClassValidator>(validator) );
+ }
+ if ( validator != NO_VALIDATOR ) {
+ validator.assertValid( object );
+ }
+ }
+}
Show replies by date