[hibernate-commits] Hibernate SVN: r15300 - in validator/trunk/hibernate-validator-legacy: src/main and 6 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Thu Oct 9 04:57:53 EDT 2008
Author: hardy.ferentschik
Date: 2008-10-09 04:57:53 -0400 (Thu, 09 Oct 2008)
New Revision: 15300
Added:
validator/trunk/hibernate-validator-legacy/src/main/docbook/
validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/
validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/images/
validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/images/hibernate_logo_a.png
validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/master.xml
validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/modules/
validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/modules/checkconstraints.xml
validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/modules/defineconstraints.xml
validator/trunk/hibernate-validator-legacy/src/main/javadoc/
validator/trunk/hibernate-validator-legacy/src/main/javadoc/stylesheet.css
Removed:
validator/trunk/hibernate-validator-legacy/build.properties.dist
validator/trunk/hibernate-validator-legacy/build.xml
validator/trunk/hibernate-validator-legacy/common-build.xml
validator/trunk/hibernate-validator-legacy/doc/
validator/trunk/hibernate-validator-legacy/ivy.xml
validator/trunk/hibernate-validator-legacy/ivy/
validator/trunk/hibernate-validator-legacy/jdbc/
Modified:
validator/trunk/hibernate-validator-legacy/pom.xml
validator/trunk/hibernate-validator-legacy/src/test/resources/log4j.properties
Log:
Switched from ant build to maven build. Removed ant related resources
Deleted: validator/trunk/hibernate-validator-legacy/build.properties.dist
===================================================================
--- validator/trunk/hibernate-validator-legacy/build.properties.dist 2008-10-09 07:17:13 UTC (rev 15299)
+++ validator/trunk/hibernate-validator-legacy/build.properties.dist 2008-10-09 08:57:53 UTC (rev 15300)
@@ -1,3 +0,0 @@
-common.dir=.
-src.dir=src
-test.dir=test
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator-legacy/build.xml
===================================================================
--- validator/trunk/hibernate-validator-legacy/build.xml 2008-10-09 07:17:13 UTC (rev 15299)
+++ validator/trunk/hibernate-validator-legacy/build.xml 2008-10-09 08:57:53 UTC (rev 15300)
@@ -1,219 +0,0 @@
-<!--
-
- Hibernate Annotations ANT build script.
-
- You need JDK 5.0 installed to build Hibernate Annotations.
-
--->
-
-<!-- To add a dependency:
- defines the dependency.jar property that points to the expected jar file
- in init, add an available dependency.jar and populate dependency.jar.available
- create a target get.dependency which calls clean and jar
- add get.depdendecy to depends= for compile or compiletest
- alter lib.moduleclass.path or junit.moduleclasspath accordingly
--->
-
-<project name="Hibernate Validator" default="dist" basedir="."
- xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
-
- <!-- Give user a chance to override without editing this file
- (and without typing -D each time it compiles it) -->
- <property file="build.properties"/>
- <property file="${user.home}/.ant.properties"/>
-
- <!-- Name of project and version, used to create filenames -->
- <property name="Name" value="Hibernate Validator"/>
- <property name="name" value="hibernate-validator"/>
- <property name="version" value="3.1.0.GA"/>
- <property name="javadoc.packagenames" value="org.hibernate.validator.*"/>
- <property name="copy.test" value="true"/>
- <property name="javac.source" value="1.5"/>
- <property name="javac.target" value="1.5"/>
- <property name="jdbc.dir" value="jdbc"/>
- <property name="common.dir" value="${basedir}"/>
-
- <property name="ivy.dep.dir" value="${basedir}/target/lib"/>
-
-
- <import file="${common.dir}/common-build.xml"/>
-
-
- <path id="lib.moduleclass.path">
- <fileset dir="${ivy.dep.dir}/core">
- <include name="*.jar"/>
- </fileset>
- </path>
- <path id="junit.moduleclasspath">
- <pathelement location="${src.dir}"/>
- <pathelement location="${test.dir}"/>
- <fileset dir="${ivy.dep.dir}/test">
- <include name="*.jar"/>
- </fileset>
- <fileset dir="${jdbc.dir}">
- <include name="*.jar"/>
- <include name="*.zip"/>
- </fileset>
- <fileset dir="${lib.dir}/test">
- <include name="*.jar"/>
- <include name="*.zip"/>
- </fileset>
- </path>
-
- <!-- ivy load -->
- <property name="ivy.jar.dir" value="${basedir}/ivy"/>
- <property name="ivy.conf.dir" value="${basedir}"/>
- <path id="ivy.lib.path">
- <fileset dir="${ivy.jar.dir}" includes="*.jar"/>
- </path>
- <taskdef resource="fr/jayasoft/ivy/ant/antlib.xml"
- uri="antlib:fr.jayasoft.ivy.ant" classpathref="ivy.lib.path"/>
-
- <target name="init">
- <antcall target="common-build.init"/>
- <tstamp>
- <format property="now" pattern="yyyyMMddhhmmss"/>
- </tstamp>
- <mkdir dir="${ivy.dep.dir}/core"/>
- <mkdir dir="${ivy.dep.dir}/test"/>
- <ivy:configure file="${ivy.jar.dir}/ivyconf.xml"/>
- <mkdir dir="${lib.dir}/test"/>
- </target>
-
- <target name="get.deps.core" depends="init" description="retrieve the core dependencies">
- <ivy:resolve conf="default"/>
- <ivy:retrieve pattern="${ivy.dep.dir}/core/[artifact].[ext]" conf="default"/>
- </target>
-
- <target name="get.deps.test" depends="init" description="retrieve the test dependencies">
- <ivy:resolve conf="test"/>
- <ivy:retrieve pattern="${ivy.dep.dir}/test/[artifact].[ext]" conf="test"/>
- </target>
-
- <!-- Run a single unit test. -->
- <target name="junitsingle" depends="compiletest"
- description="Run a single test suite (requires testname and jdbc.driver properties)">
- <mkdir dir="${test.output}"/>
- <junit printsummary="yes" fork="yes" haltonfailure="yes">
- <classpath>
- <fileset dir="${jdbc.dir}">
- <include name="**/*.jar"/>
- <include name="**/*.zip"/>
- </fileset>
- <path refid="lib.class.path"/>
- <pathelement path="${classes.dir}"/>
- <pathelement path="${src.dir}"/>
- <!-- pick up properties from here -->
- <pathelement path="${test.dir}"/>
- <!-- pick up mappings from here -->
- </classpath>
- <formatter type="plain"/>
- <formatter type="xml"/>
- <test fork="yes" todir="${test.output}" haltonfailure="no" name="${testname}"/>
- </junit>
- </target>
-
- <target name="compile" depends="init,get.deps.core,resources" description="Compile the Java source code">
- <available
- classname="org.eclipse.core.launcher.Main"
- property="build.compiler"
- value="org.eclipse.jdt.core.JDTCompilerAdapter"
- classpath="${java.class.path}"/>
- <javac
- srcdir="${src.dir}"
- destdir="${classes.dir}"
- classpathref="lib.class.path"
- debug="${javac.debug}"
- optimize="${javac.optimize}"
- nowarn="on"
- source="${javac.source}"
- target="${javac.target}">
- <src path="${src.dir}"/>
- </javac>
- <copy todir="${classes.dir}">
- <fileset dir="${src.dir}">
- <include name="**/resources/*.properties"/>
- <include name="**/*.xsd"/>
- </fileset>
- </copy>
- </target>
-
- <target name="jar" depends="compile" description="Build the distribution .jar file">
- <mkdir dir="${classes.dir}/META-INF"/>
- <manifest file="${classes.dir}/META-INF/MANIFEST.MF">
- <attribute name="Implementation-Title" value="${Name}"/>
- <attribute name="Implementation-Version" value="${version}"/>
- <attribute name="Implementation-Vendor" value="hibernate.org"/>
- <attribute name="Implementation-Vendor-Id" value="hibernate.org"/>
- <attribute name="Implementation-URL" value="http://validator.hibernate.org"/>
- </manifest>
- <antcall target="common-build.jar"/>
- </target>
-
- <!-- Some of this can probably be moved to common-build... -->
- <target name="dist" depends="get.deps.core,get.deps.test,jar,javadoc,copysource,copytest,copylib,extras"
- description="Build everything">
-
- <ant inheritall="false" dir="${basedir}/doc/reference"/>
- <copy todir="${dist.dir}/doc/reference" failonerror="false">
- <fileset dir="${basedir}/doc/reference/build">
- <include name="**/*.*"/>
- </fileset>
- </copy>
-
- <copy todir="${dist.dir}" failonerror="false">
- <fileset dir="${common.dir}">
- <include name="common-build.xml"/>
- </fileset>
- </copy>
- <copy todir="${dist.dir}/ivy" failonerror="false">
- <fileset dir="${ivy.jar.dir}">
- <include name="**/*.*"/>
- </fileset>
- </copy>
-
- <!-- copy dependencies -->
- <copy todir="${dist.lib.dir}" failonerror="false">
- <!-- fileset file="${jpa-api.jar}"/>
- <fileset file="${commons-annotations.jar}"/ -->
- <fileset dir="${ivy.dep.dir}/core">
- <include name="*.jar"/>
- </fileset>
- </copy>
-
- <mkdir dir="${dist.lib.dir}/test"/>
- <copy todir="${dist.lib.dir}/test" failonerror="false">
- <fileset dir="${ivy.dep.dir}/test">
- <include name="*.jar"/>
- </fileset>
- </copy>
-
- <mkdir dir="${dist.lib.dir}/build"/>
- <copy todir="${dist.lib.dir}/build" failonerror="false">
- <fileset file="${lib.dir}/build/*.jar"/>
- </copy>
-
- <!-- ivy uses the module name without hibernate- (to mimic the directory names). Revert the situation -->
- <move file="${dist.lib.dir}/commons-annotations.jar" tofile="${dist.lib.dir}/hibernate-commons-annotations.jar"
- failonerror="false"/>
- <move file="${dist.lib.dir}/test/annotations.jar" tofile="${dist.lib.dir}/test/hibernate-annotations.jar"
- failonerror="false"/>
- <move file="${dist.lib.dir}/test/entitymanager.jar" tofile="${dist.lib.dir}/test/hibernate-entitymanager.jar"
- failonerror="false"/>
-
- <copy file="${basedir}/build.properties.dist" tofile="${dist.dir}/build.properties" failonerror="false">
- </copy>
- <antcall target="common-build.dist"/>
- </target>
-
- <target name="zip-dist" description="zip the dist">
- <zip zipfile="${dist.dir}-${version}.zip">
- <zipfileset prefix="${name}-${version}" dir="${dist.dir}"/>
- </zip>
- <tar compression="gzip" tarfile="${dist.dir}-${version}.tar.gz">
- <tarfileset prefix="${name}-${version}" dir="${dist.dir}"/>
- </tar>
- </target>
-
-
-</project>
Deleted: validator/trunk/hibernate-validator-legacy/common-build.xml
===================================================================
--- validator/trunk/hibernate-validator-legacy/common-build.xml 2008-10-09 07:17:13 UTC (rev 15299)
+++ validator/trunk/hibernate-validator-legacy/common-build.xml 2008-10-09 08:57:53 UTC (rev 15300)
@@ -1,478 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="common-build" default="dist"
- xmlns:artifact="urn:maven-artifact-ant">
- <description>Common properties and targets for the HibernateExt project</description>
-
- <!-- my.basedir property can be used to refer to files/directories relatively to the common-build.xml file -->
- <dirname property="common-build.basedir" file="${ant.file.common-build}"/>
-
- <!-- Give user a chance to override without editing this file
- (and without typing -D each time it compiles it) -->
- <property file="${common-build.basedir}/build.properties"/>
- <property file="${user.home}/.ant.properties"/>
-
- <property name="src.dir" location="src/main/java"/>
- <property name="resources.dir" location="src/main/resources"/>
- <property name="test.dir" location="src/test/java"/>
- <property name="test.resources.dir" location="src/test/resources"/>
- <property name="lib.dir" location="lib"/>
- <property name="build.dir" location="${basedir}/target"/>
- <property name="test.output" location="${build.dir}/test-reports"/>
- <property name="classes.dir" location="${build.dir}/classes"/>
- <property name="testclasses.dir" location="${build.dir}/testclasses"/>
- <property name="dist.target.dir" location="${basedir}/target"/>
- <property name="dist.dir" location="${dist.target.dir}/${name}"/>
- <property name="instrumenttest.out.dir" value="instrumenttestout"/>
- <property name="doc.dir" location="doc"/>
- <property name="doc.api.dir" location="${doc.dir}/api"/>
- <property name="doc.reference.dir" location="${doc.dir}/reference"/>
-
- <property name="dist.doc.dir" location="${dist.dir}/doc"/>
- <property name="dist.api.dir" location="${dist.dir}/doc/api"/>
-
- <property name="dist.src.dir" location="${dist.dir}/src"/>
- <property name="dist.test.dir" location="${dist.dir}/test"/>
- <property name="dist.lib.dir" location="${dist.dir}/lib"/>
- <property name="jar.name" value="${name}"/>
- <property name="jar.file.name" value="${dist.dir}/${jar.name}.jar"/>
- <property name="jartest.file.name" value="${dist.dir}/${jar.name}-tests.jar"/>
-
- <property name="javadoc" value="http://java.sun.com/j2se/1.4/docs/api"/>
- <property name="javac.debug" value="on"/>
- <property name="javac.optimize" value="off"/>
- <property name="javac.source" value="1.4"/>
- <property name="javac.target" value="1.4"/>
-
- <property name="pom.file" value="pom.xml"/>
- <property name="src.jar" value="${build.dir}/src.jar"/>
-
- <!-- build related properties -->
- <property name="build.lib.dir" value="${lib.dir}/target"/>
-
- <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
- <classpath>
- <fileset dir="${common-build.basedir}/lib/build"> <!-- ${build.lib.dir} fails in reference doc build -->
- <include name="junit-*.jar"/>
- <include name="ant-junit-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
-
- <taskdef name="junitreport" classname="org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator">
- <classpath>
- <fileset dir="${common-build.basedir}/lib/build"> <!-- ${build.lib.dir} fails in reference doc build -->
- <include name="junit-*.jar"/>
- <include name="ant-junit-*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
-
- <!-- ivy load -->
- <property name="ivy.jar.dir" value="${common-build.basedir}/ivy" />
- <property name="ivy.conf.dir" value="${common-build.basedir}" />
- <path id="ivy.lib.path">
- <fileset dir="${ivy.jar.dir}" includes="*.jar"/>
- </path>
- <taskdef resource="fr/jayasoft/ivy/ant/antlib.xml"
- uri="antlib:fr.jayasoft.ivy.ant" classpathref="ivy.lib.path"/>
-
- <!-- maven task load -->
- <path id="maven-ant-tasks.path" path="${ivy.jar.dir}/maven-ant-tasks.jar" />
- <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
- uri="urn:maven-artifact-ant"
- classpathref="maven-ant-tasks.path" />
-
- <artifact:remoteRepository id="offline.repository.jboss.org" url="file://${offline.repository.jboss.org}" />
-
- <path id="lib.class.path">
- <fileset dir="${lib.dir}">
- <include name="*.jar"/>
- </fileset>
- <path refid="lib.moduleclass.path"/>
- <pathelement path="${clover.jar}"/>
- </path>
-
- <!-- overridable in modules -->
- <path id="lib.moduleclass.path"/>
-
- <patternset id="support.files">
- <include name="**/*.jpg"/>
- <include name="**/*.gif"/>
- <include name="**/*.dtd"/>
- <include name="**/*.xsd"/>
- <include name="**/*.xml"/>
- <include name="**/*.xslt"/>
-
- <!-- exclude everything we don't want in the jar -->
- <exclude name="${build.dir}/**/*"/>
- <exclude name="${doc.dir}/**/*"/>
- <exclude name="classes/**/*"/>
- <exclude name="build.xml"/>
- <exclude name="**/*.properties"/>
- <exclude name="**/*.ccf"/>
- <exclude name="**/*.cfg.xml"/>
- <exclude name="**/ehcache.xml"/>
- </patternset>
-
- <patternset id="source.files">
- <include name="**/*.java"/>
- <include name="**/*.properties"/>
- </patternset>
-
- <!-- junit paths/filesets -->
- <fileset dir="${testclasses.dir}" id="junit.batchtestset">
- <include name="**/*Test.class"/>
- </fileset>
-
- <path id="testsrc.path">
- <pathelement location="${test.dir}"/>
- <pathelement location="${test.resources.dir}"/>
- </path>
-
- <!-- Clover -->
- <property name="clover.out.dir" value="cloverout"/>
- <property name="clover.jar" value="${ant.home}/lib/clover.jar"/>
- <taskdef resource="clovertasks"/>
-
- <path id="junit.classpath">
- <fileset dir="${lib.dir}">
- <include name="*.jar"/>
- </fileset>
- <pathelement path="${classes.dir}"/>
- <pathelement path="${testclasses.dir}"/>
- <path refid="lib.class.path"/>
- <path refid="junit.moduleclasspath"/>
- <path location="${clover.jar}"/>
- </path>
-
- <!-- Clover tasks -->
- <target name="with.clover">
- <clover-setup initString="clover_coverage.db"/>
- </target>
-
- <target name="cloverreport.html" depends="with.clover"
- description="Generate a clover report from the current clover database.">
- <clover-report>
- <current outfile="${clover.out.dir}">
- <format type="html"/>
- </current>
- </clover-report>
- </target>
-
- <target name="cloverreport" depends="with.clover,junitreport,cloverreport.html"
- description="Run the tests and generate a clover report">
- </target>
-
- <!-- Tasks -->
-
- <target name="clean" description="Cleans up build and dist directories">
- <delete dir="${build.dir}"/>
- <delete dir="${dist.target.dir}"/>
- <delete dir="${clover.out.dir}"/>
- </target>
-
- <target name="init" description="Initialize the build">
- <tstamp>
- <format property="subversion" pattern="yyyy-MM-dd hh:mm:ss"/>
- </tstamp>
- <echo message="Build ${Name}-${version} (${subversion})"/>
- <mkdir dir="${classes.dir}"/>
- <mkdir dir="${testclasses.dir}"/>
- <copy todir="${classes.dir}">
- <fileset dir="${src.dir}">
- <patternset refid="support.files"/>
- </fileset>
- </copy>
-
- <copy todir="${build.dir}">
- <fileset dir=".">
- <include name="readme.txt"/>
- <include name="lgpl.txt"/>
- </fileset>
- </copy>
- </target>
-
- <target name="compiletest" depends="compile,get.deps.test,test-resources" description="Compile the tests">
- <available
- classname="org.eclipse.core.launcher.Main"
- property="build.compiler"
- value="org.eclipse.jdt.core.JDTCompilerAdapter"
- classpath="${java.class.path}"/>
- <javac
- target="${javac.target}"
- source="${javac.source}"
- destdir="${testclasses.dir}"
- classpathref="junit.classpath"
- debug="${javac.debug}"
- optimize="${javac.optimize}"
- nowarn="on">
- <src refid="testsrc.path"/>
- </javac>
- </target>
-
- <target name="test-resources" description="Copies test resources">
- <mkdir dir="${testclasses.dir}"/>
- <copy todir="${testclasses.dir}" overwrite="true">
- <fileset dir="${test.resources.dir}">
- <include name="*.properties"/>
- <include name="*.xml"/>
- </fileset>
- </copy>
- </target>
-
- <target name="resources" description="Copies resources">
- <mkdir dir="${classes.dir}"/>
- <copy todir="${classes.dir}" overwrite="true">
- <fileset dir="${resources.dir}">
- <include name="**/*.properties"/>
- <include name="**/*.xml"/>
- </fileset>
- </copy>
- </target>
-
- <target name="instrument" depends="compiletest"
- description="Instrument the persistent classes"> <!-- depends="jar" -->
-
- <taskdef name="instrument" classname="org.hibernate.tool.instrument.InstrumentTask">
- <classpath path="${classes.dir}"/>
- <classpath path="${testclasses.dir}"/>
- <classpath refid="lib.class.path"/>
- </taskdef>
-
- <instrument verbose="true">
- <fileset dir="${testclasses.dir}/org/hibernate/test">
- <include name="**/*.class"/>
- <exclude name="**/*Test$*.class"/>
- <exclude name="**/*Test.class"/>
- <exclude name="**/*Tests.class"/>
- </fileset>
- </instrument>
- </target>
-
- <target name="copytest" description="Copy tests to dist dir" if="copy.test" >
- <mkdir dir="${dist.test.dir}"/>
- <copy todir="${dist.test.dir}">
- <fileset dir="${test.dir}"/>
- </copy>
- </target>
-
- <target name="copysource" depends="copytest" description="Copy sources to dist dir">
- <mkdir dir="${dist.src.dir}"/>
- <copy todir="${dist.src.dir}">
- <fileset dir="${src.dir}">
- <patternset refid="source.files"/>
- </fileset>
- <fileset dir="${src.dir}">
- <patternset refid="support.files"/>
- </fileset>
- </copy>
- <mkdir dir="${dist.src.dir}"/>
- <copy todir="${dist.src.dir}">
- <fileset dir="${src.dir}">
- <patternset refid="source.files"/>
- </fileset>
- <fileset dir="${src.dir}">
- <patternset refid="support.files"/>
- </fileset>
- </copy>
- </target>
-
- <target name="copylib" description="Copy jars to lib dir">
- <mkdir dir="${dist.lib.dir}"/>
- <copy todir="${dist.lib.dir}">
- <fileset dir="${lib.dir}">
- <include name="*.jar"/>
- <exclude name="log4j.jar"/>
- <exclude name="checkstyle*.jar"/>
- <include name="*.txt"/>
- </fileset>
- </copy>
- </target>
-
- <target name="copydoc" description="Copy doc to dist dir" if="copy.doc">
- <mkdir dir="${dist.doc.dir}"/>
- <copy todir="${dist.doc.dir}">
- <fileset dir="${doc.dir}">
- <include name="**/*.html"/>
- </fileset>
- </copy>
- </target>
-
- <target name="jar" depends="compile" description="Build the distribution .jar file">
- <mkdir dir="${dist.dir}"/>
- <jar filesetmanifest="merge" jarfile="${jar.file.name}" basedir="${classes.dir}"/>
- </target>
-
- <target name="jartest" depends="compiletest" description="Build the distribution .jar file">
- <mkdir dir="${dist.dir}"/>
- <jar filesetmanifest="merge" jarfile="${jartest.file.name}" basedir="${testclasses.dir}"/>
- </target>
-
- <!-- DOCUMENTATION -->
-
- <target name="javadoc" description="Compile the Javadoc API documentation to dist dir">
- <mkdir dir="${dist.api.dir}"/>
- <javadoc
- packagenames="${javadoc.packagenames}"
- classpathref="lib.class.path"
- destdir="${dist.api.dir}"
- use="true"
- protected="true"
- version="true"
- windowtitle="${Name} API Documentation"
- Overview="${doc.api.dir}/package.html"
- doctitle="${Name} API Documentation"
- stylesheetfile="${doc.api.dir}/jdstyle.css"
- link="${javadoc}">
- <packageset dir="${src.dir}" defaultexcludes="yes" >
- <include name="**/*" />
- </packageset>
- </javadoc>
- </target>
-
-
- <target name="extras" description="Copies miscellaneous files to root dir">
- <copy todir="${dist.dir}/bin" failonerror="false">
- <fileset dir="bin">
- <include name="*.bat"/>
- </fileset>
- </copy>
- <copy file="readme.txt" todir="${dist.dir}"/>
- <copy file="lgpl.txt" todir="${dist.dir}"/>
- <copy file="changelog.txt" todir="${dist.dir}"/>
- <copy file="build.xml" todir="${dist.dir}"/>
- <replace file="${dist.dir}/build.xml">
- <replacetoken><![CDATA[../${name}-${version}]]></replacetoken>
- <replacevalue><![CDATA[../${name}]]></replacevalue>
- </replace>
- </target>
-
- <target name="dist" depends="jar,javadoc,copysource,copylib,copydoc,extras" description="Build everything">
- <zip zipfile = "${dist.dir}-${version}.zip">
- <zipfileset prefix="${name}-${version}" dir="${dist.dir}"/>
- </zip>
- <tar compression="gzip" tarfile="${dist.dir}-${version}.tar.gz">
- <tarfileset prefix="${name}-${version}" dir="${dist.dir}"/>
- </tar>
- </target>
-
- <target name="info" description="Echoes useful system properties">
- <echo message="java.vm.info=${java.vm.info}"/>
- <echo message="java.vm.name=${java.vm.name}"/>
- <echo message="java.vm.vendor=${java.vm.vendor}"/>
- <echo message="java.vm.version=${java.vm.version}"/>
- <echo message="os.arch=${os.arch}"/>
- <echo message="os.name=${os.name}"/>
- <echo message="os.version=${os.version}"/>
- <echo message="java.home = ${java.home}"/>
- <echo message="java.class.path = ${java.class.path}"/>
- <echo message="build.compiler = ${build.compiler}"/>
- <echo message="file.encoding=${file.encoding}"/>
- <echo message="user.home = ${user.home}"/>
- <echo message="user.language=${user.language}"/>
- </target>
-
- <target name="junit" depends="compiletest">
- <mkdir dir="${test.output}"/>
- <junit printsummary="yes" haltonfailure="yes" forkmode="once">
- <classpath refid="junit.classpath"/>
- <formatter type="plain"/>
- <formatter type="xml"/>
- <batchtest fork="yes" todir="${test.output}" haltonfailure="no">
- <fileset refid="junit.batchtestset"/>
- </batchtest>
- </junit>
- </target>
-
- <!-- Run a single unit test. -->
- <target name="junitsingle" depends="compiletest" description="Run a single test suite (requires testname and jdbc.driver properties)">
- <mkdir dir="${test.output}"/>
- <junit printsummary="yes" fork="yes" haltonfailure="yes">
- <classpath refid="junit.classpath"/>
- <formatter type="plain"/>
- <formatter type="xml"/>
- <test fork="yes" todir="${test.output}" haltonfailure="no" name="${testname}"/>
- </junit>
- </target>
-
- <target name="junitinstrument" depends="compiletest,instrument"
- description="Run the instrument test suite (requires driver.jar property)">
- <mkdir dir="${instrumenttest.out.dir}"/>
- <junit printsummary="yes" haltonfailure="yes" dir="${basedir}"
- maxmemory="256M" fork="yes" forkmode="perBatch">
- <classpath refid="junit.classpath"/>
- <formatter type="plain"/>
- <formatter type="xml"/>
- <batchtest todir="${instrumenttest.out.dir}" haltonfailure="no">
- <fileset dir="${classes.dir}">
- <include name="org/hibernate/test/**/*Test.class"/>
- </fileset>
- </batchtest>
- </junit>
- </target>
-
- <target name="junitreport" depends="">
- <junitreport todir="${test.output}">
- <fileset dir="${test.output}">
- <include name="TEST-*.xml"/>
- </fileset>
- <report format="frames" todir="./${test.output}"/>
- </junitreport>
- </target>
-
- <target name="run" depends="compile" description="Run Hibernate Console">
- <java classname="org.hibernate.console.Start" classpathref="lib.class.path" fork="true">
- <classpath>
- <path location="${build.dir}"/>
- </classpath>
- </java>
- </target>
-
- <target name="checkstyle" description="Check coding style">
- <taskdef resource="checkstyletask.properties">
- <classpath>
- <path refid="lib.class.path"/>
- <fileset dir="${common-build.basedir}/lib">
- <include name="checkstyle*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
-
- <checkstyle config="${common-build.basedir}/checkstyle_checks.xml">
- <fileset dir="src/main/java">
- <include name="**/*.java"/>
- </fileset>
- <formatter type="plain"/>
- </checkstyle>
- </target>
-
- <target name="patch" depends="checkstyle"
- description="Create a patch">
- <cvs command="-q diff -u -N" output="patch.txt"/>
- </target>
-
- <!-- maven deploy: to be used by the subbuild and delcare deps on jar -->
- <target name="deploy" depends="jar">
- <fail unless="offline.repository.jboss.org" message="offline.repository.jboss.org must be defined"/>
- <jar jarfile="${src.jar}" basedir="${src.dir}">
- <include name="**/*.java" />
- <exclude name="**/test/*.java" />
- <!-- patternset refid="meta.files" / -->
- </jar>
-
- <artifact:pom id="maven.project" file="${pom.file}" />
-
- <artifact:install file="${jar.file.name}">
- <pom refid="maven.project"/>
- </artifact:install>
-
- <artifact:deploy file="${jar.file.name}">
- <pom refid="maven.project" />
- <remoteRepository refId="offline.repository.jboss.org">
- </remoteRepository>
- <attach file="${src.jar}" classifier="sources" />
- <attach file="${jar.file.name}" classifier="" />
- </artifact:deploy>
- </target>
-
-</project>
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator-legacy/ivy.xml
===================================================================
--- validator/trunk/hibernate-validator-legacy/ivy.xml 2008-10-09 07:17:13 UTC (rev 15299)
+++ validator/trunk/hibernate-validator-legacy/ivy.xml 2008-10-09 08:57:53 UTC (rev 15300)
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ivy-module version="1.3"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation=
- "http://www.jayasoft.org/misc/ivy/ivy.xsd">
- <info organisation="org.hibernate" module="validator"/>
- <configurations>
- <conf name="default" description="Core module dependencies"/>
- <conf name="test" visibility="private" description="Dependencies needed for testing purposes"/>
- </configurations>
- <publications>
- <artifact name="hibernate-validator" conf="default"/>
- </publications>
- <dependencies>
- <!-- compile time dependencies -->
- <dependency name="ejb3-persistence" rev="1.0.2.GA" conf="default->default"/>
- <dependency name="commons-annotations" rev="3.1.0.GA" conf="default->default"/>
- <dependency org="org.hibernate" name="hibernate-core" rev="3.3.0.SP1" conf="default->default"/>
- <dependency org="org.slf4j" name="slf4j-api" rev="1.4.2" conf="default->default"/>
-
- <!-- transitive dependencies -->
- <dependency org="antlr" name="antlr" rev="2.7.6" conf="test->default"/>
- <dependency org="commons-collections" name="commons-collections" rev="3.1" conf="test->default"/>
- <dependency org="dom4j" name="dom4j" rev="1.6.1" conf="test->default"/>
-
- <!-- test deps -->
- <dependency name="annotations" rev="3.4.0.GA" conf="test->default"/>
- <dependency name="entitymanager" rev="3.4.0.GA" conf="test->default"/>
- <dependency org="javassist" name="javassist" rev="3.4.GA" conf="default->default"/>
- <dependency org="asm" name="asm" rev="1.5.3" conf="test->default"/>
- <dependency org="asm" name="asm-attrs" rev="1.5.3" conf="test->default"/>
- <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.4.2" conf="test->default"/>
- <dependency org="log4j" name="log4j" rev="1.2.14" conf="test->default"/>
- <dependency org="junit" name="junit" rev="3.8.1" conf="test->default"/>
- <dependency org="javax.transaction" name="jta" rev="1.1" conf="test->default"/>
- </dependencies>
-</ivy-module>
\ No newline at end of file
Modified: validator/trunk/hibernate-validator-legacy/pom.xml
===================================================================
--- validator/trunk/hibernate-validator-legacy/pom.xml 2008-10-09 07:17:13 UTC (rev 15299)
+++ validator/trunk/hibernate-validator-legacy/pom.xml 2008-10-09 08:57:53 UTC (rev 15300)
@@ -1,15 +1,13 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
-
<parent>
<artifactId>hibernate-validator-parent</artifactId>
<groupId>org.hibernate</groupId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
-
<artifactId>hibernate-validator-legacy</artifactId>
<packaging>jar</packaging>
<name>Hibernate Validator (legacy)</name>
@@ -27,6 +25,7 @@
<scm>
<url>http://anonhibernate.labs.jboss.com/trunk/HibernateExt/validator</url>
</scm>
+
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
@@ -43,7 +42,6 @@
<artifactId>slf4j-api</artifactId>
<version>1.4.2</version>
</dependency>
-
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>ejb3-persistence</artifactId>
@@ -62,7 +60,6 @@
<version>3.4.0.GA</version>
<optional>true</optional>
</dependency>
-
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
@@ -81,7 +78,7 @@
<version>1.5.3</version>
<scope>test</scope>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.4.2</version>
@@ -93,7 +90,7 @@
<version>1.2.14</version>
<scope>test</scope>
</dependency>
- <dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
@@ -111,6 +108,95 @@
<version>1.8.0.2</version>
<scope>test</scope>
</dependency>
+ </dependencies>
- </dependencies>
-</project>
\ No newline at end of file
+ <profiles>
+ <profile>
+ <id>dist</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/dist.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-javadoc</id>
+ <phase>package</phase>
+ <goals>
+ <goal>javadoc</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <version>2.1.0</version>
+ <extensions>true</extensions>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jdocbook-style</artifactId>
+ <version>1.0.2</version>
+ <type>jdocbook-style</type>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <sourceDocumentName>master.xml</sourceDocumentName>
+ <sourceDirectory>${basedir}/src/main/docbook/en-US</sourceDirectory>
+ <masterTranslation>en-US</masterTranslation>
+ <imageResource>
+ <directory>${basedir}/src/main/docbook/en-US/images</directory>
+ </imageResource>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>classpath:/xslt/hibernate/pdf/main-pdf.xsl</stylesheetResource>
+ <finalName>hibernate-validator-legacy-guide.pdf</finalName>
+ </format>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/hibernate/html/main-single.xsl
+ </stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/hibernate/html/main-chunk.xsl
+ </stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
+ <options>
+ <xincludeSupported>true</xincludeSupported>
+ <localeSeparator>-</localeSeparator>
+ <useRelativeImageUris>true</useRelativeImageUris>
+ </options>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-doc</id>
+ <phase>package</phase>
+ <goals>
+ <goal>resources</goal>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
Added: validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/images/hibernate_logo_a.png
===================================================================
(Binary files differ)
Property changes on: validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/images/hibernate_logo_a.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/master.xml
===================================================================
--- validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/master.xml (rev 0)
+++ validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/master.xml 2008-10-09 08:57:53 UTC (rev 15300)
@@ -0,0 +1,92 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+ <!ENTITY versionNumber "3.1.0.GA">
+ <!ENTITY copyrightYear "2004">
+ <!ENTITY copyrightHolder "Red Hat Middleware, LLC.">
+]>
+
+<book lang="en">
+ <bookinfo>
+ <title>Hibernate Validator</title>
+ <subtitle>Reference Guide</subtitle>
+ <releaseinfo>&versionNumber;</releaseinfo>
+ <productnumber>&versionNumber;</productnumber>
+ <issuenum>1</issuenum>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/hibernate_logo_a.png" format="png" />
+ </imageobject>
+ </mediaobject>
+ <copyright>
+ <year>©rightYear;</year>
+ <holder>©rightHolder;</holder>
+ </copyright>
+ <!-- include translators... -->
+ </bookinfo>
+
+ <toc/>
+
+ <preface id="preface" revision="2">
+ <title>Preface</title>
+
+ <para>Annotations are a very convenient and elegant way to specify
+ invariant constraints for a domain model. You can, for example, express
+ that a property should never be null, that the account balance should be
+ strictly positive, etc. These domain model constraints are declared in the
+ bean itself by annotating its properties. A validator can then read them
+ and check for constraint violations. The validation mechanism can be
+ executed in different layers in your application without having to
+ duplicate any of these rules (presentation layer, data access layer).
+ Following the DRY principle, Hibernate Validator has been designed for
+ that purpose.</para>
+
+ <para>Hibernate Validator works at two levels. First, it is able to check
+ in-memory instances of a class for constraint violations. Second, it can
+ apply the constraints to the Hibernate metamodel and incorporate them into
+ the generated database schema.</para>
+
+ <para>Each constraint annotation is associated to a validator
+ implementation responsible for checking the constraint on the entity
+ instance. A validator can also (optionally) apply the constraint to the
+ Hibernate metamodel, allowing Hibernate to generate DDL that expresses the
+ constraint. With the appropriate event listener, you can execute the
+ checking operation on inserts and updates done by Hibernate. Hibernate
+ Validator is not limited to use with Hibernate. You can easily use it
+ anywhere in your application as well as with any Java Persistence provider
+ (entity listener provided).</para>
+
+ <para>When checking instances at runtime, Hibernate Validator returns
+ information about constraint violations in an array of
+ <classname>InvalidValue</classname> s. Among other information, the
+ <classname>InvalidValue</classname> contains an error description message
+ that can embed the parameter values bundle with the annotation (eg. length
+ limit), and message strings that may be externalized to a
+ <classname>ResourceBundle</classname> .</para>
+ </preface>
+
+ <xi:include href="modules/defineconstraints.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="modules/checkconstraints.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+</book>
\ No newline at end of file
Added: validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/modules/checkconstraints.xml
===================================================================
--- validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/modules/checkconstraints.xml (rev 0)
+++ validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/modules/checkconstraints.xml 2008-10-09 08:57:53 UTC (rev 15300)
@@ -0,0 +1,235 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+
+<chapter id="validator-checkconstraints">
+ <title>Using the Validator framework</title>
+
+ <para>Hibernate Validator is intended to be used to implement multi-layered
+ data validation, where constraints are expressed in a single place (the
+ annotated domain model) and checked in various different layers of the
+ application.</para>
+
+ <para>This chapter will cover Hibernate Validator usage for different
+ layers</para>
+
+ <section id="validator-checkconstraints-db" revision="2">
+ <title>Database schema-level validation</title>
+
+ <para>Out of the box, Hibernate Annotations will translate the constraints
+ you have defined for your entities into mapping metadata. For example, if
+ a property of your entity is annotated <literal>@NotNull</literal>, its
+ columns will be declared as <literal>not null</literal> in the DDL schema
+ generated by Hibernate.</para>
+
+ <para>Using hbm2ddl, domain model constraints will be expressed into the
+ database schema.</para>
+
+ <para>If, for some reason, the feature needs to be disabled, set
+ <literal>hibernate.validator.apply_to_ddl</literal> to
+ <literal>false</literal>.</para>
+ </section>
+
+ <section id="validator-checkconstraints-orm">
+ <title>ORM integration</title>
+
+ <para>Hibernate Validator integrates with both Hibernate and all pure Java
+ Persistence providers</para>
+
+ <section id="validator-checkconstraints-orm-hibernateevent" revision="1">
+ <title>Hibernate event-based validation</title>
+
+ <para>Hibernate Validator has two built-in Hibernate event listeners.
+ Whenever a <literal>PreInsertEvent</literal> or
+ <literal>PreUpdateEvent</literal> occurs, the listeners will verify all
+ constraints of the entity instance and throw an exception if any
+ constraint is violated. Basically, objects will be checked before any
+ inserts and before any updates made by Hibernate. This includes changes
+ applied by cascade! This is the most convenient and the easiest way to
+ activate the validation process. On constraint violation, the event will
+ raise a runtime <classname>InvalidStateException</classname> which
+ contains an array of <literal>InvalidValue</literal>s describing each
+ failure.</para>
+
+ <para>If Hibernate Validator is present in the classpath, Hibernate
+ Annotations (or Hibernate EntityManager) will use it transparently. If,
+ for some reason, you want to disable this integration, set
+ <literal>hibernate.validator.autoregister_listeners</literal> to
+ false</para>
+
+ <para><note>
+ <para>If the beans are not annotated with validation annotations,
+ there is no runtime performance cost.</para>
+ </note></para>
+
+ <para>In case you need to manually set the event listeners for Hibernate
+ Core, use the following configuration in
+ <literal>hibernate.cfg.xml</literal>:</para>
+
+ <programlisting><hibernate-configuration>
+ ...
+ <event type="pre-update">
+ <listener
+ class="org.hibernate.validator.event.ValidateEventListener"/>
+ </event>
+ <event type="pre-insert">
+ <listener
+ class="org.hibernate.validator.event.ValidateEventListener"/>
+ </event>
+</hibernate-configuration></programlisting>
+ </section>
+
+ <section id="validator-checkconstraints-orm-jpaevent">
+ <title>Java Persistence event-based validation</title>
+
+ <para>Hibernate Validator is not tied to Hibernate for event based
+ validation: a Java Persistence entity listener is available. Whenever an
+ listened entity is persisted or updated, Hibernate Validator will verify
+ all constraints of the entity instance and throw an exception if any
+ constraint is violated. Basically, objects will be checked before any
+ inserts and before any updates made by the Java Persistence provider.
+ This includes changes applied by cascade! On constraint violation, the
+ event will raise a runtime <classname>InvalidStateException</classname>
+ which contains an array of <literal>InvalidValue</literal>s describing
+ each failure.</para>
+
+ <para>Here is how to make a class validatable:</para>
+
+ <programlisting>@Entity
+ at EntityListeners( JPAValidateListener.class )
+public class Submarine {
+ ...
+}</programlisting>
+
+ <para><note>
+ <para>Compared to the Hibernate event, the Java Persistence listener
+ has two drawbacks. You need to define the entity listener on every
+ validatable entity. The DDL generated by your provider will not
+ reflect the constraints.</para>
+ </note></para>
+ </section>
+ </section>
+
+ <section>
+ <title>Application-level validation</title>
+
+ <para>Hibernate Validator can be applied anywhere in your application
+ code.</para>
+
+ <programlisting>ClassValidator personValidator = new ClassValidator( Person.class );
+ClassValidator addressValidator = new ClassValidator( Address.class, ResourceBundle.getBundle("messages", Locale.ENGLISH) );
+
+InvalidValue[] validationMessages = addressValidator.getInvalidValues(address);</programlisting>
+
+ <para>The first two lines prepare the Hibernate Validator for class
+ checking. The first one relies upon the error messages embedded in
+ Hibernate Validator (see <xref
+ linkend="validator-defineconstraints-error" />), the second one uses a
+ resource bundle for these messages. It is considered a good practice to
+ execute these lines once and cache the validator instances.</para>
+
+ <para>The third line actually validates the <literal>Address</literal>
+ instance and returns an array of <literal>InvalidValue</literal>s. Your
+ application logic will then be able to react to the failure.</para>
+
+ <para>You can also check a particular property instead of the whole bean.
+ This might be useful for property per property user interaction</para>
+
+ <programlisting>ClassValidator addressValidator = new ClassValidator( Address.class, ResourceBundle.getBundle("messages", Locale.ENGLISH) );
+
+//only get city property invalid values
+InvalidValue[] validationMessages = addressValidator.getInvalidValues(address, "city");
+
+//only get potential city property invalid values
+InvalidValue[] validationMessages = addressValidator.getPotentialInvalidValues("city", "Paris")</programlisting>
+ </section>
+
+ <section>
+ <title>Presentation layer validation</title>
+
+ <para>When working with JSF and <productname>JBoss Seam</productname>, one
+ can triggers the validation process at the presentation layer using Seam's
+ JSF tags <literal><s:validate></literal> and
+ <literal><s:validateAll/></literal>, letting the constraints be
+ expressed on the model, and the violations presented in the view</para>
+
+ <programlisting><h:form>
+ <div>
+ <h:messages/>
+ </div>
+ <emphasis role="bold"><s:validateAll></emphasis>
+ <div>
+ Country:
+ <h:inputText value="#{location.country}" required="true"/>
+ </div>
+ <div>
+ Zip code:
+ <h:inputText value="#{location.zip}" required="true"/>
+ </div>
+ <div>
+ <h:commandButton/>
+ </div>
+ <emphasis role="bold"></s:validateAll></emphasis>
+</h:form></programlisting>
+
+ <para>Going even further, and adding <productname>Ajax4JSF</productname>
+ to the loop will bring client side validation with just a couple of
+ additional JSF tags, again without validation definition
+ duplication.</para>
+
+ <para>Check the <ulink url="http://www.jboss.com/products/seam">JBoss
+ Seam</ulink> documentation for more information.</para>
+ </section>
+
+ <section>
+ <title>Validation informations</title>
+
+ <para>As a validation information carrier, hibernate provide an array of
+ <classname>InvalidValue</classname>. Each <literal>InvalidValue</literal>
+ has a buch of methods describing the individual issues.</para>
+
+ <para><methodname>getBeanClass()</methodname> retrieves the failing bean
+ type</para>
+
+ <para><methodname>getBean()</methodname>retrieves the failing instance (if
+ any ie not when using
+ <methodname>getPotentianInvalidValues()</methodname>)</para>
+
+ <para><methodname>getValue()</methodname> retrieves the failing
+ value</para>
+
+ <para><methodname>getMessage()</methodname> retrieves the proper
+ internationalized error message</para>
+
+ <para><methodname>getRootBean()</methodname> retrieves the root bean
+ instance generating the issue (useful in conjunction with
+ <literal>@Valid</literal>), is null if getPotentianInvalidValues() is
+ used.</para>
+
+ <para><literal>getPropertyPath()</literal> retrieves the dotted path of
+ the failing property starting from the root bean</para>
+ </section>
+</chapter>
\ No newline at end of file
Added: validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/modules/defineconstraints.xml
===================================================================
--- validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/modules/defineconstraints.xml (rev 0)
+++ validator/trunk/hibernate-validator-legacy/src/main/docbook/en-US/modules/defineconstraints.xml 2008-10-09 08:57:53 UTC (rev 15300)
@@ -0,0 +1,494 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+
+<chapter id="validator-defineconstraints">
+ <title>Defining constraints</title>
+
+ <section id="validator-defineconstraints-definition" revision="1">
+ <title>What is a constraint?</title>
+
+ <para>A constraint is a rule that a given element (field, property or
+ bean) has to comply to. The rule semantic is expressed by an annotation. A
+ constraint usually has some attributes used to parameterize the
+ constraints limits. The constraint applies to the annotated
+ element.</para>
+ </section>
+
+ <section id="validator-defineconstraints-builtin" revision="2">
+ <title>Built in constraints</title>
+
+ <para>Hibernate Validator comes with some built-in constraints, which
+ covers most basic data checks. As we'll see later, you're not limited to
+ them, you can literally in a minute write your own constraints.</para>
+
+ <table>
+ <title>Built-in constraints</title>
+
+ <tgroup cols="4">
+ <colspec align="center" />
+
+ <thead>
+ <row>
+ <entry>Annotation</entry>
+
+ <entry>Apply on</entry>
+
+ <entry>Runtime checking</entry>
+
+ <entry>Hibernate Metadata impact</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>@Length(min=, max=)</entry>
+
+ <entry>property (String)</entry>
+
+ <entry>check if the string length match the range</entry>
+
+ <entry>Column length will be set to max</entry>
+ </row>
+
+ <row>
+ <entry>@Max(value=)</entry>
+
+ <entry>property (numeric or string representation of a
+ numeric)</entry>
+
+ <entry>check if the value is less than or equals to max</entry>
+
+ <entry>Add a check constraint on the column</entry>
+ </row>
+
+ <row>
+ <entry>@Min(value=)</entry>
+
+ <entry>property (numeric or string representation of a
+ numeric)</entry>
+
+ <entry>check if the value is more than or equals to min</entry>
+
+ <entry>Add a check constraint on the column</entry>
+ </row>
+
+ <row>
+ <entry>@NotNull</entry>
+
+ <entry>property</entry>
+
+ <entry>check if the value is not null</entry>
+
+ <entry>Column(s) are not null</entry>
+ </row>
+
+ <row>
+ <entry>@NotEmpty</entry>
+
+ <entry>property</entry>
+
+ <entry>check if the string is not null nor empty. Check if the
+ connection is not null nor empty</entry>
+
+ <entry>Column(s) are not null (for String)</entry>
+ </row>
+
+ <row>
+ <entry>@Past</entry>
+
+ <entry>property (date or calendar)</entry>
+
+ <entry>check if the date is in the past</entry>
+
+ <entry>Add a check constraint on the column</entry>
+ </row>
+
+ <row>
+ <entry>@Future</entry>
+
+ <entry>property (date or calendar)</entry>
+
+ <entry>check if the date is in the future</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@Pattern(regex="regexp", flag=) or @Patterns(
+ {@Pattern(...)} )</entry>
+
+ <entry>property (string)</entry>
+
+ <entry>check if the property match the regular expression given a
+ match flag (see <classname>java.util.regex.Pattern </classname>
+ )</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@Range(min=, max=)</entry>
+
+ <entry>property (numeric or string representation of a
+ numeric)</entry>
+
+ <entry>check if the value is between min and max
+ (included)</entry>
+
+ <entry>Add a check constraint on the column</entry>
+ </row>
+
+ <row>
+ <entry>@Size(min=, max=)</entry>
+
+ <entry>property (array, collection, map)</entry>
+
+ <entry>check if the element size is between min and max
+ (included)</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@AssertFalse</entry>
+
+ <entry>property</entry>
+
+ <entry>check that the method evaluates to false (useful for
+ constraints expressed in code rather than annotations)</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@AssertTrue</entry>
+
+ <entry>property</entry>
+
+ <entry>check that the method evaluates to true (useful for
+ constraints expressed in code rather than annotations)</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@Valid</entry>
+
+ <entry>property (object)</entry>
+
+ <entry>perform validation recursively on the associated object. If
+ the object is a Collection or an array, the elements are validated
+ recursively. If the object is a Map, the value elements are
+ validated recursively.</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@Email</entry>
+
+ <entry>property (String)</entry>
+
+ <entry>check whether the string is conform to the email address
+ specification</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@CreditCardNumber</entry>
+
+ <entry>property (String)</entry>
+
+ <entry>check whether the string is a well formated credit card
+ number (derivative of the Luhn algorithm)</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@Digits</entry>
+
+ <entry>property (numeric or string representation of a
+ numeric)</entry>
+
+ <entry>check whether the property is a number having up to
+ <literal>integerDigits</literal> integer digits and
+ <literal>fractionalDigits</literal> fractonal digits</entry>
+
+ <entry>define column precision and scale</entry>
+ </row>
+
+ <row>
+ <entry>@EAN</entry>
+
+ <entry>property (string)</entry>
+
+ <entry>check whether the string is a properly formated EAN or
+ UPC-A code</entry>
+
+ <entry>none</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+
+ <section id="validator-defineconstraints-error" xreflabel="Error messages">
+ <title>Error messages</title>
+
+ <para>Hibernate Validator comes with a default set of error messages
+ translated in about ten languages (if yours is not part of it, please sent
+ us a patch). You can override those messages by creating a
+ <filename>ValidatorMessages.properties</filename> or (
+ <filename>ValidatorMessages_loc.properties</filename> ) and override the
+ needed keys. You can even add your own additional set of messages while
+ writing your validator annotations. If Hibernate Validator cannot resolve
+ a key from your resourceBundle nor from ValidatorMessage, it falls back to
+ the default built-in values.</para>
+
+ <para>Alternatively you can provide a
+ <classname>ResourceBundle</classname> while checking programmatically the
+ validation rules on a bean or if you want a completly different
+ interpolation mechanism, you can provide an implementation of
+ <literal>org.hibernate.validator.MessageInterpolator</literal> (check the
+ JavaDoc for more informations).</para>
+ </section>
+
+ <section id="validator-defineconstraints-own" revision="1">
+ <title>Writing your own constraints</title>
+
+ <para>Extending the set of built-in constraints is extremely easy. Any
+ constraint consists of two pieces: the constraint
+ <emphasis>descriptor</emphasis> (the annotation) and the constraint
+ <emphasis>validator</emphasis> (the implementation class). Here is a
+ simple user-defined descriptor:</para>
+
+ <programlisting>@ValidatorClass(CapitalizedValidator.class)
+ at Target(METHOD)
+ at Retention(RUNTIME)
+ at Documented
+public @interface Capitalized {
+ CapitalizeType type() default Capitalize.FIRST;
+ String message() default "has incorrect capitalization"
+} </programlisting>
+
+ <para><literal>type</literal> is a parameter describing how the property
+ should to be capitalized. This is a user parameter fully dependant on the
+ annotation business.</para>
+
+ <para><literal>message</literal> is the default string used to describe
+ the constraint violation and is mandatory. You can hard code the string or
+ you can externalize part/all of it through the Java ResourceBundle
+ mechanism. Parameters values are going to be injected inside the message
+ when the <literal>{parameter}</literal> string is found (in our example
+ <literal>Capitalization is not {type}</literal> would generate
+ <literal>Capitalization is not FIRST</literal> ), externalizing the whole
+ string in <filename>ValidatorMessages.properties</filename> is considered
+ good practice. See <xref linkend="validator-defineconstraints-error" />
+ .</para>
+
+ <programlisting>@ValidatorClass(CapitalizedValidator.class)
+ at Target(METHOD)
+ at Retention(RUNTIME)
+ at Documented
+public @interface Capitalized {
+ CapitalizeType type() default Capitalize.FIRST;
+ String message() default "{validator.capitalized}";
+}
+
+
+#in ValidatorMessages.properties
+validator.capitalized = <literal>Capitalization is not {type}</literal>
+ </programlisting>
+
+ <para>As you can see the {} notation is recursive.</para>
+
+ <para>To link a descriptor to its validator implementation, we use the
+ <literal>@ValidatorClass</literal> meta-annotation. The validator class
+ parameter must name a class which implements
+ <literal>Validator<ConstraintAnnotation></literal> .</para>
+
+ <para>We now have to implement the validator (ie. the rule checking
+ implementation). A validation implementation can check the value of the a
+ property (by implementing <literal>PropertyConstraint</literal> ) and/or
+ can modify the hibernate mapping metadata to express the constraint at the
+ database level (by implementing
+ <literal>PersistentClassConstraint</literal> )</para>
+
+ <programlisting>public class CapitalizedValidator
+ implements Validator<Capitalized>, PropertyConstraint {
+ private CapitalizeType type;
+
+ //part of the Validator<Annotation> contract,
+ //allows to get and use the annotation values
+ public void initialize(Capitalized parameters) {
+ type = parameters.type();
+ }
+
+ //part of the property constraint contract
+ public boolean isValid(Object value) {
+ if (value==null) return true;
+ if ( !(value instanceof String) ) return false;
+ String string = (String) value;
+ if (type == CapitalizeType.ALL) {
+ return string.equals( string.toUpperCase() );
+ }
+ else {
+ String first = string.substring(0,1);
+ return first.equals( first.toUpperCase();
+ }
+ }
+} </programlisting>
+
+ <para>The <literal>isValid()</literal> method should return false if the
+ constraint has been violated. For more examples, refer to the built-in
+ validator implementations.</para>
+
+ <para>We only have seen property level validation, but you can write a
+ Bean level validation annotation. Instead of receiving the return instance
+ of a property, the bean itself will be passed to the validator. To
+ activate the validation checking, just annotated the bean itself instead.
+ A small sample can be found in the unit test suite.</para>
+
+ <para>If your constraint can be applied multiple times (with different
+ parameters) on the same property or type, you can use the following
+ annotation form:</para>
+
+ <programlisting>@Target(METHOD)
+ at Retention(RUNTIME)
+ at Documented
+<emphasis role="bold">public @interface Patterns {</emphasis>
+ Pattern[] value();
+}
+
+ at Target(METHOD)
+ at Retention(RUNTIME)
+ at Documented
+ at ValidatorClass(PatternValidator.class)
+public @interface Pattern {
+ String regexp();
+}</programlisting>
+
+ <para>Basically an annotation containing the value attribute as an array
+ of validator annotations.</para>
+ </section>
+
+ <section>
+ <title>Annotating your domain model</title>
+
+ <para>Since you are already familiar with annotations now, the syntax
+ should be very familiar</para>
+
+ <programlisting>public class Address {
+ private String line1;
+ private String line2;
+ private String zip;
+ private String state;
+ private String country;
+ private long id;
+
+ // a not null string of 20 characters maximum
+ @Length(max=20)
+ @NotNull
+ public String getCountry() {
+ return country;
+ }
+
+ // a non null string
+ @NotNull
+ public String getLine1() {
+ return line1;
+ }
+
+ //no constraint
+ public String getLine2() {
+ return line2;
+ }
+
+ // a not null string of 3 characters maximum
+ @Length(max=3) @NotNull
+ public String getState() {
+ return state;
+ }
+
+ // a not null numeric string of 5 characters maximum
+ // if the string is longer, the message will
+ //be searched in the resource bundle at key 'long'
+ @Length(max=5, message="{long}")
+ @Pattern(regex="[0-9]+")
+ @NotNull
+ public String getZip() {
+ return zip;
+ }
+
+ // should always be true
+ @AssertTrue
+ public boolean isValid() {
+ return true;
+ }
+
+ // a numeric between 1 and 2000
+ @Id @Min(1)
+ @Range(max=2000)
+ public long getId() {
+ return id;
+ }
+} </programlisting>
+
+ <para>While the example only shows public property validation, you can
+ also annotate fields of any kind of visibility</para>
+
+ <programlisting>@MyBeanConstraint(max=45
+public class Dog {
+ @AssertTrue private boolean isMale;
+ @NotNull protected String getName() { ... };
+ ...
+} </programlisting>
+
+ <para>You can also annotate interfaces. Hibernate Validator will check all
+ superclasses and interfaces extended or implemented by a given bean to
+ read the appropriate validator annotations.</para>
+
+ <programlisting>public interface Named {
+ @NotNull String getName();
+ ...
+}
+
+public class Dog implements Named {
+
+ @AssertTrue private boolean isMale;
+
+ public String getName() { ... };
+
+}
+ </programlisting>
+
+ <para>The name property will be checked for nullity when the Dog bean is
+ validated.</para>
+ </section>
+</chapter>
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator-legacy/src/main/javadoc
___________________________________________________________________
Name: svn:mergeinfo
+
Added: validator/trunk/hibernate-validator-legacy/src/main/javadoc/stylesheet.css
===================================================================
--- validator/trunk/hibernate-validator-legacy/src/main/javadoc/stylesheet.css (rev 0)
+++ validator/trunk/hibernate-validator-legacy/src/main/javadoc/stylesheet.css 2008-10-09 08:57:53 UTC (rev 15300)
@@ -0,0 +1,117 @@
+/* Javadoc style sheet */
+
+/* Define colors, fonts and other style attributes here to override the defaults */
+
+/* Page background color */
+body { font-family: Arial;
+ background-color: white;
+ font-size: 10pt;
+ }
+td { font-family: Arial;
+ font-size: 10pt;
+ }
+/* Table colors */
+.TableHeadingColor { background: #F4F4F4 }
+.TableSubHeadingColor { background: #F4F4F4 }
+.TableRowColor { background: #FFFFFF }
+
+/* Font used in left-hand frame lists */
+.FrameTitleFont { font-size: normal; font-family: Arial }
+.FrameHeadingFont { font-size: normal; font-family: Arial }
+.FrameItemFont { font-size: normal; font-family: Arial }
+
+/* Example of smaller, sans-serif font in frames */
+/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */
+
+/* Navigation bar fonts and colors */
+.NavBarCell1 { background-color:#F4F4F4;}
+.NavBarCell1Rev { background-color:silver;}
+
+.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;}
+.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;}
+
+.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
+.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
+
+A {
+ color: #003399;
+}
+
+A:active {
+ color: #003399;
+}
+
+A:visited {
+ color: #888888;
+}
+
+P, OL, UL, LI, DL, DT, DD, BLOCKQUOTE {
+ color: #000000;
+}
+
+TD, TH, SPAN {
+ color: #000000;
+}
+
+BLOCKQUOTE {
+ margin-right: 0px;
+}
+
+
+/*H1, H2, H3, H4, H5, H6 {
+ color: #000000;
+ font-weight:500;
+ margin-top:10px;
+ padding-top:15px;
+}
+
+H1 { font-size: 150%; }
+H2 { font-size: 140%; }
+H3 { font-size: 110%; font-weight: bold; }
+H4 { font-size: 110%; font-weight: bold;}
+H5 { font-size: 100%; font-style: italic; }
+H6 { font-size: 100%; font-style: italic; }*/
+
+TT {
+font-size: 90%;
+ font-family: "Courier New", Courier, monospace;
+ color: #000000;
+}
+
+PRE {
+font-size: 90%;
+ padding: 5px;
+ border-style: solid;
+ border-width: 1px;
+ border-color: #CCCCCC;
+ background-color: #F4F4F4;
+}
+
+UL, OL, LI {
+ list-style: disc;
+}
+
+HR {
+ width: 100%;
+ height: 1px;
+ background-color: #CCCCCC;
+ border-width: 0px;
+ padding: 0px;
+ color: #CCCCCC;
+}
+
+.variablelist {
+ padding-top: 10;
+ padding-bottom:10;
+ margin:0;
+}
+
+.itemizedlist, UL {
+ padding-top: 0;
+ padding-bottom:0;
+ margin:0;
+}
+
+.term {
+ font-weight:bold;
+}
Property changes on: validator/trunk/hibernate-validator-legacy/src/main/javadoc/stylesheet.css
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: validator/trunk/hibernate-validator-legacy/src/test/resources/log4j.properties
===================================================================
--- validator/trunk/hibernate-validator-legacy/src/test/resources/log4j.properties 2008-10-09 07:17:13 UTC (rev 15299)
+++ validator/trunk/hibernate-validator-legacy/src/test/resources/log4j.properties 2008-10-09 08:57:53 UTC (rev 15300)
@@ -18,7 +18,7 @@
### log just the SQL
-log4j.logger.org.hibernate.SQL=debug
+log4j.logger.org.hibernate.SQL=warn
#log4j.logger.org.hibernate.engine.CascadingAction=debug
@@ -26,7 +26,7 @@
#log4j.logger.org.hibernate.type=debug
### log schema export/update ###
-log4j.logger.org.hibernate.tool.hbm2ddl=debug
+log4j.logger.org.hibernate.tool.hbm2ddl=warn
### log cache activity ###
#log4j.logger.org.hibernate.cache=debug
More information about the hibernate-commits
mailing list