Hibernate SVN: r14822 - in entitymanager/trunk/src: java/org/hibernate/ejb/packaging and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-29 09:44:43 -0400 (Sun, 29 Jun 2008)
New Revision: 14822
Modified:
entitymanager/trunk/src/java/org/hibernate/ejb/event/EntityCallbackHandler.java
entitymanager/trunk/src/java/org/hibernate/ejb/packaging/JarVisitor.java
entitymanager/trunk/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java
Log:
* Cleanup
* Enabled svn keyword substitution
Modified: entitymanager/trunk/src/java/org/hibernate/ejb/event/EntityCallbackHandler.java
===================================================================
--- entitymanager/trunk/src/java/org/hibernate/ejb/event/EntityCallbackHandler.java 2008-06-29 13:38:37 UTC (rev 14821)
+++ entitymanager/trunk/src/java/org/hibernate/ejb/event/EntityCallbackHandler.java 2008-06-29 13:44:43 UTC (rev 14822)
@@ -1,3 +1,4 @@
+// $Id:$
/*
* JBoss, the OpenSource EJB server
*
@@ -24,6 +25,7 @@
*
* @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
*/
+@SuppressWarnings({"unchecked", "serial"})
public class EntityCallbackHandler implements Serializable {
private HashMap<Class, Callback[]> preCreates = new HashMap<Class, Callback[]>();
private HashMap<Class, Callback[]> postCreates = new HashMap<Class, Callback[]>();
Property changes on: entitymanager/trunk/src/java/org/hibernate/ejb/event/EntityCallbackHandler.java
___________________________________________________________________
Name: svn:keywords
- Author Date Id Revision
+ Id
Modified: entitymanager/trunk/src/java/org/hibernate/ejb/packaging/JarVisitor.java
===================================================================
--- entitymanager/trunk/src/java/org/hibernate/ejb/packaging/JarVisitor.java 2008-06-29 13:38:37 UTC (rev 14821)
+++ entitymanager/trunk/src/java/org/hibernate/ejb/packaging/JarVisitor.java 2008-06-29 13:44:43 UTC (rev 14822)
@@ -1,4 +1,4 @@
-//$
+// $Id:$
package org.hibernate.ejb.packaging;
import java.util.Set;
Property changes on: entitymanager/trunk/src/java/org/hibernate/ejb/packaging/JarVisitor.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: entitymanager/trunk/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java
===================================================================
--- entitymanager/trunk/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java 2008-06-29 13:38:37 UTC (rev 14821)
+++ entitymanager/trunk/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java 2008-06-29 13:44:43 UTC (rev 14822)
@@ -33,6 +33,7 @@
/**
* @author Gavin King
*/
+@SuppressWarnings("unchecked")
public class PackagedEntityManagerTest extends TestCase {
public Class[] getAnnotatedClasses() {
@@ -228,81 +229,6 @@
emf.close();
}
-// This test does not make sense anymore, validator being autoregistered at the HAN level
-// public void testListenersOverridingCfgXmlPar() throws Exception {
-// EntityManagerFactory emf = Persistence.createEntityManagerFactory( "cfgxmlpar", new HashMap() );
-// EntityManager em = emf.createEntityManager();
-// Cat cat = new Cat();
-// cat.setName( "123"); //validator catch that
-// em.getTransaction().begin();
-// try {
-// em.persist( cat );
-// em.flush();
-// }
-// catch (InvalidStateException e) {
-// fail("Shouldn't call the ValidatorEvent listener");
-// }
-// catch (PersistenceException e) {
-// if ( ! (e.getCause() instanceof JDBCException ) ) {
-// fail("Unexpected exception: " + e);
-// }
-// }
-// em.getTransaction().rollback();
-//
-// em.close();
-// emf.close();
-// }
-
- //EM TRANSACTION
-// public void testEntityManager() {
-//
-// Item item = new Item( "Mouse", "Micro$oft mouse" );
-//
-// EntityManager em = factory.createEntityManager();
-// em.getTransaction().begin();
-// em.persist( item );
-// assertTrue( em.contains( item ) );
-// em.getTransaction().commit();
-//
-// assertFalse( em.contains( item ) );
-//
-// em.getTransaction().begin();
-// item = (Item) em.createQuery( "from Item where descr like 'M%'" ).getSingleResult();
-// assertNotNull( item );
-// assertEquals( "Micro$oft mouse", item.getDescr() );
-// item.setDescr( "Micro$oft wireless mouse" );
-// assertTrue( em.contains( item ) );
-// em.getTransaction().commit();
-//
-// assertFalse( em.contains( item ) );
-//
-// em.getTransaction().begin();
-// item = (Item) em.find( Item.class, "Mouse" );
-// assertNotNull( item );
-// em.getTransaction().commit();
-//
-// item = em.find( Item.class, "Mouse" );
-// assertFalse( em.contains( item ) );
-//
-// item = (Item) em.createQuery( "from Item where descr like 'M%'" ).getSingleResult();
-// assertNotNull( item );
-// assertFalse( em.contains( item ) );
-//
-// em.getTransaction().begin();
-// assertEquals("Explicit package in <class> should work", 1, em.createNamedQuery( "countItems" ).getSingleResult() );
-// em.getTransaction().commit();
-//
-// em.getTransaction().begin();
-// item = em.find( Item.class, "Mouse" );
-// assertNotNull( item );
-// assertTrue( em.contains( item ) );
-// assertEquals( "Micro$oft wireless mouse", item.getDescr() );
-// em.remove( item );
-// em.getTransaction().commit();
-//
-// em.close();
-// }
-
public void testExtendedEntityManager() {
Item item = new Item( "Mouse", "Micro$oft mouse" );
Property changes on: entitymanager/trunk/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java
___________________________________________________________________
Name: svn:keywords
- Author Date Id Revision
+ Id
16 years, 5 months
Hibernate SVN: r14821 - in entitymanager/trunk: ivy and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-29 09:38:37 -0400 (Sun, 29 Jun 2008)
New Revision: 14821
Modified:
entitymanager/trunk/build.xml
entitymanager/trunk/common-build.xml
entitymanager/trunk/ivy/ivyconf.xml
entitymanager/trunk/src/test/log4j.properties
Log:
* Synchronizing common-build.xml and ivyconf.xml with annotations and commons-annotations.
Modified: entitymanager/trunk/build.xml
===================================================================
--- entitymanager/trunk/build.xml 2008-06-29 13:06:15 UTC (rev 14820)
+++ entitymanager/trunk/build.xml 2008-06-29 13:38:37 UTC (rev 14821)
@@ -1,469 +1,440 @@
+<!-- $Id:$ -->
<!--
- Hibernate Annotations ANT build script.
+ Hibernate Entity Manager ANT build script.
You need JDK 5.0 installed to build Hibernate EntityManager.
-->
<project name="HibernateEntityManager" 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 EntityManager"/>
- <property name="name" value="hibernate-entitymanager"/>
- <property name="version" value="3.4.0.CR1"/>
- <property name="javadoc.packagenames" value="org.hibernate.ejb.*"/>
- <property name="jdbc.dir" value="jdbc"/>
- <property name="copy.test" value="true"/>
+ 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 EntityManager"/>
+ <property name="name" value="hibernate-entitymanager"/>
+ <property name="version" value="3.4.0.CR1"/>
+ <property name="javadoc.packagenames" value="org.hibernate.ejb.*"/>
+ <property name="jdbc.dir" value="jdbc"/>
+ <property name="copy.test" value="true"/>
<property name="javac.source" value="1.5"/>
<property name="javac.target" value="1.5"/>
- <property name="common.dir" value="${basedir}"/>
-
- <available property="jpa-present" file="${basedir}/../jpa-api" type="dir"/>
- <!-- property name="jpa-api.jar" value="${basedir}/../jpa-api/build/ejb3-persistence.jar"/>
- <property name="annotations.jar"
- value="${basedir}/../annotations/target/hibernate-annotations/hibernate-annotations.jar"/>
- <property name="commons-annotations.jar"
- value="${basedir}/../commons-annotations/target/hibernate-commons-annotations/hibernate-commons-annotations.jar"/ -->
- <property name="ivy.dep.dir" value="${basedir}/build/lib" />
-
- <import file="${common.dir}/common-build.xml"/>
+ <property name="common.dir" value="${basedir}"/>
+
+ <available property="jpa-present" file="${basedir}/../jpa-api" type="dir"/>
+ <property name="ivy.dep.dir" value="${basedir}/build/lib"/>
+
+ <import file="${common.dir}/common-build.xml"/>
<property name="jpa-javadoc.dir" value="${dist.doc.dir}/jpa-api"/>
-
-
- <property name="resources.dir" value="src/resources"/>
- <property name="testresources.dir" value="src/test-resources"/>
- <property name="build.testresources.dir" value="${build.dir}/testresources"/>
- <property name="build.temp.dir" value="${build.dir}/temp"/>
-
- <path id="lib.moduleclass.path">
- <!-- pathelement location="${jpa-api.jar}"/>
- <pathelement location="${commons-annotations.jar}"/>
- <pathelement location="${annotations.jar}"/ -->
- <fileset dir="${ivy.dep.dir}/core">
+
+ <property name="resources.dir" value="src/resources"/>
+ <property name="testresources.dir" value="src/test-resources"/>
+ <property name="build.testresources.dir" value="${build.dir}/testresources"/>
+ <property name="build.temp.dir" value="${build.dir}/temp"/>
+
+ <path id="lib.moduleclass.path">
+ <fileset dir="${ivy.dep.dir}/core">
<include name="*.jar"/>
</fileset>
- </path>
+ </path>
<path id="junit.moduleclasspath">
<pathelement location="${src.dir}"/>
<pathelement location="${test.dir}"/>
- <fileset dir="${jdbc.dir}">
+ <fileset dir="${jdbc.dir}">
<include name="*.jar"/>
<include name="*.zip"/>
</fileset>
- <fileset dir="${lib.dir}/test">
+ <fileset dir="${lib.dir}/test">
<include name="*.jar"/>
<include name="*.zip"/>
</fileset>
- <fileset dir="${ivy.dep.dir}/test">
+ <fileset dir="${ivy.dep.dir}/test">
<include name="*.jar"/>
</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">
+ </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>
- <!-- check for dependency artefacts -->
- <!-- available file="${jpa-api.jar}" type="file" property="jpa-api.jar.available"/>
- <available file="${commons-annotations.jar}" type="file" property="commons-annotations.jar.available"/>
- <available file="${annotations.jar}" type="file" property="annotations.jar.available"/ -->
- <mkdir dir="${lib.dir}/test"/>
- <mkdir dir="${ivy.dep.dir}/core"/>
- <mkdir dir="${ivy.dep.dir}/test"/>
- <ivy:configure file="${ivy.jar.dir}/ivyconf.xml" />
- </target>
-
- <!-- target name="get.jpa-api" depends="init" unless="jpa-api.jar.available">
- <ant inheritall="false" dir="${basedir}/../jpa-api" target="clean"/>
- <ant inheritall="false" dir="${basedir}/../jpa-api" target="jar"/>
+ <tstamp>
+ <format property="now" pattern="yyyyMMddhhmmss"/>
+ </tstamp>
+ <mkdir dir="${lib.dir}/test"/>
+ <mkdir dir="${ivy.dep.dir}/core"/>
+ <mkdir dir="${ivy.dep.dir}/test"/>
+ <ivy:configure file="${ivy.jar.dir}/ivyconf.xml"/>
</target>
-
- <target name="get.commons-annotations" depends="init" unless="commons-annotations.jar.available">
- <ant inheritall="false" dir="${basedir}/../commons-annotations" target="clean"/>
- <ant inheritall="false" dir="${basedir}/../commons-annotations" target="jar"/>
+
+ <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.annotations" depends="init" unless="annotations.jar.available">
- <ant inheritall="false" dir="${basedir}/../annotations" target="clean"/>
- <ant inheritall="false" dir="${basedir}/../annotations" target="jar"/>
- </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="compile" depends="init,get.deps.core" 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}"
- >
- </javac>
- </target>
-
- <target name="packjar">
- <property name="extension" value="jar"/>
+
+ <target name="compile" depends="init,get.deps.core"
+ 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}">
+ </javac>
+ </target>
+
+ <target name="packjar">
+ <property name="extension" value="jar"/>
<property name="packagename" value="${jarname}"/>
- <property name="headerdirectory" value="."/>
- <!-- property name="jarname"/ -->
- <mkdir dir="${build.testresources.dir}"/>
- <mkdir dir="${build.temp.dir}/${headerdirectory}"/>
- <copy todir="${build.temp.dir}/${headerdirectory}">
- <fileset dir="${classes.dir}" >
- <include name="**/test/pack/${packagename}/**.*"/>
- </fileset>
- </copy>
- <jar destfile="${build.testresources.dir}/${jarname}.${extension}">
- <!-- fileset dir="${classes.dir}" >
- <include name="**/test/pack/${packagename}/**.*"/>
- </fileset -->
- <fileset dir="${build.temp.dir}">
- <include name="**/*.*"/>
- </fileset>
- <fileset dir="${testresources.dir}/${jarname}">
- <include name="**/*.*"/>
- </fileset>
- </jar>
- <delete dir="${build.temp.dir}"/>
- </target>
-
- <target name="packexploded">
- <property name="extension" value="jar"/>
- <!-- property name="jarname"/ -->
- <mkdir dir="${build.testresources.dir}/${jarname}.${extension}"/>
- <copy todir="${build.testresources.dir}/${jarname}.${extension}">
- <!-- fileset dir="${build.temp.dir}"/ -->
- <fileset dir="${classes.dir}">
- <include name="**/test/pack/${jarname}/**.*"/>
- </fileset>
- <fileset dir="${testresources.dir}/${jarname}">
- <include name="**/*.*"/>
- </fileset>
- </copy>
- <!-- delete dir="${build.temp.dir}"/ -->
- </target>
-
- <target name="test-resources" description="Prepare all needed jars and pars">
- <antcall target="packjar" inheritall="true">
- <param name="extension" value="par"/>
- <param name="jarname" value="defaultpar"/>
- </antcall>
+ <property name="headerdirectory" value="."/>
+ <!-- property name="jarname"/ -->
+ <mkdir dir="${build.testresources.dir}"/>
+ <mkdir dir="${build.temp.dir}/${headerdirectory}"/>
+ <copy todir="${build.temp.dir}/${headerdirectory}">
+ <fileset dir="${classes.dir}">
+ <include name="**/test/pack/${packagename}/**.*"/>
+ </fileset>
+ </copy>
+ <jar destfile="${build.testresources.dir}/${jarname}.${extension}">
+ <!-- fileset dir="${classes.dir}" >
+ <include name="**/test/pack/${packagename}/**.*"/>
+ </fileset -->
+ <fileset dir="${build.temp.dir}">
+ <include name="**/*.*"/>
+ </fileset>
+ <fileset dir="${testresources.dir}/${jarname}">
+ <include name="**/*.*"/>
+ </fileset>
+ </jar>
+ <delete dir="${build.temp.dir}"/>
+ </target>
+
+ <target name="packexploded">
+ <property name="extension" value="jar"/>
+ <!-- property name="jarname"/ -->
+ <mkdir dir="${build.testresources.dir}/${jarname}.${extension}"/>
+ <copy todir="${build.testresources.dir}/${jarname}.${extension}">
+ <!-- fileset dir="${build.temp.dir}"/ -->
+ <fileset dir="${classes.dir}">
+ <include name="**/test/pack/${jarname}/**.*"/>
+ </fileset>
+ <fileset dir="${testresources.dir}/${jarname}">
+ <include name="**/*.*"/>
+ </fileset>
+ </copy>
+ <!-- delete dir="${build.temp.dir}"/ -->
+ </target>
+
+ <target name="test-resources" description="Prepare all needed jars and pars">
<antcall target="packjar" inheritall="true">
- <param name="extension" value="par"/>
- <param name="jarname" value="space par"/>
+ <param name="extension" value="par"/>
+ <param name="jarname" value="defaultpar"/>
+ </antcall>
+ <antcall target="packjar" inheritall="true">
+ <param name="extension" value="par"/>
+ <param name="jarname" value="space par"/>
<param name="packagename" value="spacepar"/>
</antcall>
<antcall target="packjar" inheritall="true">
- <param name="extension" value="par"/>
- <param name="jarname" value="explicitpar"/>
- </antcall>
- <antcall target="packjar" inheritall="true">
- <param name="extension" value="par"/>
- <param name="jarname" value="excludehbmpar"/>
- </antcall>
- <antcall target="packjar" inheritall="true">
- <param name="extension" value="jar"/>
- <param name="jarname" value="externaljar"/>
- </antcall>
- <antcall target="packjar" inheritall="true">
- <param name="extension" value="par"/>
- <param name="jarname" value="cfgxmlpar"/>
- </antcall>
+ <param name="extension" value="par"/>
+ <param name="jarname" value="explicitpar"/>
+ </antcall>
<antcall target="packjar" inheritall="true">
- <param name="extension" value="jar"/>
- <param name="jarname" value="overridenpar"/>
- </antcall>
-
- <!-- nested jar -->
- <jar destfile="${build.testresources.dir}/nestedjar.ear">
- <fileset dir="${build.testresources.dir}">
- <include name="defaultpar.par"/>
- </fileset>
- </jar>
- <copy todir="${build.testresources.dir}/nesteddir.ear">
- <fileset dir="${build.testresources.dir}">
- <include name="defaultpar.par"/>
- </fileset>
- </copy>
-
- <antcall target="packjar" inheritall="true">
- <param name="extension" value="war"/>
- <param name="jarname" value="war"/>
- <param name="headerdirectory" value="WEB-INF/classes"/>
- </antcall>
-
- <antcall target="packexploded" inheritall="true">
- <param name="extension" value="par"/>
- <param name="jarname" value="explodedpar"/>
- </antcall>
- </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>
-
- <target name="compiletest" depends="compile,get.deps.test" 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
- srcdir="${test.dir}"
- destdir="${classes.dir}"
- debug="${javac.debug}"
- optimize="${javac.optimize}"
- nowarn="on"
- source="${javac.source}"
- target="${javac.target}">
- <classpath>
- <path refid="junit.classpath"/>
- </classpath>
- </javac>
- </target>
-
- <target name="junit" depends="compiletest,test-resources">
- <mkdir dir="test_output"/>
- <mkdir dir="${classes.dir}/META-INF/services"/>
- <copy todir="${classes.dir}">
- <fileset dir="${resources.dir}">
- <include name="**/*.*"/>
- </fileset>
- </copy>
- <junit fork="once" printsummary="yes" haltonfailure="yes">
- <classpath>
- <fileset dir="${jdbc.dir}">
- <include name="**/*.jar"/>
- <include name="**/*.zip"/>
- </fileset>
- <dirset dir="${build.testresources.dir}">
- <include name="**/*.jar"/>
- <include name="**/*.par"/>
- </dirset>
-
- <fileset dir="${build.testresources.dir}">
- <include name="**/*.jar"/>
- <include name="**/*.par"/>
- </fileset>
- <path refid="junit.classpath"/>
- <!-- pathelement path="${classes.dir}"/ -->
- <dirset dir="${classes.dir}">
- <exclude name="**/pack/**.*"/>
- </dirset>
-
- <!-- pathelement path="build/test.par"/ -->
- <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"/>
- <batchtest fork="yes" todir="test_output" haltonfailure="no">
- <fileset dir="${classes.dir}">
- <include name="**/*Test.class"/>
- </fileset>
- </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>
- <fileset dir="${jdbc.dir}">
- <include name="**/*.jar"/>
- <include name="**/*.zip"/>
- </fileset>
- <path refid="lib.class.path"/>
- <pathelement path="build/test.par"/>
- <pathelement path="target/hibernate-entitymanager/hibernate-entitymanager.jar"/>
- <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="jar" depends="compile" description="Build the distribution .jar file">
- <mkdir dir="${classes.dir}/META-INF/services"/>
- <copy todir="${classes.dir}">
- <fileset dir="${resources.dir}">
- <include name="**/*.*"/>
- </fileset>
- </copy>
- <manifest file="${classes.dir}/META-INF/MANIFEST.MF">
- <attribute name="Implementation-Title" value="${Name}"/>
+ <param name="extension" value="par"/>
+ <param name="jarname" value="excludehbmpar"/>
+ </antcall>
+ <antcall target="packjar" inheritall="true">
+ <param name="extension" value="jar"/>
+ <param name="jarname" value="externaljar"/>
+ </antcall>
+ <antcall target="packjar" inheritall="true">
+ <param name="extension" value="par"/>
+ <param name="jarname" value="cfgxmlpar"/>
+ </antcall>
+ <antcall target="packjar" inheritall="true">
+ <param name="extension" value="jar"/>
+ <param name="jarname" value="overridenpar"/>
+ </antcall>
+
+ <!-- nested jar -->
+ <jar destfile="${build.testresources.dir}/nestedjar.ear">
+ <fileset dir="${build.testresources.dir}">
+ <include name="defaultpar.par"/>
+ </fileset>
+ </jar>
+ <copy todir="${build.testresources.dir}/nesteddir.ear">
+ <fileset dir="${build.testresources.dir}">
+ <include name="defaultpar.par"/>
+ </fileset>
+ </copy>
+
+ <antcall target="packjar" inheritall="true">
+ <param name="extension" value="war"/>
+ <param name="jarname" value="war"/>
+ <param name="headerdirectory" value="WEB-INF/classes"/>
+ </antcall>
+
+ <antcall target="packexploded" inheritall="true">
+ <param name="extension" value="par"/>
+ <param name="jarname" value="explodedpar"/>
+ </antcall>
+ </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>
+
+ <target name="compiletest" depends="compile,get.deps.test"
+ 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 srcdir="${test.dir}" destdir="${classes.dir}" debug="${javac.debug}"
+ optimize="${javac.optimize}" nowarn="on" source="${javac.source}"
+ target="${javac.target}">
+ <classpath>
+ <path refid="junit.classpath"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="junit" depends="compiletest,test-resources">
+ <mkdir dir="${testreports.dir}"/>
+ <mkdir dir="${classes.dir}/META-INF/services"/>
+ <copy todir="${classes.dir}">
+ <fileset dir="${resources.dir}">
+ <include name="**/*.*"/>
+ </fileset>
+ </copy>
+ <junit fork="once" printsummary="yes" haltonfailure="yes">
+ <classpath>
+ <fileset dir="${jdbc.dir}">
+ <include name="**/*.jar"/>
+ <include name="**/*.zip"/>
+ </fileset>
+ <dirset dir="${build.testresources.dir}">
+ <include name="**/*.jar"/>
+ <include name="**/*.par"/>
+ </dirset>
+
+ <fileset dir="${build.testresources.dir}">
+ <include name="**/*.jar"/>
+ <include name="**/*.par"/>
+ </fileset>
+ <path refid="junit.classpath"/>
+ <!-- pathelement path="${classes.dir}"/ -->
+ <dirset dir="${classes.dir}">
+ <exclude name="**/pack/**.*"/>
+ </dirset>
+
+ <!-- pathelement path="build/test.par"/ -->
+ <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"/>
+ <batchtest fork="yes" todir="${testreports.dir}" haltonfailure="no">
+ <fileset dir="${classes.dir}">
+ <include name="**/*Test.class"/>
+ </fileset>
+ </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="${testreports.dir}"/>
+ <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="build/test.par"/>
+ <pathelement
+ path="target/hibernate-entitymanager/hibernate-entitymanager.jar"/>
+ <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="${testreports.dir}" haltonfailure="no"
+ name="${testname}"/>
+ </junit>
+ </target>
+
+ <target name="jar" depends="compile"
+ description="Build the distribution .jar file">
+ <mkdir dir="${classes.dir}/META-INF/services"/>
+ <copy todir="${classes.dir}">
+ <fileset dir="${resources.dir}">
+ <include name="**/*.*"/>
+ </fileset>
+ </copy>
+ <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://entitymanager.hibernate.org"/>
- <attribute name="Specification-Title" value="Java Persistence"/>
+ <attribute name="Implementation-Vendor" value="hibernate.org"/>
+ <attribute name="Implementation-Vendor-Id" value="hibernate.org"/>
+ <attribute name="Implementation-URL"
+ value="http://entitymanager.hibernate.org"/>
+ <attribute name="Specification-Title" value="Java Persistence"/>
<attribute name="Specification-Version" value="1.0"/>
- <attribute name="Specification-Vendor" value="jcp.org"/>
- </manifest>
- <antcall target="common-build.jar"/>
- <ivy:resolve conf="default"/>
- <ivy:publish artifactspattern="${dist.dir}/[artifact].[ext]"
- resolver="local"
- pubrevision="latest"
- pubdate="${now}"
- status="integration"
- />
- </target>
-
- <!-- target name="javadoc" description="Compile the Javadoc API documentation to dist dir">
- <echo>Skipping java doc since ant's javadoc task cannot handle an alternative javadoc</echo>
- </target -->
-
- <target name="jpa-javadoc" if="jpa-present">
- <mkdir dir="${jpa-javadoc.dir}"/>
- <ant dir="../jpa-api" target="javadoc" inheritAll="false"/>
- <copy todir="${jpa-javadoc.dir}">
- <fileset dir="${basedir}/../jpa-api/build/api">
- <include name="**/*.*"/>
- </fileset>
- </copy>
+ <attribute name="Specification-Vendor" value="jcp.org"/>
+ </manifest>
+ <antcall target="common-build.jar"/>
+ <ivy:resolve conf="default"/>
+ <delete file="${dist.dir}/ivy.xml"/> <!-- delete last produced ivy file to be sure a new one will be generated -->
+ <ivy:publish artifactspattern="${dist.dir}/[artifact].[ext]"
+ resolver="local" pubrevision="latest" pubdate="${now}"
+ status="integration"/>
</target>
-
- <!-- Some of this can probably be moved to common-build... -->
- <target name="dist" depends="get.deps.core,get.deps.test,jar,javadoc,jpa-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}/resources" failonerror="false">
- <fileset dir="${resources.dir}">
- <include name="**/*.*"/>
- </fileset>
- </copy>
- <copy todir="${dist.dir}/test-resources" failonerror="false">
- <fileset dir="${testresources.dir}">
- <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">
+
+ <!-- target name="javadoc" description="Compile the Javadoc API documentation to dist dir">
+ <echo>Skipping java doc since ant's javadoc task cannot handle an alternative javadoc</echo>
+ </target -->
+
+ <target name="jpa-javadoc" if="jpa-present">
+ <mkdir dir="${jpa-javadoc.dir}"/>
+ <ant dir="../jpa-api" target="javadoc" inheritAll="false"/>
+ <copy todir="${jpa-javadoc.dir}">
+ <fileset dir="${basedir}/../jpa-api/build/api">
+ <include name="**/*.*"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <!-- Some of this can probably be moved to common-build... -->
+ <target name="dist"
+ depends="get.deps.core,get.deps.test,jar,javadoc,jpa-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}/resources" failonerror="false">
+ <fileset dir="${resources.dir}">
+ <include name="**/*.*"/>
+ </fileset>
+ </copy>
+ <copy todir="${dist.dir}/test-resources" failonerror="false">
+ <fileset dir="${testresources.dir}">
+ <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 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>
- <copy todir="${dist.lib.dir}/test" failonerror="false">
+ <include name="*.jar"/>
+ </fileset>
+ </copy>
+ <copy todir="${dist.lib.dir}/test" failonerror="false">
<fileset file="${lib.dir}/test/*.jar"/>
- </copy>
-
- <mkdir dir="${dist.lib.dir}/build"/>
- <copy todir="${dist.lib.dir}/build" failonerror="false">
+ </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}/annotations.jar" tofile="${dist.lib.dir}/hibernate-annotations.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>
-
- <target name="profile" depends="compiletest">
- <java classname="org.hibernate.ejb.test.Profile" fork="true">
- <jvmarg value="-XrunjbossInspector:c:\profiler\data,include=org.hibernate.ejb,ignore=*,wakeupOnStartup=true"/>
- <classpath>
- <fileset dir="${jdbc.dir}">
- <include name="**/*.jar"/>
- <include name="**/*.zip"/>
- </fileset>
- <dirset dir="${build.testresources.dir}">
- <include name="**/*.jar"/>
- <include name="**/*.par"/>
- </dirset>
-
- <fileset dir="${build.testresources.dir}">
- <include name="**/*.jar"/>
- <include name="**/*.par"/>
- </fileset>
- <path refid="lib.class.path"/>
- <pathelement path="${classes.dir}"/>
- <!-- pathelement path="build/test.par"/ -->
- <pathelement path="${src.dir}"/>
- <!-- pick up properties from here -->
- <pathelement path="${test.dir}"/>
- <!-- pick up mappings from here -->
- </classpath>
- </java>
- </target>
-
-
+ </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}/annotations.jar"
+ tofile="${dist.lib.dir}/hibernate-annotations.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>
+
+ <target name="profile" depends="compiletest">
+ <java classname="org.hibernate.ejb.test.Profile" fork="true">
+ <jvmarg
+ value="-XrunjbossInspector:c:\profiler\data,include=org.hibernate.ejb,ignore=*,wakeupOnStartup=true"/>
+ <classpath>
+ <fileset dir="${jdbc.dir}">
+ <include name="**/*.jar"/>
+ <include name="**/*.zip"/>
+ </fileset>
+ <dirset dir="${build.testresources.dir}">
+ <include name="**/*.jar"/>
+ <include name="**/*.par"/>
+ </dirset>
+
+ <fileset dir="${build.testresources.dir}">
+ <include name="**/*.jar"/>
+ <include name="**/*.par"/>
+ </fileset>
+ <path refid="lib.class.path"/>
+ <pathelement path="${classes.dir}"/>
+ <!-- pathelement path="build/test.par"/ -->
+ <pathelement path="${src.dir}"/>
+ <!-- pick up properties from here -->
+ <pathelement path="${test.dir}"/>
+ <!-- pick up mappings from here -->
+ </classpath>
+ </java>
+ </target>
+
</project>
Property changes on: entitymanager/trunk/build.xml
___________________________________________________________________
Name: svn:keywords
- Author Date Id Revision
+ Id
Modified: entitymanager/trunk/common-build.xml
===================================================================
--- entitymanager/trunk/common-build.xml 2008-06-29 13:06:15 UTC (rev 14820)
+++ entitymanager/trunk/common-build.xml 2008-06-29 13:38:37 UTC (rev 14821)
@@ -13,10 +13,11 @@
<property name="src.dir" location="src/java"/>
<property name="test.dir" location="src/test"/>
- <property name="lib.dir" location="lib"/>
+ <property name="lib.dir" location="lib"/>
<property name="build.dir" location="build"/>
<property name="classes.dir" location="${build.dir}/classes"/>
- <property name="testclasses.dir" location="${build.dir}/testclasses"/>
+ <property name="testclasses.dir" location="${build.dir}/testclasses"/>
+ <property name="testreports.dir" location="${build.dir}/test-reports"/>
<property name="dist.target.dir" location="target"/>
<property name="dist.dir" location="${dist.target.dir}/${name}"/>
<property name="instrumenttest.out.dir" value="instrumenttestout"/>
@@ -43,25 +44,23 @@
<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}/build"/>
-
- <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 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>
+ <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 -->
@@ -82,9 +81,6 @@
<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>
@@ -131,9 +127,6 @@
<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"/>
@@ -278,19 +271,19 @@
</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="copylib" description="Copy jars to lib dir">
+ <mkdir dir="${dist.lib.dir}"/>
+ <copy todir="${dist.lib.dir}" verbose="true">
+ <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}">
@@ -351,7 +344,7 @@
</replace>
</target>
- <target name="dist" depends="jar,javadoc,copysource,copylib,copydoc,extras" description="Build everything">
+ <target name="dist" depends="jar,javadoc,copysource,copydoc,extras" description="Build everything">
<zip zipfile = "${dist.dir}-${version}.zip">
<zipfileset prefix="${name}-${version}" dir="${dist.dir}"/>
</zip>
@@ -377,12 +370,12 @@
</target>
<target name="junit" depends="compiletest">
- <mkdir dir="test_output"/>
+ <mkdir dir="${testreports.dir}"/>
<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">
+ <batchtest fork="yes" todir="${testreports.dir}" haltonfailure="no">
<fileset refid="junit.batchtestset"/>
</batchtest>
</junit>
@@ -390,12 +383,12 @@
<!-- 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"/>
+ <mkdir dir="${testreports.dir}"/>
<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}"/>
+ <test fork="yes" todir="${testreports.dir}" haltonfailure="no" name="${testname}"/>
</junit>
</target>
@@ -416,11 +409,11 @@
</target>
<target name="junitreport" depends="">
- <junitreport todir="./test_output">
- <fileset dir="test_output">
+ <junitreport todir="${testreports.dir}">
+ <fileset dir="${testreports.dir}">
<include name="TEST-*.xml"/>
</fileset>
- <report format="frames" todir="./test_output"/>
+ <report format="frames" todir="${testreports.dir}"/>
</junitreport>
</target>
Property changes on: entitymanager/trunk/common-build.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: entitymanager/trunk/ivy/ivyconf.xml
===================================================================
--- entitymanager/trunk/ivy/ivyconf.xml 2008-06-29 13:06:15 UTC (rev 14820)
+++ entitymanager/trunk/ivy/ivyconf.xml 2008-06-29 13:38:37 UTC (rev 14821)
@@ -9,9 +9,13 @@
</chain>
<chain name="rep-hibernate" returnFirst="true" latest="latest-revision">
<filesystem name="local">
- <ivy pattern="../[module]/target/[revision]/ivy.xml"/>
- <artifact pattern="../[module]/target/[revision]/[artifact].[ext]"/>
+ <ivy pattern="../[module]/target/hibernate-[module]/ivy.xml"/>
+ <artifact pattern="../[module]/target/hibernate-[module]/[artifact].[ext]"/>
</filesystem>
+ <filesystem name="hudson-local">
+ <ivy pattern="../../[module]/trunk/target/hibernate-[module]/ivy.xml"/>
+ <artifact pattern="../../[module]/trunk/target/hibernate-[module]/[artifact].[ext]"/>
+ </filesystem>
<filesystem name="maven-local" m2compatible="true">
<artifact pattern="${offline.repository.jboss.org}/[organization]/hibernate-[module]/[revision]/hibernate-[artifact]-[revision].[ext]"/>
</filesystem>
Property changes on: entitymanager/trunk/ivy/ivyconf.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: entitymanager/trunk/src/test/log4j.properties
===================================================================
--- entitymanager/trunk/src/test/log4j.properties 2008-06-29 13:06:15 UTC (rev 14820)
+++ entitymanager/trunk/src/test/log4j.properties 2008-06-29 13:38:37 UTC (rev 14821)
@@ -5,16 +5,22 @@
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct messages to file hibernate.log ###
-#log4j.appender.file=org.apache.log4j.FileAppender
-#log4j.appender.file.File=hibernate.log
-#log4j.appender.file.layout=org.apache.log4j.PatternLayout
-#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.File=hibernate.log
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+### direct messages to socket - chainsaw ###
+log4j.appender.socket=org.apache.log4j.net.SocketAppender
+log4j.appender.socket.remoteHost=localhost
+log4j.appender.socket.port=4560
+log4j.appender.socket.locationInfo=true
+
### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=warn, stdout
-log4j.logger.org.hibernate=info
+log4j.logger.org.hibernate=debug
#log4j.logger.org.hibernate=debug
log4j.logger.org.hibernate.ejb=debug
16 years, 5 months
Hibernate SVN: r14820 - in commons-annotations/trunk: ivy and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-29 09:06:15 -0400 (Sun, 29 Jun 2008)
New Revision: 14820
Modified:
commons-annotations/trunk/build.xml
commons-annotations/trunk/common-build.xml
commons-annotations/trunk/ivy/ivyconf.xml
Log:
* Synchronised ivyconf.xml and common-build.xml with annotations project.
* Cleanup of build.xml
Modified: commons-annotations/trunk/build.xml
===================================================================
--- commons-annotations/trunk/build.xml 2008-06-29 08:18:20 UTC (rev 14819)
+++ commons-annotations/trunk/build.xml 2008-06-29 13:06:15 UTC (rev 14820)
@@ -21,20 +21,6 @@
<import file="${common.dir}/common-build.xml"/>
- <!-- FIXME path id="lib.class.path">
- <fileset dir="${hibernate-core.lib.dir}">
- <include name="commons-logging*.jar"/>
- <include name="log4j*.jar"/>
- </fileset>
- <fileset dir="${lib.dir}">
- <include name="*.jar"/>
- </fileset>
- <fileset dir="${ivy.dep.dir}/core">
- <include name="*.jar"/>
- </fileset>
- <path refid="lib.moduleclass.path"/>
- <pathelement path="${clover.jar}"/>
- </path -->
<path id="lib.moduleclass.path">
<fileset dir="${ivy.dep.dir}/core">
<include name="*.jar"/>
@@ -59,16 +45,6 @@
<taskdef resource="fr/jayasoft/ivy/ant/antlib.xml"
uri="antlib:fr.jayasoft.ivy.ant" classpathref="ivy.lib.path"/>
- <!-- target name="report">
- <mkdir dir="test_output"/>
- <junitreport todir="test_output">
- <fileset dir="test_output">
- <include name="TEST-*.xml"/>
- </fileset>
- <report format="frames" todir="test_output/report"/>
- </junitreport>
- </target -->
-
<target name="init" description="Initialize the build">
<!-- CCed from common-build to avoid failure when hibernate core is not compiled -->
<tstamp>
@@ -95,8 +71,6 @@
<mkdir dir="${ivy.dep.dir}/core"/>
<mkdir dir="${ivy.dep.dir}/test"/>
<ivy:configure file="${ivy.jar.dir}/ivyconf.xml" />
- <!-- check for dependency artefacts -->
- <!-- available file="${jpa-api.jar}" type="file" property="jpa-api.jar.available"/ -->
</target>
<target name="get.deps.core" depends="init" description="retrieve the core dependencies">
@@ -131,11 +105,6 @@
</javac>
</target>
- <!-- target name="get.jpa-api" depends="init" unless="jpa-api.jar.available">
- <ant inheritall="false" dir="${basedir}/../jpa-api" target="clean"/>
- <ant inheritall="false" dir="${basedir}/../jpa-api" target="jar"/>
- </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">
Modified: commons-annotations/trunk/common-build.xml
===================================================================
--- commons-annotations/trunk/common-build.xml 2008-06-29 08:18:20 UTC (rev 14819)
+++ commons-annotations/trunk/common-build.xml 2008-06-29 13:06:15 UTC (rev 14820)
@@ -13,10 +13,11 @@
<property name="src.dir" location="src/java"/>
<property name="test.dir" location="src/test"/>
- <property name="lib.dir" location="lib"/>
+ <property name="lib.dir" location="lib"/>
<property name="build.dir" location="build"/>
<property name="classes.dir" location="${build.dir}/classes"/>
- <property name="testclasses.dir" location="${build.dir}/testclasses"/>
+ <property name="testclasses.dir" location="${build.dir}/testclasses"/>
+ <property name="testreports.dir" location="${build.dir}/test-reports"/>
<property name="dist.target.dir" location="target"/>
<property name="dist.dir" location="${dist.target.dir}/${name}"/>
<property name="instrumenttest.out.dir" value="instrumenttestout"/>
@@ -43,25 +44,23 @@
<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}/build"/>
-
- <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 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>
+ <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 -->
@@ -82,9 +81,6 @@
<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>
@@ -131,9 +127,6 @@
<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"/>
@@ -278,19 +271,19 @@
</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="copylib" description="Copy jars to lib dir">
+ <mkdir dir="${dist.lib.dir}"/>
+ <copy todir="${dist.lib.dir}" verbose="true">
+ <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}">
@@ -351,7 +344,7 @@
</replace>
</target>
- <target name="dist" depends="jar,javadoc,copysource,copylib,copydoc,extras" description="Build everything">
+ <target name="dist" depends="jar,javadoc,copysource,copydoc,extras" description="Build everything">
<zip zipfile = "${dist.dir}-${version}.zip">
<zipfileset prefix="${name}-${version}" dir="${dist.dir}"/>
</zip>
@@ -377,12 +370,12 @@
</target>
<target name="junit" depends="compiletest">
- <mkdir dir="test_output"/>
+ <mkdir dir="${testreports.dir}"/>
<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">
+ <batchtest fork="yes" todir="${testreports.dir}" haltonfailure="no">
<fileset refid="junit.batchtestset"/>
</batchtest>
</junit>
@@ -390,12 +383,12 @@
<!-- 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"/>
+ <mkdir dir="${testreports.dir}"/>
<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}"/>
+ <test fork="yes" todir="${testreports.dir}" haltonfailure="no" name="${testname}"/>
</junit>
</target>
@@ -416,11 +409,11 @@
</target>
<target name="junitreport" depends="">
- <junitreport todir="./test_output">
- <fileset dir="test_output">
+ <junitreport todir="${testreports.dir}">
+ <fileset dir="${testreports.dir}">
<include name="TEST-*.xml"/>
</fileset>
- <report format="frames" todir="./test_output"/>
+ <report format="frames" todir="${testreports.dir}"/>
</junitreport>
</target>
Modified: commons-annotations/trunk/ivy/ivyconf.xml
===================================================================
--- commons-annotations/trunk/ivy/ivyconf.xml 2008-06-29 08:18:20 UTC (rev 14819)
+++ commons-annotations/trunk/ivy/ivyconf.xml 2008-06-29 13:06:15 UTC (rev 14820)
@@ -9,9 +9,13 @@
</chain>
<chain name="rep-hibernate" returnFirst="true" latest="latest-revision">
<filesystem name="local">
- <ivy pattern="../[module]/target/[revision]/ivy.xml"/>
- <artifact pattern="../[module]/target/[revision]/[artifact].[ext]"/>
+ <ivy pattern="../[module]/target/hibernate-[module]/ivy.xml"/>
+ <artifact pattern="../[module]/target/hibernate-[module]/[artifact].[ext]"/>
</filesystem>
+ <filesystem name="hudson-local">
+ <ivy pattern="../../[module]/trunk/target/hibernate-[module]/ivy.xml"/>
+ <artifact pattern="../../[module]/trunk/target/hibernate-[module]/[artifact].[ext]"/>
+ </filesystem>
<filesystem name="maven-local" m2compatible="true">
<artifact pattern="${offline.repository.jboss.org}/[organization]/hibernate-[module]/[revision]/hibernate-[artifact]-[revision].[ext]"/>
</filesystem>
16 years, 5 months
Hibernate SVN: r14819 - search/trunk/src/java/org/hibernate/search/engine.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-06-29 04:18:20 -0400 (Sun, 29 Jun 2008)
New Revision: 14819
Modified:
search/trunk/src/java/org/hibernate/search/engine/MultiClassesQueryLoader.java
search/trunk/src/java/org/hibernate/search/engine/ObjectLoader.java
Log:
Minor optimization: use simple object loading when the List of EntityInfo is of size one
Modified: search/trunk/src/java/org/hibernate/search/engine/MultiClassesQueryLoader.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/MultiClassesQueryLoader.java 2008-06-28 10:51:13 UTC (rev 14818)
+++ search/trunk/src/java/org/hibernate/search/engine/MultiClassesQueryLoader.java 2008-06-29 08:18:20 UTC (rev 14819)
@@ -58,6 +58,18 @@
public List load(EntityInfo... entityInfos) {
if ( entityInfos.length == 0 ) return Collections.EMPTY_LIST;
+ if ( entityInfos.length == 1 ) {
+ final Object entity = load( entityInfos[0] );
+ if ( entity == null ) {
+ return Collections.EMPTY_LIST;
+ }
+ else {
+ final List<Object> list = new ArrayList<Object>( 1 );
+ list.add( entity );
+ return list;
+ }
+ }
+
//split EntityInfo per root entity
Map<RootEntityMetadata, List<EntityInfo>> entityinfoBuckets =
new HashMap<RootEntityMetadata, List<EntityInfo>>( entityMatadata.size());
Modified: search/trunk/src/java/org/hibernate/search/engine/ObjectLoader.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/ObjectLoader.java 2008-06-28 10:51:13 UTC (rev 14818)
+++ search/trunk/src/java/org/hibernate/search/engine/ObjectLoader.java 2008-06-29 08:18:20 UTC (rev 14819)
@@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Collections;
import org.hibernate.Hibernate;
import org.hibernate.Session;
@@ -25,6 +26,18 @@
}
public List load(EntityInfo... entityInfos) {
+ if ( entityInfos.length == 0 ) return Collections.EMPTY_LIST;
+ if ( entityInfos.length == 1 ) {
+ final Object entity = load( entityInfos[0] );
+ if ( entity == null ) {
+ return Collections.EMPTY_LIST;
+ }
+ else {
+ final List<Object> list = new ArrayList<Object>( 1 );
+ list.add( entity );
+ return list;
+ }
+ }
//use load to benefit from the batch-size
//we don't face proxy casting issues since the exact class is extracted from the index
for (EntityInfo entityInfo : entityInfos) {
16 years, 5 months
Hibernate SVN: r14818 - in search/trunk/src: java/org/hibernate/search/query and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-06-28 06:51:13 -0400 (Sat, 28 Jun 2008)
New Revision: 14818
Added:
search/trunk/src/java/org/hibernate/search/engine/MultiClassesQueryLoader.java
search/trunk/src/java/org/hibernate/search/engine/ObjectLoaderHelper.java
search/trunk/src/test/org/hibernate/search/test/query/MultiClassesQueryLoaderTest.java
Removed:
search/trunk/src/test/org/hibernate/search/test/query/ObjectLoaderTest.java
Modified:
search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java
search/trunk/src/java/org/hibernate/search/engine/ObjectLoader.java
search/trunk/src/java/org/hibernate/search/engine/ProjectionLoader.java
search/trunk/src/java/org/hibernate/search/engine/QueryLoader.java
search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java
Log:
HSEARCH-223 use multiple queries rathen than ObjectLoader when possible (can't do that if id is composite)
Modified: search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java 2008-06-27 00:25:45 UTC (rev 14817)
+++ search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java 2008-06-28 10:51:13 UTC (rev 14818)
@@ -47,6 +47,7 @@
import org.hibernate.search.bridge.BridgeFactory;
import org.hibernate.search.bridge.FieldBridge;
import org.hibernate.search.bridge.TwoWayFieldBridge;
+import org.hibernate.search.bridge.TwoWayString2FieldBridgeAdaptor;
import org.hibernate.search.store.DirectoryProvider;
import org.hibernate.search.store.IndexShardingStrategy;
import org.hibernate.search.util.BinderHelper;
@@ -81,7 +82,13 @@
private int maxLevel = Integer.MAX_VALUE;
private final ScopedAnalyzer analyzer = new ScopedAnalyzer();
private Similarity similarity;
+ private boolean isRoot;
+ //if composite id, use of (a, b) in ((1,2), (3,4)) fails on most database
+ private boolean safeFromTupleId;
+ public boolean isRoot() {
+ return isRoot;
+ }
public DocumentBuilder(XClass clazz, InitContext context, DirectoryProvider[] directoryProviders,
IndexShardingStrategy shardingStrategy, ReflectionManager reflectionManager) {
@@ -103,6 +110,9 @@
if ( idKeywordName == null ) {
throw new SearchException( "No document id in: " + clazz.getName() );
}
+ //if composite id, use of (a, b) in ((1,2)TwoWayString2FieldBridgeAdaptor, (3,4)) fails on most database
+ //a TwoWayString2FieldBridgeAdaptor is never a composite id
+ safeFromTupleId = TwoWayString2FieldBridgeAdaptor.class.isAssignableFrom( idBridge.getClass() );
}
private Analyzer getAnalyzer(XAnnotatedElement annotatedElement, InitContext context) {
@@ -788,7 +798,16 @@
for (Class currentClass : indexedClasses) {
if ( plainClass.isAssignableFrom( currentClass ) ) tempMappedSubclasses.add( currentClass );
}
- mappedSubclasses = Collections.unmodifiableSet( tempMappedSubclasses );
+ this.mappedSubclasses = Collections.unmodifiableSet( tempMappedSubclasses );
+ Class superClass = plainClass.getSuperclass();
+ this.isRoot = true;
+ while ( superClass != null) {
+ if ( indexedClasses.contains( superClass ) ) {
+ this.isRoot = false;
+ break;
+ }
+ superClass = superClass.getSuperclass();
+ }
}
@@ -796,6 +815,14 @@
return mappedSubclasses;
}
+ /**
+ * Make sure to return false if there is a risk of composite id
+ * if composite id, use of (a, b) in ((1,2), (3,4)) fails on most database
+ */
+ public boolean isSafeFromTupleId() {
+ return safeFromTupleId;
+ }
+
private static class PropertiesMetadata {
public Float boost;
public Analyzer analyzer;
Added: search/trunk/src/java/org/hibernate/search/engine/MultiClassesQueryLoader.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/MultiClassesQueryLoader.java (rev 0)
+++ search/trunk/src/java/org/hibernate/search/engine/MultiClassesQueryLoader.java 2008-06-28 10:51:13 UTC (rev 14818)
@@ -0,0 +1,112 @@
+package org.hibernate.search.engine;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import java.util.HashMap;
+import java.util.Arrays;
+
+import org.hibernate.Session;
+import org.hibernate.Criteria;
+import org.hibernate.annotations.common.AssertionFailure;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class MultiClassesQueryLoader implements Loader {
+ private Session session;
+ private SearchFactoryImplementor searchFactoryImplementor;
+ private List<RootEntityMetadata> entityMatadata;
+ //useful if loading with a query is unsafe
+ private ObjectLoader objectLoader;
+
+ public void init(Session session, SearchFactoryImplementor searchFactoryImplementor) {
+ this.session = session;
+ this.searchFactoryImplementor = searchFactoryImplementor;
+ this.objectLoader = new ObjectLoader();
+ this.objectLoader.init( session, searchFactoryImplementor );
+ }
+
+ public void setEntityTypes(Class[] entityTypes) {
+ List<Class> safeEntityTypes;
+ //TODO should we go find the root entity for a given class rather than just checking for it's root status?
+ // root entity could lead to quite inefficient queries in Hibnernate when using table per class
+ if ( entityTypes.length == 0 ) {
+ //support all classes
+ safeEntityTypes = new ArrayList<Class>();
+ for( Map.Entry<Class, DocumentBuilder<Object>> entry : searchFactoryImplementor.getDocumentBuilders().entrySet() ) {
+ //get only root entities to limit queries
+ if ( entry.getValue().isRoot() ) {
+ safeEntityTypes.add( entry.getKey() );
+ }
+ }
+ }
+ else {
+ safeEntityTypes = Arrays.asList(entityTypes);
+ }
+ entityMatadata = new ArrayList<RootEntityMetadata>( safeEntityTypes.size() );
+ for (Class clazz : safeEntityTypes) {
+ entityMatadata.add( new RootEntityMetadata( clazz, searchFactoryImplementor, session ) );
+ }
+ }
+
+ public Object load(EntityInfo entityInfo) {
+ return ObjectLoaderHelper.load( entityInfo, session );
+ }
+
+ public List load(EntityInfo... entityInfos) {
+ if ( entityInfos.length == 0 ) return Collections.EMPTY_LIST;
+ //split EntityInfo per root entity
+ Map<RootEntityMetadata, List<EntityInfo>> entityinfoBuckets =
+ new HashMap<RootEntityMetadata, List<EntityInfo>>( entityMatadata.size());
+ for (EntityInfo entityInfo : entityInfos) {
+ boolean found = false;
+ for (RootEntityMetadata rootEntityInfo : entityMatadata) {
+ if ( rootEntityInfo.mappedSubclasses.contains( entityInfo.clazz ) ) {
+ List<EntityInfo> bucket = entityinfoBuckets.get( rootEntityInfo );
+ if ( bucket == null ) {
+ bucket = new ArrayList<EntityInfo>();
+ entityinfoBuckets.put( rootEntityInfo, bucket );
+ }
+ bucket.add( entityInfo );
+ found = true;
+ break; //we stop looping for the right bucket
+ }
+ }
+ if (!found) throw new AssertionFailure( "Could not find root entity for " + entityInfo.clazz );
+ }
+
+ //initialize objects by bucket
+ for ( Map.Entry<RootEntityMetadata, List<EntityInfo>> entry : entityinfoBuckets.entrySet() ) {
+ final RootEntityMetadata key = entry.getKey();
+ final List<EntityInfo> value = entry.getValue();
+ final EntityInfo[] bucketEntityInfos = value.toArray( new EntityInfo[value.size()] );
+ if ( key.useObjectLoader ) {
+ objectLoader.load( bucketEntityInfos );
+ }
+ else {
+ ObjectLoaderHelper.initializeObjects( bucketEntityInfos,
+ key.criteria, key.rootEntity, searchFactoryImplementor);
+ }
+ }
+ return ObjectLoaderHelper.returnAlreadyLoadedObjectsInCorrectOrder( entityInfos, session );
+ }
+
+ private static class RootEntityMetadata {
+ public final Class rootEntity;
+ public final Set<Class> mappedSubclasses;
+ private final Criteria criteria;
+ public final boolean useObjectLoader;
+
+ RootEntityMetadata(Class rootEntity, SearchFactoryImplementor searchFactoryImplementor, Session session) {
+ this.rootEntity = rootEntity;
+ DocumentBuilder provider = searchFactoryImplementor.getDocumentBuilders().get( rootEntity );
+ if ( provider == null) throw new AssertionFailure("Provider not found for class: " + rootEntity);
+ this.mappedSubclasses = provider.getMappedSubclasses();
+ this.criteria = session.createCriteria( rootEntity );
+ this.useObjectLoader = !provider.isSafeFromTupleId();
+ }
+ }
+}
Modified: search/trunk/src/java/org/hibernate/search/engine/ObjectLoader.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/ObjectLoader.java 2008-06-27 00:25:45 UTC (rev 14817)
+++ search/trunk/src/java/org/hibernate/search/engine/ObjectLoader.java 2008-06-28 10:51:13 UTC (rev 14818)
@@ -21,22 +21,7 @@
}
public Object load(EntityInfo entityInfo) {
- //be sure to get an initialized object but save from ONFE and ENFE
- Object maybeProxy = session.load( entityInfo.clazz, entityInfo.id );
- try {
- Hibernate.initialize( maybeProxy );
- }
- catch (RuntimeException e) {
- if ( LoaderHelper.isObjectNotFoundException( e ) ) {
- log.debug( "Object found in Search index but not in database: {} with id {}",
- entityInfo.clazz, entityInfo.id );
- maybeProxy = null;
- }
- else {
- throw e;
- }
- }
- return maybeProxy;
+ return ObjectLoaderHelper.load( entityInfo, session );
}
public List load(EntityInfo... entityInfos) {
Added: search/trunk/src/java/org/hibernate/search/engine/ObjectLoaderHelper.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/ObjectLoaderHelper.java (rev 0)
+++ search/trunk/src/java/org/hibernate/search/engine/ObjectLoaderHelper.java 2008-06-28 10:51:13 UTC (rev 14818)
@@ -0,0 +1,90 @@
+package org.hibernate.search.engine;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+import java.io.Serializable;
+
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Criteria;
+import org.hibernate.type.EntityType;
+import org.hibernate.criterion.Disjunction;
+import org.hibernate.criterion.Restrictions;
+import org.hibernate.annotations.common.AssertionFailure;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class ObjectLoaderHelper {
+
+ private static final int MAX_IN_CLAUSE = 500;
+ private static final Logger log = LoggerFactory.getLogger( ObjectLoader.class );
+
+ public static Object load(EntityInfo entityInfo, Session session) {
+ //be sure to get an initialized object but save from ONFE and ENFE
+ Object maybeProxy = session.load( entityInfo.clazz, entityInfo.id );
+ try {
+ Hibernate.initialize( maybeProxy );
+ }
+ catch (RuntimeException e) {
+ if ( LoaderHelper.isObjectNotFoundException( e ) ) {
+ log.debug( "Object found in Search index but not in database: {} with id {}",
+ entityInfo.clazz, entityInfo.id );
+ maybeProxy = null;
+ }
+ else {
+ throw e;
+ }
+ }
+ return maybeProxy;
+ }
+
+ public static void initializeObjects(EntityInfo[] entityInfos, Criteria criteria, Class entityType,
+ SearchFactoryImplementor searchFactoryImplementor) {
+ final int maxResults = entityInfos.length;
+ if ( maxResults == 0 ) return;
+
+ DocumentBuilder builder = searchFactoryImplementor.getDocumentBuilders().get( entityType );
+ String idName = builder.getIdentifierName();
+ int loop = maxResults / MAX_IN_CLAUSE;
+ boolean exact = maxResults % MAX_IN_CLAUSE == 0;
+ if ( !exact ) loop++;
+ Disjunction disjunction = Restrictions.disjunction();
+ for (int index = 0; index < loop; index++) {
+ int max = index * MAX_IN_CLAUSE + MAX_IN_CLAUSE <= maxResults ?
+ index * MAX_IN_CLAUSE + MAX_IN_CLAUSE :
+ maxResults;
+ List<Serializable> ids = new ArrayList<Serializable>( max - index * MAX_IN_CLAUSE );
+ for (int entityInfoIndex = index * MAX_IN_CLAUSE; entityInfoIndex < max; entityInfoIndex++) {
+ ids.add( entityInfos[entityInfoIndex].id );
+ }
+ disjunction.add( Restrictions.in( idName, ids ) );
+ }
+ criteria.add( disjunction );
+ criteria.list(); //load all objects
+ }
+
+
+ public static List returnAlreadyLoadedObjectsInCorrectOrder(EntityInfo[] entityInfos, Session session) {
+ //mandatory to keep the same ordering
+ List result = new ArrayList( entityInfos.length );
+ for (EntityInfo entityInfo : entityInfos) {
+ Object element = session.load( entityInfo.clazz, entityInfo.id );
+ if ( Hibernate.isInitialized( element ) ) {
+ //all existing elements should have been loaded by the query,
+ //the other ones are missing ones
+ result.add( element );
+ }
+ else {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Object found in Search index but not in database: {} with {}",
+ entityInfo.clazz, entityInfo.id );
+ }
+ }
+ }
+ return result;
+ }
+}
Modified: search/trunk/src/java/org/hibernate/search/engine/ProjectionLoader.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/ProjectionLoader.java 2008-06-27 00:25:45 UTC (rev 14817)
+++ search/trunk/src/java/org/hibernate/search/engine/ProjectionLoader.java 2008-06-28 10:51:13 UTC (rev 14818)
@@ -10,6 +10,7 @@
/**
* @author Emmanuel Bernard
*/
+//TODO change the underlying ObjectLoader to a MutliClassesQueryLoader
public class ProjectionLoader implements Loader {
private SearchFactoryImplementor searchFactoryImplementor;
private Session session;
Modified: search/trunk/src/java/org/hibernate/search/engine/QueryLoader.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/QueryLoader.java 2008-06-27 00:25:45 UTC (rev 14817)
+++ search/trunk/src/java/org/hibernate/search/engine/QueryLoader.java 2008-06-28 10:51:13 UTC (rev 14818)
@@ -2,15 +2,13 @@
package org.hibernate.search.engine;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
+import java.util.Collections;
import org.hibernate.Criteria;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.annotations.common.AssertionFailure;
-import org.hibernate.criterion.Disjunction;
-import org.hibernate.criterion.Restrictions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -18,7 +16,6 @@
* @author Emmanuel Bernard
*/
public class QueryLoader implements Loader {
- private static final int MAX_IN_CLAUSE = 500;
private final Logger log = LoggerFactory.getLogger( QueryLoader.class );
private Session session;
@@ -36,66 +33,16 @@
}
public Object load(EntityInfo entityInfo) {
- //be sure to get an initialized object
- Object maybeProxy = session.get( entityInfo.clazz, entityInfo.id );
- try {
- Hibernate.initialize( maybeProxy );
- }
- catch (RuntimeException e) {
- if ( LoaderHelper.isObjectNotFoundException( e ) ) {
- log.debug( "Object found in Search index but not in database: {} with id {}",
- entityInfo.clazz, entityInfo.id );
- maybeProxy = null;
- }
- else {
- throw e;
- }
- }
- return maybeProxy;
+ return ObjectLoaderHelper.load( entityInfo, session );
}
public List load(EntityInfo... entityInfos) {
- final int maxResults = entityInfos.length;
- if ( maxResults == 0 ) return Collections.EMPTY_LIST;
+ if ( entityInfos.length == 0 ) return Collections.EMPTY_LIST;
if ( entityType == null ) throw new AssertionFailure( "EntityType not defined" );
if ( criteria == null ) criteria = session.createCriteria( entityType );
- DocumentBuilder builder = searchFactoryImplementor.getDocumentBuilders().get( entityType );
- String idName = builder.getIdentifierName();
- int loop = maxResults / MAX_IN_CLAUSE;
- boolean exact = maxResults % MAX_IN_CLAUSE == 0;
- if ( !exact ) loop++;
- Disjunction disjunction = Restrictions.disjunction();
- for (int index = 0; index < loop; index++) {
- int max = index * MAX_IN_CLAUSE + MAX_IN_CLAUSE <= maxResults ?
- index * MAX_IN_CLAUSE + MAX_IN_CLAUSE :
- maxResults;
- List ids = new ArrayList( max - index * MAX_IN_CLAUSE );
- for (int entityInfoIndex = index * MAX_IN_CLAUSE; entityInfoIndex < max; entityInfoIndex++) {
- ids.add( entityInfos[entityInfoIndex].id );
- }
- disjunction.add( Restrictions.in( idName, ids ) );
- }
- criteria.add( disjunction );
- criteria.list(); //load all objects
-
- //mandatory to keep the same ordering
- List result = new ArrayList( entityInfos.length );
- for (EntityInfo entityInfo : entityInfos) {
- Object element = session.load( entityInfo.clazz, entityInfo.id );
- if ( Hibernate.isInitialized( element ) ) {
- //all existing elements should have been loaded by the query,
- //the other ones are missing ones
- result.add( element );
- }
- else {
- if ( log.isDebugEnabled() ) {
- log.debug( "Object found in Search index but not in database: {} with {}",
- entityInfo.clazz, entityInfo.id );
- }
- }
- }
- return result;
+ ObjectLoaderHelper.initializeObjects( entityInfos, criteria, entityType, searchFactoryImplementor );
+ return ObjectLoaderHelper.returnAlreadyLoadedObjectsInCorrectOrder( entityInfos, session );
}
public void setCriteria(Criteria criteria) {
Modified: search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2008-06-27 00:25:45 UTC (rev 14817)
+++ search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2008-06-28 10:51:13 UTC (rev 14818)
@@ -43,10 +43,10 @@
import org.hibernate.search.engine.EntityInfo;
import org.hibernate.search.engine.FilterDef;
import org.hibernate.search.engine.Loader;
-import org.hibernate.search.engine.ObjectLoader;
import org.hibernate.search.engine.ProjectionLoader;
import org.hibernate.search.engine.QueryLoader;
import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.engine.MultiClassesQueryLoader;
import org.hibernate.search.filter.ChainedFilter;
import org.hibernate.search.filter.FilterKey;
import org.hibernate.search.reader.ReaderProvider;
@@ -185,15 +185,16 @@
return loader;
}
else if ( classes.length == 1 ) {
- QueryLoader loader = new QueryLoader();
+ final QueryLoader loader = new QueryLoader();
loader.init( session, searchFactoryImplementor );
loader.setEntityType( classes[0] );
return loader;
}
else {
- final ObjectLoader objectLoader = new ObjectLoader();
- objectLoader.init( session, searchFactoryImplementor );
- return objectLoader;
+ final MultiClassesQueryLoader loader = new MultiClassesQueryLoader();
+ loader.init( session, searchFactoryImplementor );
+ loader.setEntityTypes( classes );
+ return loader;
}
}
Copied: search/trunk/src/test/org/hibernate/search/test/query/MultiClassesQueryLoaderTest.java (from rev 14770, search/trunk/src/test/org/hibernate/search/test/query/ObjectLoaderTest.java)
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/query/MultiClassesQueryLoaderTest.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/query/MultiClassesQueryLoaderTest.java 2008-06-28 10:51:13 UTC (rev 14818)
@@ -0,0 +1,56 @@
+//$
+package org.hibernate.search.test.query;
+
+import java.sql.Statement;
+import java.util.List;
+
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.FullTextQuery;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.analysis.KeywordAnalyzer;
+import org.apache.lucene.search.Query;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class MultiClassesQueryLoaderTest extends SearchTestCase {
+
+ public void testObjectNotFound() throws Exception {
+ Session sess = openSession();
+ Transaction tx = sess.beginTransaction();
+ Author author = new Author();
+ author.setName( "Moo Cow" );
+ sess.persist( author );
+
+ tx.commit();
+ sess.clear();
+ Statement statement = sess.connection().createStatement();
+ statement.executeUpdate( "DELETE FROM Author" );
+ statement.close();
+ FullTextSession s = Search.createFullTextSession( sess );
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "title", new KeywordAnalyzer() );
+ Query query = parser.parse( "name:moo" );
+ FullTextQuery hibQuery = s.createFullTextQuery( query, Author.class, Music.class );
+ List result = hibQuery.list();
+ assertEquals( "Should have returned no author", 0, result.size() );
+
+ for (Object o : s.createCriteria( Object.class ).list()) {
+ s.delete( o );
+ }
+
+ tx.commit();
+ s.close();
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Author.class,
+ Music.class
+ };
+ }
+}
Deleted: search/trunk/src/test/org/hibernate/search/test/query/ObjectLoaderTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/query/ObjectLoaderTest.java 2008-06-27 00:25:45 UTC (rev 14817)
+++ search/trunk/src/test/org/hibernate/search/test/query/ObjectLoaderTest.java 2008-06-28 10:51:13 UTC (rev 14818)
@@ -1,56 +0,0 @@
-//$
-package org.hibernate.search.test.query;
-
-import java.sql.Statement;
-import java.util.List;
-
-import org.hibernate.search.test.SearchTestCase;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.FullTextQuery;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.analysis.KeywordAnalyzer;
-import org.apache.lucene.search.Query;
-
-/**
- * @author Emmanuel Bernard
- */
-public class ObjectLoaderTest extends SearchTestCase {
-
- public void testObjectNotFound() throws Exception {
- Session sess = openSession();
- Transaction tx = sess.beginTransaction();
- Author author = new Author();
- author.setName( "Moo Cow" );
- sess.persist( author );
-
- tx.commit();
- sess.clear();
- Statement statement = sess.connection().createStatement();
- statement.executeUpdate( "DELETE FROM Author" );
- statement.close();
- FullTextSession s = Search.createFullTextSession( sess );
- tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "title", new KeywordAnalyzer() );
- Query query = parser.parse( "name:moo" );
- FullTextQuery hibQuery = s.createFullTextQuery( query, Author.class, Music.class );
- List result = hibQuery.list();
- assertEquals( "Should have returned no author", 0, result.size() );
-
- for (Object o : s.createCriteria( Object.class ).list()) {
- s.delete( o );
- }
-
- tx.commit();
- s.close();
- }
-
- protected Class[] getMappings() {
- return new Class[] {
- Author.class,
- Music.class
- };
- }
-}
16 years, 5 months
Hibernate SVN: r14817 - in search/trunk/src: java/org/hibernate/search/backend/impl and 5 other directories.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2008-06-26 20:25:45 -0400 (Thu, 26 Jun 2008)
New Revision: 14817
Modified:
search/trunk/src/java/org/hibernate/search/backend/Workspace.java
search/trunk/src/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
search/trunk/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java
search/trunk/src/java/org/hibernate/search/impl/FullTextSessionImpl.java
search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java
search/trunk/src/java/org/hibernate/search/reader/SharingBufferReaderProvider.java
search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
search/trunk/src/java/org/hibernate/search/store/FSMasterDirectoryProvider.java
search/trunk/src/test/org/hibernate/search/test/reader/performance/ReaderPerformance.java
Log:
minor DirectoryProviders's Locks reorganization (and relative API)
Modified: search/trunk/src/java/org/hibernate/search/backend/Workspace.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/Workspace.java 2008-06-26 22:15:36 UTC (rev 14816)
+++ search/trunk/src/java/org/hibernate/search/backend/Workspace.java 2008-06-27 00:25:45 UTC (rev 14817)
@@ -4,7 +4,7 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.locks.Lock;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.SimpleAnalyzer;
@@ -189,7 +189,7 @@
private class DPWorkspace {
private final DirectoryProvider directoryProvider;
- private final ReentrantLock lock;
+ private final Lock lock;
private IndexReader reader;
private IndexWriter writer;
@@ -199,7 +199,7 @@
DPWorkspace(DirectoryProvider dp) {
this.directoryProvider = dp;
- this.lock = searchFactoryImplementor.getLockableDirectoryProviders().get( dp );
+ this.lock = searchFactoryImplementor.getDirectoryProviderLock( dp );
}
public boolean needsOptimization() {
Modified: search/trunk/src/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2008-06-26 22:15:36 UTC (rev 14816)
+++ search/trunk/src/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2008-06-27 00:25:45 UTC (rev 14817)
@@ -38,14 +38,13 @@
private static final Logger log = LoggerFactory.getLogger( BatchedQueueingProcessor.class );
- private boolean sync;
- private int batchSize;
- private ExecutorService executorService;
- private BackendQueueProcessorFactory backendQueueProcessorFactory;
- private SearchFactoryImplementor searchFactoryImplementor;
+ private final boolean sync;
+ private final int batchSize;
+ private final ExecutorService executorService;
+ private final BackendQueueProcessorFactory backendQueueProcessorFactory;
+ private final SearchFactoryImplementor searchFactoryImplementor;
- public BatchedQueueingProcessor(SearchFactoryImplementor searchFactoryImplementor,
- Properties properties) {
+ public BatchedQueueingProcessor(SearchFactoryImplementor searchFactoryImplementor, Properties properties) {
this.searchFactoryImplementor = searchFactoryImplementor;
//default to sync if none defined
this.sync = !"async".equalsIgnoreCase( properties.getProperty( Environment.WORKER_EXECUTION ) );
@@ -71,6 +70,9 @@
new ThreadPoolExecutor.CallerRunsPolicy()
);
}
+ else {
+ executorService = null;
+ }
String backend = properties.getProperty( Environment.WORKER_BACKEND );
if ( StringHelper.isEmpty( backend ) || "lucene".equalsIgnoreCase( backend ) ) {
backendQueueProcessorFactory = new LuceneBackendQueueProcessorFactory();
Modified: search/trunk/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java 2008-06-26 22:15:36 UTC (rev 14816)
+++ search/trunk/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java 2008-06-27 00:25:45 UTC (rev 14817)
@@ -3,7 +3,7 @@
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.locks.Lock;
import org.hibernate.search.SearchFactory;
import org.hibernate.search.backend.BackendQueueProcessorFactory;
@@ -26,8 +26,6 @@
Map<Class, DocumentBuilder<Object>> getDocumentBuilders();
- Map<DirectoryProvider, ReentrantLock> getLockableDirectoryProviders();
-
Worker getWorker();
void addOptimizerStrategy(DirectoryProvider<?> provider, OptimizerStrategy optimizerStrategy);
@@ -49,4 +47,11 @@
void addClassToDirectoryProvider(Class clazz, DirectoryProvider<?> directoryProvider);
Set<Class> getClassesInDirectoryProvider(DirectoryProvider<?> directoryProvider);
+
+ Set<DirectoryProvider> getDirectoryProviders();
+
+ Lock getDirectoryProviderLock(DirectoryProvider dp);
+
+ void addDirectoryProvider(DirectoryProvider<?> provider);
+
}
Modified: search/trunk/src/java/org/hibernate/search/impl/FullTextSessionImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/impl/FullTextSessionImpl.java 2008-06-26 22:15:36 UTC (rev 14816)
+++ search/trunk/src/java/org/hibernate/search/impl/FullTextSessionImpl.java 2008-06-27 00:25:45 UTC (rev 14817)
@@ -43,7 +43,6 @@
import org.hibernate.search.FullTextQuery;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.SearchFactory;
-import org.hibernate.search.SearchException;
import org.hibernate.search.backend.Work;
import org.hibernate.search.backend.WorkType;
import org.hibernate.search.engine.DocumentBuilder;
@@ -153,9 +152,9 @@
//need to add elements in a queue kept at the Session level
//the queue will be processed by a Lucene(Auto)FlushEventListener
//note that we could keep this queue somewhere in the event listener in the mean time but that requires
- // a synchronized hashmap holding this queue on a per session basis plus some session house keeping (yuk)
- //an other solution would be to subclass SessionImpl instead of having this LuceneSession delecation model
- // this is an open discussion
+ //a synchronized hashmap holding this queue on a per session basis plus some session house keeping (yuk)
+ //another solution would be to subclass SessionImpl instead of having this LuceneSession delegation model
+ //this is an open discussion
}
public SearchFactory getSearchFactory() {
Modified: search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2008-06-26 22:15:36 UTC (rev 14816)
+++ search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2008-06-27 00:25:45 UTC (rev 14817)
@@ -13,6 +13,8 @@
import java.util.Properties;
import java.util.Set;
import java.util.WeakHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.lucene.analysis.Analyzer;
@@ -60,29 +62,25 @@
Version.touch();
}
- private static final Logger log = LoggerFactory.getLogger( SearchFactoryImpl.class );
+ private final Logger log = LoggerFactory.getLogger( SearchFactoryImpl.class );
private final Map<Class, DocumentBuilder<Object>> documentBuilders = new HashMap<Class, DocumentBuilder<Object>>();
//keep track of the index modifiers per DirectoryProvider since multiple entity can use the same directory provider
- //TODO move the ReentrantLock into DirectoryProviderData.lock, add a getDPLock(DP) and add a Set<DP> getDirectoryProviders() method.
- private final Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders =
- new HashMap<DirectoryProvider, ReentrantLock>();
- private final Map<DirectoryProvider, DirectoryProviderData> dirProviderData =
- new HashMap<DirectoryProvider, DirectoryProviderData>();
- private Worker worker;
- private ReaderProvider readerProvider;
+ private final Map<DirectoryProvider, DirectoryProviderData> dirProviderData = new HashMap<DirectoryProvider, DirectoryProviderData>();
+ private final Worker worker;
+ private final ReaderProvider readerProvider;
private BackendQueueProcessorFactory backendQueueProcessorFactory;
private final Map<String, FilterDef> filterDefinitions = new HashMap<String, FilterDef>();
- private FilterCachingStrategy filterCachingStrategy;
+ private final FilterCachingStrategy filterCachingStrategy;
private Map<String, Analyzer> analyzers;
- private boolean stopped = false;
+ private final AtomicBoolean stopped = new AtomicBoolean( false );
/**
* Each directory provider (index) can have its own performance settings.
*/
private Map<DirectoryProvider, LuceneIndexingParameters> dirProviderIndexingParams =
new HashMap<DirectoryProvider, LuceneIndexingParameters>();
- private String indexingStrategy;
+ private final String indexingStrategy;
public BackendQueueProcessorFactory getBackendQueueProcessorFactory() {
@@ -97,24 +95,24 @@
public SearchFactoryImpl(Configuration cfg) {
//yuk
ReflectionManager reflectionManager = getReflectionManager( cfg );
- setIndexingStrategy(cfg); //need to be done before the document builds
- InitContext context = new InitContext(cfg);
- initDocumentBuilders(cfg, reflectionManager, context );
+ this.indexingStrategy = defineIndexingStrategy( cfg ); //need to be done before the document builds
+ initDocumentBuilders( cfg, reflectionManager );
Set<Class> indexedClasses = documentBuilders.keySet();
for (DocumentBuilder builder : documentBuilders.values()) {
builder.postInitialize( indexedClasses );
}
- worker = WorkerFactory.createWorker( cfg, this );
- readerProvider = ReaderProviderFactory.createReaderProvider( cfg, this );
- buildFilterCachingStrategy( cfg.getProperties() );
+ this.worker = WorkerFactory.createWorker( cfg, this );
+ this.readerProvider = ReaderProviderFactory.createReaderProvider( cfg, this );
+ this.filterCachingStrategy = buildFilterCachingStrategy( cfg.getProperties() );
}
- private void setIndexingStrategy(Configuration cfg) {
- indexingStrategy = cfg.getProperties().getProperty( Environment.INDEXING_STRATEGY, "event" );
+ private static String defineIndexingStrategy(Configuration cfg) {
+ String indexingStrategy = cfg.getProperties().getProperty( Environment.INDEXING_STRATEGY, "event" );
if ( ! ("event".equals( indexingStrategy ) || "manual".equals( indexingStrategy ) ) ) {
- throw new SearchException(Environment.INDEXING_STRATEGY + " unknown: " + indexingStrategy);
+ throw new SearchException( Environment.INDEXING_STRATEGY + " unknown: " + indexingStrategy );
}
+ return indexingStrategy;
}
public String getIndexingStrategy() {
@@ -122,8 +120,7 @@
}
public void close() {
- if (!stopped) {
- stopped = true;
+ if ( stopped.compareAndSet( false, true) ) {
try {
worker.close();
}
@@ -131,7 +128,7 @@
log.error( "Worker raises an exception on close()", e );
}
//TODO move to DirectoryProviderFactory for cleaner
- for (DirectoryProvider dp : lockableDirectoryProviders.keySet() ) {
+ for (DirectoryProvider dp : getDirectoryProviders() ) {
try {
dp.stop();
}
@@ -223,7 +220,6 @@
SearchFactoryImpl searchFactory = contextMap.get( cfg );
if ( searchFactory == null ) {
searchFactory = new SearchFactoryImpl( cfg );
-
contextMap.put( cfg, searchFactory );
}
return searchFactory;
@@ -234,8 +230,8 @@
return documentBuilders;
}
- public Map<DirectoryProvider, ReentrantLock> getLockableDirectoryProviders() {
- return lockableDirectoryProviders;
+ public Set<DirectoryProvider> getDirectoryProviders() {
+ return this.dirProviderData.keySet();
}
public Worker getWorker() {
@@ -272,7 +268,7 @@
ReflectionManager reflectionManager;
try {
//TODO introduce a ReflectionManagerHolder interface to avoid reflection
- //I want to avoid hard link between HAN and Validator for usch a simple need
+ //I want to avoid hard link between HAN and Validator for such a simple need
//reuse the existing reflectionManager one when possible
reflectionManager =
(ReflectionManager) cfg.getClass().getMethod( "getReflectionManager" ).invoke( cfg );
@@ -311,11 +307,12 @@
return analyzer;
}
- private void initDocumentBuilders(Configuration cfg, ReflectionManager reflectionManager, InitContext context) {
+ private void initDocumentBuilders(Configuration cfg, ReflectionManager reflectionManager) {
+ InitContext context = new InitContext( cfg );
Iterator iter = cfg.getClassMappings();
DirectoryProviderFactory factory = new DirectoryProviderFactory();
- while (iter.hasNext()) {
+ while ( iter.hasNext() ) {
PersistentClass clazz = (PersistentClass) iter.next();
Class<?> mappedClass = clazz.getMappedClass();
if (mappedClass != null) {
@@ -340,7 +337,8 @@
factory.startDirectoryProviders();
}
- private void buildFilterCachingStrategy(Properties properties) {
+ private static FilterCachingStrategy buildFilterCachingStrategy(Properties properties) {
+ FilterCachingStrategy filterCachingStrategy;
String impl = properties.getProperty( Environment.FILTER_CACHING_STRATEGY );
if ( StringHelper.isEmpty( impl ) || "mru".equalsIgnoreCase( impl ) ) {
filterCachingStrategy = new MRUFilterCachingStrategy();
@@ -361,6 +359,7 @@
}
}
filterCachingStrategy.initialize( properties );
+ return filterCachingStrategy;
}
public FilterCachingStrategy getFilterCachingStrategy() {
@@ -372,7 +371,17 @@
}
private static class DirectoryProviderData {
+ public final Lock dirLock = new ReentrantLock();
public OptimizerStrategy optimizerStrategy;
public Set<Class> classes = new HashSet<Class>(2);
}
+
+ public Lock getDirectoryProviderLock(DirectoryProvider dp) {
+ return this.dirProviderData.get( dp ).dirLock;
+ }
+
+ public void addDirectoryProvider(DirectoryProvider<?> provider) {
+ this.dirProviderData.put( provider, new DirectoryProviderData() );
+ }
+
}
Modified: search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java 2008-06-26 22:15:36 UTC (rev 14816)
+++ search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java 2008-06-27 00:25:45 UTC (rev 14817)
@@ -282,7 +282,7 @@
}
public void initialize(Properties props, SearchFactoryImplementor searchFactoryImplementor) {
- Set<DirectoryProvider> providers = searchFactoryImplementor.getLockableDirectoryProviders().keySet();
+ Set<DirectoryProvider> providers = searchFactoryImplementor.getDirectoryProviders();
perDirectoryProviderManipulationLocks = new HashMap<DirectoryProvider, Lock>( providers.size() );
for (DirectoryProvider dp : providers) {
perDirectoryProviderManipulationLocks.put( dp, new ReentrantLock() );
Modified: search/trunk/src/java/org/hibernate/search/reader/SharingBufferReaderProvider.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/reader/SharingBufferReaderProvider.java 2008-06-26 22:15:36 UTC (rev 14816)
+++ search/trunk/src/java/org/hibernate/search/reader/SharingBufferReaderProvider.java 2008-06-27 00:25:45 UTC (rev 14817)
@@ -63,7 +63,7 @@
public void initialize(Properties props, SearchFactoryImplementor searchFactoryImplementor) {
Map<DirectoryProvider,PerDirectoryLatestReader> map = new HashMap<DirectoryProvider,PerDirectoryLatestReader>();
- Set<DirectoryProvider> providers = searchFactoryImplementor.getLockableDirectoryProviders().keySet();
+ Set<DirectoryProvider> providers = searchFactoryImplementor.getDirectoryProviders();
for ( DirectoryProvider provider : providers ) {
try {
map.put( provider, new PerDirectoryLatestReader( provider ) );
Modified: search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2008-06-26 22:15:36 UTC (rev 14816)
+++ search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2008-06-27 00:25:45 UTC (rev 14817)
@@ -47,7 +47,7 @@
public class DirectoryProviderFactory {
private final List<DirectoryProvider<?>> providers = new ArrayList<DirectoryProvider<?>>();
- private static String DEFAULT_DIRECTORY_PROVIDER = FSDirectoryProvider.class.getName();
+ private static final String DEFAULT_DIRECTORY_PROVIDER = FSDirectoryProvider.class.getName();
private static final String SHARDING_STRATEGY = "sharding_strategy";
private static final String NBR_OF_SHARDS = SHARDING_STRATEGY + ".nbr_of_shards";
@@ -149,8 +149,8 @@
configureIndexingParameters( searchFactoryImplementor, indexProps, provider );
providers.add( provider );
searchFactoryImplementor.addClassToDirectoryProvider(entity, provider);
- if ( !searchFactoryImplementor.getLockableDirectoryProviders().containsKey( provider ) ) {
- searchFactoryImplementor.getLockableDirectoryProviders().put( provider, new ReentrantLock() );
+ if ( ! searchFactoryImplementor.getDirectoryProviders().contains( provider ) ) {
+ searchFactoryImplementor.addDirectoryProvider( provider );
}
return provider;
}
Modified: search/trunk/src/java/org/hibernate/search/store/FSMasterDirectoryProvider.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/store/FSMasterDirectoryProvider.java 2008-06-26 22:15:36 UTC (rev 14816)
+++ search/trunk/src/java/org/hibernate/search/store/FSMasterDirectoryProvider.java 2008-06-27 00:25:45 UTC (rev 14817)
@@ -169,7 +169,7 @@
long start = System.currentTimeMillis();
inProgress = true;
if ( directoryProviderLock == null ) {
- directoryProviderLock = searchFactory.getLockableDirectoryProviders().get( directoryProvider );
+ directoryProviderLock = searchFactory.getDirectoryProviderLock( directoryProvider );
directoryProvider = null;
searchFactory = null; //get rid of any useless link (help hot redeployment?)
}
Modified: search/trunk/src/test/org/hibernate/search/test/reader/performance/ReaderPerformance.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/reader/performance/ReaderPerformance.java 2008-06-26 22:15:36 UTC (rev 14816)
+++ search/trunk/src/test/org/hibernate/search/test/reader/performance/ReaderPerformance.java 2008-06-27 00:25:45 UTC (rev 14817)
@@ -29,13 +29,15 @@
private static final File baseIndexDir = new File( new File( "." ), "indextemp" );
//more iterations for more reliable measures:
- private static final int TOTAL_WORK_BATCHES = 1000;
+ private static final int TOTAL_WORK_BATCHES = 10;
//the next 3 define the kind of workload mix to test on:
private static final int SEARCHERS_PER_BATCH = 10;
private static final int UPDATES_PER_BATCH = 2;
private static final int INSERTIONS_PER_BATCH = 1;
- private static final int WORKER_THREADS = 30;
+ private static final int WORKER_THREADS = 20;
+
+ private static final int WARMUP_CYCLES = 6;
protected void setUp() throws Exception {
baseIndexDir.mkdir();
@@ -44,8 +46,6 @@
FileHelper.delete( file );
}
super.setUp();
- //enable this line:
-// buildBigIndex();
}
public void testFakeTest(){
@@ -53,15 +53,17 @@
}
private void buildBigIndex() throws InterruptedException, CorruptIndexException, LockObtainFailedException, IOException {
+ System.out.println( "Going to create fake index..." );
FSDirectory directory = FSDirectory.getDirectory(new File(baseIndexDir, Detective.class.getCanonicalName()));
IndexWriter iw = new IndexWriter( directory, new SimpleAnalyzer(), true );
IndexFillRunnable filler = new IndexFillRunnable( iw );
ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool( WORKER_THREADS );
- for (int batch=0; batch<=100000; batch++){
+ for (int batch=0; batch<=5000000; batch++){
executor.execute( filler );
}
executor.shutdown();
executor.awaitTermination( 600, TimeUnit.SECONDS );
+ iw.optimize();
iw.close();
System.out.println( "Index created." );
}
@@ -75,7 +77,7 @@
protected void tearDown() throws Exception {
super.tearDown();
-// FileHelper.delete( baseIndexDir );
+ FileHelper.delete( baseIndexDir );
}
protected void configure(org.hibernate.cfg.Configuration cfg) {
@@ -90,7 +92,14 @@
protected abstract String getReaderStrategyName();
//this test is disabled as it is very slow (and someone should read the output)
- public final void disabled_testPerformance() throws InterruptedException{
+ public final void disabled_testPerformance() throws InterruptedException, CorruptIndexException, LockObtainFailedException, IOException {
+ buildBigIndex();
+ for (int i=0; i<WARMUP_CYCLES; i++) {
+ timeMs();
+ }
+ }
+
+ private final void timeMs() throws InterruptedException {
ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool( WORKER_THREADS );
CountDownLatch startSignal = new CountDownLatch(1);
InsertActivity insertionTask = new InsertActivity( getSessions(), startSignal );
16 years, 5 months
Hibernate SVN: r14816 - common/branches.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2008-06-26 18:15:36 -0400 (Thu, 26 Jun 2008)
New Revision: 14816
Added:
common/branches/v3_2_1_GA_CP/
Log:
JBPAPP-931, create v3_2_1_GA_CP branch for hibernate/common
Copied: common/branches/v3_2_1_GA_CP (from rev 14815, common/tags/entitymanager_v3_2_1_GA)
16 years, 5 months
Hibernate SVN: r14815 - in annotations/branches/v3_2_1_GA_CP/src: test/org/hibernate/test/annotations/query and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2008-06-26 16:10:03 -0400 (Thu, 26 Jun 2008)
New Revision: 14815
Modified:
annotations/branches/v3_2_1_GA_CP/src/java/org/hibernate/cfg/AnnotationBinder.java
annotations/branches/v3_2_1_GA_CP/src/test/org/hibernate/test/annotations/query/Chaos.java
Log:
JBPAPP-258 ANN-551, backporting 3.2.1.GA.patch01-brew into annotations 3_2_1_GA_CP branch
Modified: annotations/branches/v3_2_1_GA_CP/src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- annotations/branches/v3_2_1_GA_CP/src/java/org/hibernate/cfg/AnnotationBinder.java 2008-06-26 16:09:18 UTC (rev 14814)
+++ annotations/branches/v3_2_1_GA_CP/src/java/org/hibernate/cfg/AnnotationBinder.java 2008-06-26 20:10:03 UTC (rev 14815)
@@ -2,6 +2,8 @@
package org.hibernate.cfg;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
@@ -943,6 +945,12 @@
log.debug( "Processing " + propertyHolder.getEntityName() + " " + accessType + " annotation" );
List<XProperty> properties = annotatedClass.getDeclaredProperties( accessType );
+ //order so that property are used int he same order when binding native query
+ Collections.sort( properties, new Comparator<XProperty>() {
+ public int compare(XProperty property1, XProperty property2) {
+ return property1.getName().compareTo( property2.getName() );
+ }
+ } );
for ( XProperty p : properties ) {
if ( !p.isTypeResolved() && !discoverTypeWithoutReflection( p ) && !mustBeSkipped( p, mappings ) ) {
throw new AnnotationException(
Modified: annotations/branches/v3_2_1_GA_CP/src/test/org/hibernate/test/annotations/query/Chaos.java
===================================================================
--- annotations/branches/v3_2_1_GA_CP/src/test/org/hibernate/test/annotations/query/Chaos.java 2008-06-26 16:09:18 UTC (rev 14814)
+++ annotations/branches/v3_2_1_GA_CP/src/test/org/hibernate/test/annotations/query/Chaos.java 2008-06-26 20:10:03 UTC (rev 14815)
@@ -22,8 +22,8 @@
*/
@Entity
@Table(name="CHAOS")
-@SQLInsert( sql="INSERT INTO CHAOS(size, name, nickname, id) VALUES(?,upper(?),?,?)")
-@SQLUpdate( sql="UPDATE CHAOS SET size = ?, name = upper(?), nickname = ? WHERE id = ?")
+@SQLInsert( sql="INSERT INTO CHAOS(name, nickname, size, id) VALUES(upper(?),?,?,?)")
+@SQLUpdate( sql="UPDATE CHAOS SET name = upper(?), nickname = ?, size = ? WHERE id = ?")
@SQLDelete( sql="DELETE CHAOS WHERE id = ?")
@SQLDeleteAll( sql="DELETE CHAOS")
@Loader(namedQuery = "chaos")
16 years, 5 months
Hibernate SVN: r14814 - annotations/trunk/ivy.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-26 12:09:18 -0400 (Thu, 26 Jun 2008)
New Revision: 14814
Modified:
annotations/trunk/ivy/ivyconf.xml
Log:
A new local reolver for hudson (experimental)
Modified: annotations/trunk/ivy/ivyconf.xml
===================================================================
--- annotations/trunk/ivy/ivyconf.xml 2008-06-26 15:52:45 UTC (rev 14813)
+++ annotations/trunk/ivy/ivyconf.xml 2008-06-26 16:09:18 UTC (rev 14814)
@@ -12,6 +12,10 @@
<ivy pattern="../[module]/target/hibernate-[module]/ivy.xml"/>
<artifact pattern="../[module]/target/hibernate-[module]/[artifact].[ext]"/>
</filesystem>
+ <filesystem name="hudson-local">
+ <ivy pattern="../../[module]/trunk/target/hibernate-[module]/ivy.xml"/>
+ <artifact pattern="../../[module]/trunk/target/hibernate-[module]/[artifact].[ext]"/>
+ </filesystem>
<filesystem name="maven-local" m2compatible="true">
<artifact pattern="${offline.repository.jboss.org}/[organization]/hibernate-[module]/[revision]/hibernate-[artifact]-[revision].[ext]"/>
</filesystem>
16 years, 5 months
Hibernate SVN: r14813 - annotations/trunk/ivy.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-26 11:52:45 -0400 (Thu, 26 Jun 2008)
New Revision: 14813
Modified:
annotations/trunk/ivy/ivyconf.xml
Log:
Adjusted the artifact and ivy pattern for the local resolver in rep-hibernate.
Modified: annotations/trunk/ivy/ivyconf.xml
===================================================================
--- annotations/trunk/ivy/ivyconf.xml 2008-06-25 10:07:04 UTC (rev 14812)
+++ annotations/trunk/ivy/ivyconf.xml 2008-06-26 15:52:45 UTC (rev 14813)
@@ -9,8 +9,8 @@
</chain>
<chain name="rep-hibernate" returnFirst="true" latest="latest-revision">
<filesystem name="local">
- <ivy pattern="../[module]/target/[revision]/ivy.xml"/>
- <artifact pattern="../[module]/target/[revision]/[artifact].[ext]"/>
+ <ivy pattern="../[module]/target/hibernate-[module]/ivy.xml"/>
+ <artifact pattern="../[module]/target/hibernate-[module]/[artifact].[ext]"/>
</filesystem>
<filesystem name="maven-local" m2compatible="true">
<artifact pattern="${offline.repository.jboss.org}/[organization]/hibernate-[module]/[revision]/hibernate-[artifact]-[revision].[ext]"/>
16 years, 5 months