[hibernate-commits] Hibernate SVN: r15904 - in validator/trunk/hibernate-validator/src: main/java/org/hibernate/validation/engine and 3 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Thu Feb 5 11:10:27 EST 2009
Author: hardy.ferentschik
Date: 2009-02-05 11:10:27 -0500 (Thu, 05 Feb 2009)
New Revision: 15904
Added:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/HibernateValidationProvider.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/Version.java
Removed:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/Version.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/HibernateValidationProvider.java
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConfigurationImpl.java
validator/trunk/hibernate-validator/src/main/resources/META-INF/services/javax.validation.spi.ValidationProvider
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
Log:
some class refactoring
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/HibernateValidationProvider.java (from rev 15883, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/HibernateValidationProvider.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/HibernateValidationProvider.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/HibernateValidationProvider.java 2009-02-05 16:10:27 UTC (rev 15904)
@@ -0,0 +1,69 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation;
+
+import javax.validation.Configuration;
+import javax.validation.ValidationException;
+import javax.validation.ValidatorFactory;
+import javax.validation.spi.BootstrapState;
+import javax.validation.spi.ConfigurationState;
+import javax.validation.spi.ValidationProvider;
+
+import org.hibernate.validation.engine.HibernateValidatorConfiguration;
+import org.hibernate.validation.engine.ConfigurationImpl;
+import org.hibernate.validation.engine.ValidatorFactoryImpl;
+
+/**
+ * Default implementation of <code>ValidationProvider</code> within Hibernate validator.
+ *
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+public class HibernateValidationProvider implements ValidationProvider {
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSuitable(Class<? extends Configuration<?>> builderClass) {
+ return builderClass == HibernateValidatorConfiguration.class;
+ }
+
+ public <T extends Configuration<T>> T createSpecializedConfiguration(BootstrapState state, Class<T> configurationClass) {
+ if ( !isSuitable( configurationClass ) ) {
+ throw new ValidationException(
+ "Illegal call to createSpecializedConfiguration() for a non suitable provider"
+ );
+ }
+ //cast protected by isSuitable call
+ return configurationClass.cast( new ConfigurationImpl( this ) );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Configuration<?> createGenericConfiguration(BootstrapState state) {
+ return new ConfigurationImpl( state );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ValidatorFactory buildValidatorFactory(ConfigurationState configurationState) {
+ return new ValidatorFactoryImpl( configurationState );
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/HibernateValidationProvider.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Id
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/Version.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/Version.java 2009-02-05 11:55:06 UTC (rev 15903)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/Version.java 2009-02-05 16:10:27 UTC (rev 15904)
@@ -1,61 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation;
-
-import java.net.URL;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import org.slf4j.Logger;
-
-/**
- * @author Hardy Ferentschik
- */
-public class Version {
- private static final Logger log = org.hibernate.validation.util.LoggerFactory.make();
-
- static {
- Class clazz = Version.class;
- String classFileName = clazz.getSimpleName() + ".class";
- String classFilePath = clazz.getCanonicalName().replace( '.', '/' )
- + ".class";
- String pathToThisClass =
- clazz.getResource( classFileName ).toString();
- String pathToManifest = pathToThisClass.substring( 0, pathToThisClass.indexOf( classFilePath ) - 1 )
- + "/META-INF/MANIFEST.MF";
- log.trace( "Manifest file {}", pathToManifest );
- Manifest manifest = null;
- String version;
- try {
- manifest = new Manifest( new URL( pathToManifest ).openStream() );
- }
- catch ( Exception e ) {
- log.warn( "Unable to determine version of Hibernate Validator" );
- }
- if ( manifest == null ) {
- version = "?";
- }
- else {
- version = manifest.getMainAttributes().getValue( Attributes.Name.IMPLEMENTATION_VERSION );
- }
- log.info( "Hibernate Commons Annotations {}", version );
- }
-
- public static void touch() {
- }
-}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConfigurationImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConfigurationImpl.java 2009-02-05 11:55:06 UTC (rev 15903)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConfigurationImpl.java 2009-02-05 16:10:27 UTC (rev 15904)
@@ -33,7 +33,7 @@
import javax.validation.spi.ConfigurationState;
import javax.validation.spi.ValidationProvider;
-import org.hibernate.validation.Version;
+import org.hibernate.validation.util.Version;
/**
* @author Emmanuel Bernard
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/HibernateValidationProvider.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/HibernateValidationProvider.java 2009-02-05 11:55:06 UTC (rev 15903)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/HibernateValidationProvider.java 2009-02-05 16:10:27 UTC (rev 15904)
@@ -1,65 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.engine;
-
-import javax.validation.Configuration;
-import javax.validation.ValidationException;
-import javax.validation.ValidatorFactory;
-import javax.validation.spi.BootstrapState;
-import javax.validation.spi.ConfigurationState;
-import javax.validation.spi.ValidationProvider;
-
-/**
- * Default implementation of <code>ValidationProvider</code> within Hibernate validator.
- *
- * @author Emmanuel Bernard
- * @author Hardy Ferentschik
- */
-public class HibernateValidationProvider implements ValidationProvider {
-
- /**
- * {@inheritDoc}
- */
- public boolean isSuitable(Class<? extends Configuration<?>> builderClass) {
- return builderClass == HibernateValidatorConfiguration.class;
- }
-
- public <T extends Configuration<T>> T createSpecializedConfiguration(BootstrapState state, Class<T> configurationClass) {
- if ( !isSuitable( configurationClass ) ) {
- throw new ValidationException(
- "Illegal call to createSpecializedConfiguration() for a non suitable provider"
- );
- }
- //cast protected by isSuitable call
- return configurationClass.cast( new ConfigurationImpl( this ) );
- }
-
- /**
- * {@inheritDoc}
- */
- public Configuration<?> createGenericConfiguration(BootstrapState state) {
- return new ConfigurationImpl( state );
- }
-
- /**
- * {@inheritDoc}
- */
- public ValidatorFactory buildValidatorFactory(ConfigurationState configurationState) {
- return new ValidatorFactoryImpl( configurationState );
- }
-}
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/Version.java (from rev 15883, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/Version.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/Version.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/Version.java 2009-02-05 16:10:27 UTC (rev 15904)
@@ -0,0 +1,61 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.util;
+
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.slf4j.Logger;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Version {
+ private static final Logger log = org.hibernate.validation.util.LoggerFactory.make();
+
+ static {
+ Class clazz = Version.class;
+ String classFileName = clazz.getSimpleName() + ".class";
+ String classFilePath = clazz.getCanonicalName().replace( '.', '/' )
+ + ".class";
+ String pathToThisClass =
+ clazz.getResource( classFileName ).toString();
+ String pathToManifest = pathToThisClass.substring( 0, pathToThisClass.indexOf( classFilePath ) - 1 )
+ + "/META-INF/MANIFEST.MF";
+ log.trace( "Manifest file {}", pathToManifest );
+ Manifest manifest = null;
+ String version;
+ try {
+ manifest = new Manifest( new URL( pathToManifest ).openStream() );
+ }
+ catch ( Exception e ) {
+ log.warn( "Unable to determine version of Hibernate Validator" );
+ }
+ if ( manifest == null ) {
+ version = "?";
+ }
+ else {
+ version = manifest.getMainAttributes().getValue( Attributes.Name.IMPLEMENTATION_VERSION );
+ }
+ log.info( "Hibernate Commons Annotations {}", version );
+ }
+
+ public static void touch() {
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/Version.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/main/resources/META-INF/services/javax.validation.spi.ValidationProvider
===================================================================
--- validator/trunk/hibernate-validator/src/main/resources/META-INF/services/javax.validation.spi.ValidationProvider 2009-02-05 11:55:06 UTC (rev 15903)
+++ validator/trunk/hibernate-validator/src/main/resources/META-INF/services/javax.validation.spi.ValidationProvider 2009-02-05 16:10:27 UTC (rev 15904)
@@ -1 +1 @@
-org.hibernate.validation.engine.HibernateValidationProvider
\ No newline at end of file
+org.hibernate.validation.HibernateValidationProvider
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-02-05 11:55:06 UTC (rev 15903)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-02-05 16:10:27 UTC (rev 15904)
@@ -43,7 +43,7 @@
import org.junit.Test;
import org.hibernate.validation.engine.HibernateValidatorConfiguration;
-import org.hibernate.validation.engine.HibernateValidationProvider;
+import org.hibernate.validation.HibernateValidationProvider;
import org.hibernate.validation.constraints.NotNullValidator;
import org.hibernate.validation.eg.Customer;
import org.hibernate.validation.engine.ConfigurationImpl;
More information about the hibernate-commits
mailing list