Author: manaRH
Date: 2012-02-07 09:39:58 -0500 (Tue, 07 Feb 2012)
New Revision: 14301
Added:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/core/ClassValidator.java
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/pom.xml
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/captcha/CaptchaResponse.java
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/captcha/CaptchaResponseValidator.java
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/core/SeamResourceBundle.java
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/core/Validators.java
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/framework/Controller.java
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/international/StatusMessages.java
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/mock/AbstractSeamTest.java
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/navigation/Param.java
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernateSessionFactory.java
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernateSessionInvocationHandler.java
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernateSessionProxy.java
branches/community/Seam_2_3/jboss-seam-jsf2/src/test/java/org/jboss/seam/test/unit/Foo.java
branches/community/Seam_2_3/jboss-seam-jsf2/src/test/java/org/jboss/seam/test/unit/PageParamTest.java
branches/community/Seam_2_3/jboss-seam-parent/pom.xml
branches/community/Seam_2_3/jboss-seam-ui-jsf2/pom.xml
branches/community/Seam_2_3/jboss-seam-ui-jsf2/src/main/java/org/jboss/seam/ui/validator/ModelValidator.java
Log:
JBSEAM-4722 - added Bean Validation instead of hibernate-validaitor 3.x,
upgraded hibernate-core,hem, hsearch for jboss-seam-*-jsf2 artifacts
Modified: branches/community/Seam_2_3/jboss-seam-jsf2/pom.xml
===================================================================
--- branches/community/Seam_2_3/jboss-seam-jsf2/pom.xml 2012-02-03 20:23:14 UTC (rev
14300)
+++ branches/community/Seam_2_3/jboss-seam-jsf2/pom.xml 2012-02-07 14:39:58 UTC (rev
14301)
@@ -103,6 +103,7 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<optional>true</optional>
+ <version>4.0.1.Final</version>
</dependency>
<!-- Maven's "nearest" dependency resolution doesn't take into
account
@@ -121,25 +122,22 @@
<dependency>
<groupId>org.hibernate</groupId>
- <artifactId>hibernate-annotations</artifactId>
- <optional>true</optional>
- </dependency>
-
- <dependency>
- <groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
+ <version>4.2.0.Final</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
+ <version>4.0.0.Final</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
+ <version>4.0.1.Final</version>
<optional>true</optional>
</dependency>
@@ -249,12 +247,6 @@
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <optional>true</optional>
- <scope>provided</scope>
- </dependency>
<dependency>
<groupId>antlr</groupId>
@@ -312,18 +304,6 @@
</dependency>
<dependency>
- <groupId>org.buni.meldware</groupId>
- <artifactId>meldware-mailjmx</artifactId>
- <optional>true</optional>
- </dependency>
-
- <dependency>
- <groupId>org.buni.meldware</groupId>
- <artifactId>meldware-mailapi</artifactId>
- <optional>true</optional>
- </dependency>
-
- <dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<optional>true</optional>
@@ -452,10 +432,10 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <version>1.4.2</version>
- <type>jar</type>
<scope>test</scope>
+ <version>1.6.1</version>
</dependency>
+
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/captcha/CaptchaResponse.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/captcha/CaptchaResponse.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/captcha/CaptchaResponse.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -6,12 +6,12 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.hibernate.validator.ValidatorClass;
+import javax.validation.Constraint;
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Target(ElementType.METHOD)
-(a)ValidatorClass(CaptchaResponseValidator.class)
+(a)Constraint(validatedBy=CaptchaResponseValidator.class)
public @interface CaptchaResponse
{
String message() default "incorrect response";
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/captcha/CaptchaResponseValidator.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/captcha/CaptchaResponseValidator.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/captcha/CaptchaResponseValidator.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -1,24 +1,30 @@
package org.jboss.seam.captcha;
-import java.lang.annotation.Annotation;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
-import org.hibernate.validator.Validator;
-
/**
* Validates that the input entered by the user matches
* the captcha image.
*
* @author Gavin King
+ * @author Marek Novotny
*
*/
-public class CaptchaResponseValidator implements Validator
+public class CaptchaResponseValidator implements
ConstraintValidator<CaptchaResponse,String>
{
- public void initialize(Annotation captchaResponse) {}
+ public void initialize(CaptchaResponse constraintAnnotation) { }
- public boolean isValid(Object response)
+ public boolean isValid(String value, ConstraintValidatorContext context)
{
- return Captcha.instance().validateResponse( (String) response );
+ boolean result = Captcha.instance().validateResponse(value);
+ if (!result)
+ {
+ context.disableDefaultConstraintViolation();
+
context.buildConstraintViolationWithTemplate("org.jboss.seam.captcha.error").addConstraintViolation();
+ }
+ return result;
}
}
Added:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/core/ClassValidator.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/core/ClassValidator.java
(rev 0)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/core/ClassValidator.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -0,0 +1,36 @@
+package org.jboss.seam.core;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+
+/**
+ *
+ * @author Marek Novotny
+ *
+ * @param <T> type for validation
+ */
+public class ClassValidator<T> implements Serializable
+{
+
+ private static final long serialVersionUID = -726917267535562335L;
+
+ // default validator from context
+ private static final Validator validator =
Validation.buildDefaultValidatorFactory().getValidator();
+
+ private final Class<T> classForValidation;
+
+ public ClassValidator(Class<T> clazz)
+ {
+ this.classForValidation = clazz;
+ }
+
+ public Set<ConstraintViolation<T>> getPotentialInvalidValues(String
propertyName, Object value)
+ {
+ return validator.validateValue(classForValidation, propertyName, value);
+ }
+
+}
\ No newline at end of file
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/core/SeamResourceBundle.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/core/SeamResourceBundle.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/core/SeamResourceBundle.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -96,7 +96,7 @@
{
bundles.add(bundle);
}
- bundle =
resourceLoader.loadBundle("org/hibernate/validator/resources/DefaultValidatorMessages");
+ bundle =
resourceLoader.loadBundle("org/hibernate/validator/ValidationMessages");
if (bundle != null) bundles.add(bundle);
bundle = resourceLoader.loadBundle("javax.faces.Messages");
if (bundle != null) bundles.add(bundle);
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/core/Validators.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/core/Validators.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/core/Validators.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -4,9 +4,7 @@
import java.beans.FeatureDescriptor;
import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.Set;
import javax.el.ELContext;
import javax.el.ELException;
@@ -14,9 +12,8 @@
import javax.el.PropertyNotFoundException;
import javax.el.PropertyNotWritableException;
import javax.el.ValueExpression;
+import javax.validation.ConstraintViolation;
-import org.hibernate.validator.ClassValidator;
-import org.hibernate.validator.InvalidValue;
import org.jboss.seam.Component;
import org.jboss.seam.Instance;
import org.jboss.seam.ScopeType;
@@ -36,42 +33,11 @@
@Name("org.jboss.seam.core.validators")
@BypassInterceptors
@Scope(ScopeType.APPLICATION)
-@Install(precedence = BUILT_IN, classDependencies =
"org.hibernate.validator.ClassValidator")
+@Install(precedence = BUILT_IN, classDependencies =
"org.jboss.seam.core.ClassValidator")
public class Validators
{
- // TODO: should use weak references here...
- private Map<Key, ClassValidator> classValidators = new ConcurrentHashMap<Key,
ClassValidator>();
-
- class Key
- {
- private Class validatableClass;
- private java.util.Locale locale;
-
- public Key(Class validatableClass, java.util.Locale locale)
- {
- this.validatableClass = validatableClass;
- this.locale = locale;
- }
-
- @Override
- public boolean equals(Object other)
- {
- if (other == null || !(other instanceof Key)) {
- return false;
- }
-
- Key key = (Key) other;
- return key.validatableClass.equals(validatableClass) &&
key.locale.equals(locale);
- }
-
- @Override
- public int hashCode()
- {
- return validatableClass.hashCode() + locale.hashCode();
- }
- }
-
+
/**
* Get the cached ClassValidator instance. If the argument is an instance of
* a session bean Seam component instance, the returned validator will be
@@ -80,9 +46,10 @@
*
* @param model the object to be validated
*/
+ @SuppressWarnings("unchecked")
public <T> ClassValidator<T> getValidator(T model)
{
- Class modelClass = model instanceof Instance ? ((Instance)
model).getComponent().getBeanClass() : model.getClass();
+ Class<?> modelClass = model instanceof Instance ? ((Instance)
model).getComponent().getBeanClass() : model.getClass();
return getValidator((Class<T>) modelClass);
}
@@ -91,19 +58,9 @@
*
* @param modelClass the class to be validated
*/
- @SuppressWarnings("unchecked")
public <T> ClassValidator<T> getValidator(Class<T> modelClass)
{
- java.util.ResourceBundle bundle = SeamResourceBundle.getBundle();
- Locale none = bundle == null ? new Locale("NONE") : bundle.getLocale();
- Key key = new Key(modelClass, none);
- ClassValidator result = classValidators.get(key);
- if (result == null)
- {
- result = createValidator(modelClass);
- classValidators.put(key, result);
- }
- return result;
+ return createValidator(modelClass);
}
/**
@@ -112,12 +69,9 @@
*
* @param modelClass the class to be validated
*/
- @SuppressWarnings("unchecked")
protected <T> ClassValidator<T> createValidator(Class<T>
modelClass)
{
- java.util.ResourceBundle bundle = SeamResourceBundle.getBundle();
-
- return bundle == null ? new ClassValidator(modelClass) : new
ClassValidator(modelClass, bundle);
+ return new ClassValidator<T>(modelClass);
}
/**
@@ -129,7 +83,7 @@
* @param value a value to be assigned to the property
* @return a set of potential InvalidValues, from Hibernate Validator
*/
- public InvalidValue[] validate(ValueExpression valueExpression, ELContext elContext,
Object value)
+ public Set<ConstraintViolation<Object>> validate(ValueExpression
valueExpression, ELContext elContext, Object value)
{
ValidatingResolver validatingResolver = new
ValidatingResolver(elContext.getELResolver());
ELContext decoratedContext = EL.createELContext(elContext, validatingResolver);
@@ -140,14 +94,14 @@
class ValidatingResolver extends ELResolver
{
private ELResolver delegate;
- private InvalidValue[] invalidValues;
+ private Set<ConstraintViolation<Object>> invalidValues;
public ValidatingResolver(ELResolver delegate)
{
this.delegate = delegate;
}
- public InvalidValue[] getInvalidValues()
+ public Set<ConstraintViolation<Object>> getInvalidValues()
{
return invalidValues;
}
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/framework/Controller.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/framework/Controller.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/framework/Controller.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -7,11 +7,11 @@
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
-import org.hibernate.validator.ClassValidator;
import org.jboss.seam.Component;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.contexts.Context;
import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.core.ClassValidator;
import org.jboss.seam.core.Conversation;
import org.jboss.seam.core.Events;
import org.jboss.seam.core.Expressions;
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/international/StatusMessages.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/international/StatusMessages.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/international/StatusMessages.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -8,8 +8,10 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
-import org.hibernate.validator.InvalidValue;
+import javax.validation.ConstraintViolation;
+
import org.jboss.seam.Component;
import org.jboss.seam.international.StatusMessage.Severity;
@@ -305,11 +307,11 @@
* Add an array of InvalidValues from Hibernate Validator. Each message will
* be added with a severity of WARN.
*/
- public void add(InvalidValue[] ivs)
+ public void add(Set<ConstraintViolation<Object>> constraintViolations)
{
- for (InvalidValue iv: ivs)
+ for (ConstraintViolation<Object> constraintViolation: constraintViolations)
{
- add(iv);
+ add(constraintViolation);
}
}
@@ -319,11 +321,11 @@
*
* The name of the property that was validated will be used as the widget ID
*/
- public void addToControls(InvalidValue[] ivs)
+ public void addToControls(Set<ConstraintViolation<Object>>
constraintViolations)
{
- for (InvalidValue iv: ivs)
+ for (ConstraintViolation<Object> constraintViolation: constraintViolations)
{
- addToControl(iv);
+ addToControl(constraintViolation);
}
}
@@ -331,9 +333,9 @@
* Add an InvalidValue from Hibernate Validator. The message will
* be added with a severity of WARN.
*/
- public void add(InvalidValue iv)
+ public void add(ConstraintViolation<Object> constraintViolation)
{
- add( WARN, iv.getMessage() );
+ add( WARN, constraintViolation.getMessage() );
}
/**
@@ -342,9 +344,9 @@
*
* The name of the property that was validated will be used as the widget ID
*/
- public void addToControl(InvalidValue iv)
+ public void addToControl(ConstraintViolation<Object> constraintViolation)
{
- addToControl( iv.getPropertyName(), iv );
+ addToControl( constraintViolation.getInvalidValue().toString(),
constraintViolation);
}
/**
@@ -353,9 +355,9 @@
*
* You can also specify the id of the widget to add the message to
*/
- public void addToControl(String id, InvalidValue iv)
+ public void addToControl(String id, ConstraintViolation<Object>
constraintViolation)
{
- addToControl( id, WARN, iv.getMessage() );
+ addToControl( id, WARN, constraintViolation.getMessage() );
}
private List<Runnable> getTasks()
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/mock/AbstractSeamTest.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/mock/AbstractSeamTest.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/mock/AbstractSeamTest.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -36,8 +36,8 @@
import javax.servlet.http.HttpServletResponseWrapper;
import javax.servlet.http.HttpSession;
import javax.transaction.UserTransaction;
+import javax.validation.ConstraintViolation;
-import org.hibernate.validator.InvalidValue;
import org.jboss.seam.Component;
import org.jboss.seam.Seam;
import org.jboss.seam.contexts.Contexts;
@@ -445,11 +445,12 @@
protected boolean validateValue(String valueExpression, Object value)
{
ValueExpression ve =
application.getExpressionFactory().createValueExpression(facesContext.getELContext(),
valueExpression, Object.class);
- InvalidValue[] ivs = Validators.instance().validate(ve,
facesContext.getELContext(), value);
- if (ivs.length > 0)
+ Set<ConstraintViolation<Object>> ivs =
Validators.instance().validate(ve, facesContext.getELContext(), value);
+ if (ivs.size() > 0)
{
validationFailed = true;
- facesContext.addMessage(null,
FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR, ivs[0].getMessage()));
+ String message = ivs.iterator().next().getMessage();
+ facesContext.addMessage(null,
FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR, message));
return false;
}
else
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/navigation/Param.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/navigation/Param.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/navigation/Param.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -2,6 +2,7 @@
import java.util.Date;
import java.util.Map;
+import java.util.Set;
import javax.el.ELContext;
import javax.el.ELException;
@@ -10,8 +11,8 @@
import javax.faces.convert.Converter;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
+import javax.validation.ConstraintViolation;
-import org.hibernate.validator.InvalidValue;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Validators;
import org.jboss.seam.core.Expressions.ValueExpression;
@@ -254,7 +255,7 @@
{
//TODO: note that this code is duplicated from ModelValidator!!
ELContext elContext = facesContext.getELContext();
- InvalidValue[] invalidValues;
+ Set<ConstraintViolation<Object>> invalidValues;
try
{
invalidValues = Validators.instance().validate(
valueExpression.toUnifiedValueExpression(), elContext, value );
@@ -266,21 +267,17 @@
throw new ValidatorException( createMessage(cause), cause );
}
- if ( invalidValues.length>0 )
+ if ( invalidValues.size()>0 )
{
throw new ValidatorException( createMessage(invalidValues) );
}
}
}
- private FacesMessage createMessage(InvalidValue[] invalidValues)
+ private FacesMessage createMessage(Set<ConstraintViolation<Object>>
invalidValues)
{
- return FacesMessages.createFacesMessage(
- FacesMessage.SEVERITY_ERROR,
- INVALID_MESSAGE_ID,
- "'" + name + "' parameter is invalid: " +
invalidValues[0].getMessage(),
- new Object[] { invalidValues[0], name }
- );
+ String message = invalidValues.iterator().next().getMessage();
+ return FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR,
INVALID_MESSAGE_ID, "'" + name + "' parameter is invalid: " +
message, new Object[] { message, name });
}
private FacesMessage createMessage(Throwable cause)
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -356,7 +356,7 @@
{
ClassMetadata classMetadata = getClassMetadata(value, session);
return classMetadata!=null && classMetadata.isVersioned() ?
- classMetadata.getVersion(value, EntityMode.POJO) : null;
+ classMetadata.getVersion(value) : null;
}
private static ClassMetadata getClassMetadata(Object value, Session session)
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernateSessionFactory.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernateSessionFactory.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernateSessionFactory.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -8,10 +8,10 @@
import java.util.Properties;
import org.hibernate.SessionFactory;
-import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.NamingStrategy;
-import org.hibernate.util.ReflectHelper;
+import org.hibernate.internal.util.ReflectHelper;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.Destroy;
@@ -90,7 +90,7 @@
protected SessionFactory createSessionFactory() throws ClassNotFoundException
{
- AnnotationConfiguration configuration = new AnnotationConfiguration();
+ Configuration configuration = new Configuration();
// setup non-default naming strategy
if (namingStrategy != null)
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernateSessionInvocationHandler.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernateSessionInvocationHandler.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernateSessionInvocationHandler.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -12,12 +12,13 @@
import org.hibernate.CacheMode;
import org.hibernate.Criteria;
-import org.hibernate.EntityMode;
import org.hibernate.Filter;
import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
+import org.hibernate.LobHelper;
import org.hibernate.LockMode;
+import org.hibernate.LockOptions;
import org.hibernate.Query;
import org.hibernate.ReplicationMode;
import org.hibernate.SQLQuery;
@@ -25,21 +26,26 @@
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
+import org.hibernate.SharedSessionBuilder;
import org.hibernate.Transaction;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.engine.ActionQueue;
-import org.hibernate.engine.EntityEntry;
-import org.hibernate.engine.EntityKey;
-import org.hibernate.engine.PersistenceContext;
-import org.hibernate.engine.QueryParameters;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
-import org.hibernate.event.EventListeners;
-import org.hibernate.event.EventSource;
-import org.hibernate.impl.CriteriaImpl;
-import org.hibernate.jdbc.Batcher;
-import org.hibernate.jdbc.JDBCContext;
+import org.hibernate.TypeHelper;
+import org.hibernate.cache.spi.CacheKey;
+import org.hibernate.collection.spi.PersistentCollection;
+import org.hibernate.engine.jdbc.spi.JdbcConnectionAccess;
+import org.hibernate.engine.query.spi.sql.NativeSQLQuerySpecification;
+import org.hibernate.engine.spi.ActionQueue;
+import org.hibernate.engine.spi.EntityEntry;
+import org.hibernate.engine.spi.EntityKey;
+import org.hibernate.engine.spi.LoadQueryInfluencers;
+import org.hibernate.engine.spi.NonFlushedChanges;
+import org.hibernate.engine.spi.PersistenceContext;
+import org.hibernate.engine.spi.QueryParameters;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.engine.transaction.spi.TransactionCoordinator;
+import org.hibernate.event.spi.EventSource;
+import org.hibernate.internal.CriteriaImpl;
+import org.hibernate.jdbc.ReturningWork;
import org.hibernate.jdbc.Work;
import org.hibernate.loader.custom.CustomQuery;
import org.hibernate.persister.entity.EntityPersister;
@@ -59,6 +65,8 @@
*/
public class HibernateSessionInvocationHandler implements InvocationHandler,
Serializable, EventSource
{
+
+ private static final long serialVersionUID = 4954720887288965536L;
private Session delegate;
@@ -159,11 +167,6 @@
return ((SessionImplementor) delegate).getFactory();
}
- public Batcher getBatcher()
- {
- return ((SessionImplementor) delegate).getBatcher();
- }
-
public List list(String paramString, QueryParameters paramQueryParameters) throws
HibernateException
{
return ((SessionImplementor) delegate).list(paramString, paramQueryParameters);
@@ -209,16 +212,6 @@
return ((SessionImplementor) delegate).getEntityUsingInterceptor(paramEntityKey);
}
- public void afterTransactionCompletion(boolean paramBoolean, Transaction
paramTransaction)
- {
- ((SessionImplementor) delegate).afterTransactionCompletion(paramBoolean,
paramTransaction);
- }
-
- public void beforeTransactionCompletion(Transaction paramTransaction)
- {
- ((SessionImplementor) delegate).beforeTransactionCompletion(paramTransaction)
;
- }
-
public Serializable getContextEntityIdentifier(Object paramObject)
{
return ((SessionImplementor) delegate).getContextEntityIdentifier(paramObject);
@@ -279,11 +272,6 @@
return ((SessionImplementor) delegate).getDontFlushFromFind();
}
- public EventListeners getListeners()
- {
- return ((SessionImplementor) delegate).getListeners();
- }
-
public PersistenceContext getPersistenceContext()
{
return ((SessionImplementor) delegate).getPersistenceContext();
@@ -299,12 +287,6 @@
return ((SessionImplementor)
delegate).executeNativeUpdate(paramNativeSQLQuerySpecification, paramQueryParameters);
}
-
- public EntityMode getEntityMode()
- {
- return ((SessionImplementor) delegate).getEntityMode();
- }
-
public CacheMode getCacheMode()
{
return ((SessionImplementor) delegate).getCacheMode();
@@ -375,21 +357,11 @@
((SessionImplementor) delegate).setFetchProfile(paramString);
}
- public JDBCContext getJDBCContext()
- {
- return ((SessionImplementor) delegate).getJDBCContext();
- }
-
public boolean isClosed()
{
return ((SessionImplementor) delegate).isClosed();
}
- public Session getSession(EntityMode paramEntityMode)
- {
- return delegate.getSession(paramEntityMode);
- }
-
public SessionFactory getSessionFactory()
{
return delegate.getSessionFactory();
@@ -670,12 +642,6 @@
return delegate.disconnect();
}
- @SuppressWarnings("deprecation")
- public void reconnect() throws HibernateException
- {
- delegate.reconnect();
- }
-
public void reconnect(Connection paramConnection) throws HibernateException
{
delegate.reconnect(paramConnection);
@@ -731,14 +697,119 @@
((EventSource) delegate).refresh(paramObject, paramMap);
}
- public void saveOrUpdateCopy(String paramString, Object paramObject, Map paramMap)
throws HibernateException
+ public void delete(String paramString, Object paramObject, boolean paramBoolean, Set
paramSet)
{
- ((EventSource) delegate).saveOrUpdateCopy(paramString, paramObject, paramMap);
+ ((EventSource) delegate).delete(paramString, paramObject, paramBoolean, paramSet);
}
- public void delete(String paramString, Object paramObject, boolean paramBoolean, Set
paramSet)
+ public String getTenantIdentifier()
{
- ((EventSource) delegate).delete(paramString, paramObject, paramBoolean, paramSet);
+ return delegate.getTenantIdentifier();
}
+ public JdbcConnectionAccess getJdbcConnectionAccess()
+ {
+ return ((SessionImplementor) delegate).getJdbcConnectionAccess();
+ }
+
+ public EntityKey generateEntityKey(Serializable id, EntityPersister persister)
+ {
+ return ((SessionImplementor) delegate).generateEntityKey(id, persister);
+ }
+
+ public CacheKey generateCacheKey(Serializable id, Type type, String entityOrRoleName)
+ {
+ return ((SessionImplementor) delegate).generateCacheKey(id, type,
entityOrRoleName);
+ }
+
+ public void disableTransactionAutoJoin()
+ {
+ ((SessionImplementor) delegate).disableTransactionAutoJoin();
+ }
+
+ public NonFlushedChanges getNonFlushedChanges() throws HibernateException
+ {
+ return ((SessionImplementor) delegate).getNonFlushedChanges();
+ }
+
+ public void applyNonFlushedChanges(NonFlushedChanges nonFlushedChanges) throws
HibernateException
+ {
+ ((SessionImplementor) delegate).applyNonFlushedChanges(nonFlushedChanges);
+ }
+
+ public TransactionCoordinator getTransactionCoordinator()
+ {
+ return ((SessionImplementor) delegate).getTransactionCoordinator();
+ }
+
+ public LoadQueryInfluencers getLoadQueryInfluencers()
+ {
+ return ((SessionImplementor) delegate).getLoadQueryInfluencers();
+ }
+
+ public <T> T execute(Callback<T> callback)
+ {
+ return ((SessionImplementor) delegate).execute(callback);
+ }
+
+ public SharedSessionBuilder sessionWithOptions()
+ {
+ return ((EventSource) delegate).sessionWithOptions();
+ }
+
+ public Object load(Class theClass, Serializable id, LockOptions lockOptions) throws
HibernateException
+ {
+ return ((EventSource) delegate).load(theClass, id, lockOptions);
+ }
+
+ public Object load(String entityName, Serializable id, LockOptions lockOptions) throws
HibernateException
+ {
+ return ((EventSource) delegate).load(entityName, id, lockOptions);
+ }
+
+ public LockRequest buildLockRequest(LockOptions lockOptions)
+ {
+ return ((EventSource) delegate).buildLockRequest(lockOptions);
+ }
+
+ public void refresh(String entityName, Object object) throws HibernateException
+ {
+ ((EventSource) delegate).refresh(entityName, object);
+ }
+
+ public void refresh(Object object, LockOptions lockOptions) throws HibernateException
+ {
+ ((EventSource) delegate).refresh(object, lockOptions);
+ }
+
+ public void refresh(String entityName, Object object, LockOptions lockOptions) throws
HibernateException
+ {
+ ((EventSource) delegate).refresh(entityName, object, lockOptions);
+ }
+
+ public Object get(Class clazz, Serializable id, LockOptions lockOptions) throws
HibernateException
+ {
+ return ((EventSource) delegate).get(clazz, id, lockOptions);
+ }
+
+ public Object get(String entityName, Serializable id, LockOptions lockOptions) throws
HibernateException
+ {
+ return ((EventSource) delegate).get(entityName, id, lockOptions);
+ }
+
+ public <T> T doReturningWork(ReturningWork<T> work) throws
HibernateException
+ {
+ return ((EventSource) delegate).doReturningWork(work);
+ }
+
+ public TypeHelper getTypeHelper()
+ {
+ return ((EventSource) delegate).getTypeHelper();
+ }
+
+ public LobHelper getLobHelper()
+ {
+ return ((EventSource) delegate).getLobHelper();
+ }
+
}
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernateSessionProxy.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernateSessionProxy.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/persistence/HibernateSessionProxy.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -1,8 +1,8 @@
package org.jboss.seam.persistence;
import org.hibernate.Session;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.event.EventSource;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.event.spi.EventSource;
/**
* Marker interface that signifies a proxy is using the
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/test/java/org/jboss/seam/test/unit/Foo.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/test/java/org/jboss/seam/test/unit/Foo.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/test/java/org/jboss/seam/test/unit/Foo.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -9,8 +9,8 @@
import java.io.Serializable;
import javax.ejb.Remove;
+import javax.validation.constraints.NotNull;
-import org.hibernate.validator.NotNull;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.End;
@@ -23,7 +23,6 @@
*/
@Name("foo")
@Scope(ScopeType.SESSION)
-@SuppressWarnings("deprecation")
public class Foo implements Serializable
{
private static final long serialVersionUID = -5448030633067107049L;
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/test/java/org/jboss/seam/test/unit/PageParamTest.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-jsf2/src/test/java/org/jboss/seam/test/unit/PageParamTest.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-jsf2/src/test/java/org/jboss/seam/test/unit/PageParamTest.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -8,7 +8,7 @@
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
-import org.hibernate.validator.Length;
+import javax.validation.constraints.Size;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Expressions;
import org.jboss.seam.core.Validators;
@@ -152,7 +152,7 @@
{
this.birthDate = birth;
}
- @Length(min = 3, max = 10)
+ @Size(min = 3, max = 10)
public String getValue() {
return value;
}
Modified: branches/community/Seam_2_3/jboss-seam-parent/pom.xml
===================================================================
--- branches/community/Seam_2_3/jboss-seam-parent/pom.xml 2012-02-03 20:23:14 UTC (rev
14300)
+++ branches/community/Seam_2_3/jboss-seam-parent/pom.xml 2012-02-07 14:39:58 UTC (rev
14301)
@@ -48,7 +48,7 @@
<version.jbossembedded>beta3.SP15</version.jbossembedded>
<version.emma>2.0.5312</version.emma>
<version.jsf12>1.2_12</version.jsf12>
- <version.jsf2>2.1.3_01</version.jsf2>
+ <version.jsf2>2.1.5</version.jsf2>
<!-- ***************** -->
<!-- Repository Deployment URLs -->
@@ -279,7 +279,7 @@
</exclusions>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-jpdl</artifactId>
<version>3.2.2</version>
Modified: branches/community/Seam_2_3/jboss-seam-ui-jsf2/pom.xml
===================================================================
--- branches/community/Seam_2_3/jboss-seam-ui-jsf2/pom.xml 2012-02-03 20:23:14 UTC (rev
14300)
+++ branches/community/Seam_2_3/jboss-seam-ui-jsf2/pom.xml 2012-02-07 14:39:58 UTC (rev
14301)
@@ -117,26 +117,18 @@
<optional>true</optional>
</dependency>
- <!-- Maven's "nearest" dependency resolution doesn't take into
account
- parent dependency management! -->
<dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <optional>true</optional>
- </dependency>
-
- <dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<scope>provided</scope>
-<!-- <version>2.1.1-b04</version> -->
+<!-- <version>2.1.5</version> -->
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<scope>provided</scope>
-<!-- <version>2.1.1-b04</version> -->
+<!-- <version>2.1.5</version> -->
</dependency>
@@ -152,24 +144,11 @@
</exclusions>
</dependency>
- <!-- This is actually a dep of jboss-cache, but it doesn't declare it -->
<dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-system</artifactId>
- <optional>true</optional>
- </dependency>
-
- <!-- This is actually a dep of jboss-cache, but it doesn't declare it -->
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-jmx</artifactId>
- <optional>true</optional>
- </dependency>
-
- <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<optional>true</optional>
+ <version>4.0.1.Final</version>
</dependency>
<dependency>
@@ -183,17 +162,12 @@
<artifactId>commons-beanutils</artifactId>
</dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <optional>true</optional>
- <scope>provided</scope>
- </dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<optional>true</optional>
+ <version>4.2.0.Final</version>
</dependency>
<dependency>
Modified:
branches/community/Seam_2_3/jboss-seam-ui-jsf2/src/main/java/org/jboss/seam/ui/validator/ModelValidator.java
===================================================================
---
branches/community/Seam_2_3/jboss-seam-ui-jsf2/src/main/java/org/jboss/seam/ui/validator/ModelValidator.java 2012-02-03
20:23:14 UTC (rev 14300)
+++
branches/community/Seam_2_3/jboss-seam-ui-jsf2/src/main/java/org/jboss/seam/ui/validator/ModelValidator.java 2012-02-07
14:39:58 UTC (rev 14301)
@@ -1,5 +1,7 @@
package org.jboss.seam.ui.validator;
+import java.util.Set;
+
import javax.el.ELException;
import javax.el.ValueExpression;
import javax.faces.application.FacesMessage;
@@ -8,9 +10,9 @@
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
-import org.hibernate.validator.InvalidValue;
import org.jboss.seam.core.Validators;
import org.jboss.seam.faces.FacesMessages;
+import javax.validation.ConstraintViolation;
/**
* Validates using Hibernate Validator model-based annotations.
@@ -29,7 +31,7 @@
if (valueExpression != null)
{
//TODO: note that this code is duplicated to Param.getValueFromRequest()!!
- InvalidValue[] invalidValues;
+ Set<ConstraintViolation<Object>> invalidValues;
try
{
invalidValues = Validators.instance().validate( valueExpression,
facesContext.getELContext(), value );
@@ -41,16 +43,17 @@
throw new ValidatorException(createMessage(cause), cause);
}
- if ( invalidValues!=null && invalidValues.length>0 )
+ if ( invalidValues!=null && invalidValues.size()>0 )
{
throw new ValidatorException(createMessage(invalidValues,
resolveLabel(facesContext, component)));
}
}
}
- private FacesMessage createMessage(InvalidValue[] invalidValues, Object label)
+ private FacesMessage createMessage(Set<ConstraintViolation<Object>>
invalidValues, Object label)
{
- return FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR,
invalidValues[0].getMessage(), label);
+ String message = invalidValues.iterator().next().getMessage();
+ return FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR, message,
label);
}
private FacesMessage createMessage(Throwable cause)