Author: epbernard
Date: 2006-11-01 18:06:05 -0500 (Wed, 01 Nov 2006)
New Revision: 10681
Added:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Boost.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/DateBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/DocumentId.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Field.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/FieldBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Index.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Indexed.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Keyword.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Store.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Text.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Unstored.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/AddWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/DeleteWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/UpdateWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/Work.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/WorkQueue.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/Workspace.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/BatchLuceneWorkQueue.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/LuceneWorker.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/PostTransactionWorkQueueSynchronization.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/engine/
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/engine/DocumentBuilder.java
Removed:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DateBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentId.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Field.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/FieldBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Index.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Indexed.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Keyword.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Store.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Text.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Unstored.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/AddWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/DeleteWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/UpdateWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Work.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkInSynchronization.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkQueue.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Workspace.java
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/IteratorImpl.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/ScrollableResultsImpl.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProvider.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProviderFactory.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/FSDirectoryProvider.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/RAMDirectoryProvider.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/util/BinderHelper.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/AlternateDocument.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Clock.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Document.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/bridge/Cloud.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/fieldAccess/Document.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Animal.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Mammal.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/AlternateBook.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Book.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Clock.java
Log:
ANN-483 package refactoring
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,20 +0,0 @@
-//$Id: $
-package org.hibernate.lucene;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Documented;
-
-/**
- * Apply a boost factor on a field or a whole entity
- *
- * @author Emmanuel Bernard
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
-@Documented
-public @interface Boost {
- float value();
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DateBridge.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DateBridge.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DateBridge.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,24 +0,0 @@
-//$Id: $
-package org.hibernate.lucene;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Documented;
-
-import org.hibernate.lucene.bridge.Resolution;
-
-/**
- * Defines the temporal resolution of a given field
- * Date are stored as String in GMT
- *
- * @author Emmanuel Bernard
- */
-@Retention( RetentionPolicy.RUNTIME)
-(a)Target({ElementType.FIELD, ElementType.METHOD})
-@Documented
-//TODO allow pattern yyyyMMdd?
-public @interface DateBridge {
- Resolution value();
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,318 +0,0 @@
-//$Id$
-package org.hibernate.lucene;
-
-import java.io.Serializable;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.index.Term;
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.annotations.Version;
-import org.hibernate.lucene.bridge.BridgeFactory;
-import org.hibernate.lucene.bridge.FieldBridge;
-import org.hibernate.lucene.bridge.IdFieldBridge;
-import org.hibernate.lucene.event.LuceneEventListener;
-import org.hibernate.lucene.store.DirectoryProvider;
-import org.hibernate.lucene.util.BinderHelper;
-import org.hibernate.reflection.ReflectionManager;
-import org.hibernate.reflection.XAnnotatedElement;
-import org.hibernate.reflection.XClass;
-import org.hibernate.reflection.XMember;
-import org.hibernate.reflection.XProperty;
-import org.hibernate.util.ReflectHelper;
-
-/**
- * Set up and provide a manager for indexes classes
- *
- * @author Gavin King
- * @author Emmanuel Bernard
- * @author Sylvain Vieujot
- * @author Richard Hallier
- */
-public class DocumentBuilder<T> {
-
- static {
- Version.touch(); //touch version
- }
-
- private final List<XMember> keywordGetters = new ArrayList<XMember>();
- private final List<String> keywordNames = new ArrayList<String>();
- private final List<FieldBridge> keywordBridges = new
ArrayList<FieldBridge>();
- private final List<XMember> unstoredGetters = new ArrayList<XMember>();
- private final List<String> unstoredNames = new ArrayList<String>();
- private final List<FieldBridge> unstoredBridges = new
ArrayList<FieldBridge>();
- private final List<XMember> textGetters = new ArrayList<XMember>();
- private final List<String> textNames = new ArrayList<String>();
- private final List<FieldBridge> textBridges = new
ArrayList<FieldBridge>();
- private final List<String> fieldNames = new ArrayList<String>();
- private final List<XMember> fieldGetters = new ArrayList<XMember>();
- private final List<FieldBridge> fieldBridges = new
ArrayList<FieldBridge>();
- private final List<Field.Store> fieldStore = new
ArrayList<Field.Store>();
- private final List<Field.Index> fieldIndex = new
ArrayList<Field.Index>();
-
- private final XClass beanClass;
- private final DirectoryProvider directoryProvider;
- private String idKeywordName;
- private final Analyzer analyzer;
- private Float idBoost;
- public static final String CLASS_FIELDNAME = "_hibernate_class";
- private IdFieldBridge idBridge;
- private Set<Class> mappedSubclasses = new HashSet<Class>();
- private ReflectionManager reflectionManager;
-
-
- public DocumentBuilder(XClass clazz, Analyzer analyzer, DirectoryProvider directory,
ReflectionManager reflectionManager) {
- this.beanClass = clazz;
- this.analyzer = analyzer;
- this.directoryProvider = directory;
- //FIXME get rid of it when boost is stored?
- this.reflectionManager = reflectionManager;
-
- if (clazz == null) throw new AssertionFailure("Unable to build a
DocumentBuilder with a null class");
-
- for ( XClass currClass = beanClass; currClass != null; currClass =
currClass.getSuperclass() ) {
- //rejecting non properties because the object is loaded from Hibernate, so
indexing a non property does not make sense
- List<XProperty> methods = currClass.getDeclaredProperties(
XClass.ACCESS_PROPERTY );
- for ( XProperty method : methods ) {
- initializeMember( method );
- }
-
- List<XProperty> fields = currClass.getDeclaredProperties(
XClass.ACCESS_FIELD );
- for ( XProperty field : fields ) {
- initializeMember( field );
- }
- }
-
- if ( idKeywordName == null ) {
- throw new HibernateException( "No document id for: " +
clazz.getName() );
- }
- }
-
- private void initializeMember(XMember member) {
- Keyword keywordAnn = member.getAnnotation( Keyword.class );
- if ( keywordAnn != null ) {
- String name = BinderHelper.getAttributeName( member, keywordAnn.name() );
- if ( keywordAnn.id() ) {
- idKeywordName = name;
- idBoost = getBoost( member );
- FieldBridge fieldBridge = BridgeFactory.guessType( member );
- if ( fieldBridge instanceof IdFieldBridge ) {
- idBridge = (IdFieldBridge) fieldBridge;
- }
- else {
- throw new HibernateException( "Bridge for document id does not
implement IdFieldBridge: " + member.getName() );
- }
- }
- else {
- setAccessible( member );
- keywordGetters.add( member );
- keywordNames.add( name );
- keywordBridges.add( BridgeFactory.guessType( member ) );
- }
- }
-
- Unstored unstoredAnn = member.getAnnotation( Unstored.class );
- if ( unstoredAnn != null ) {
- setAccessible( member );
- unstoredGetters.add( member );
- unstoredNames.add( BinderHelper.getAttributeName( member, unstoredAnn.name()
) );
- unstoredBridges.add( BridgeFactory.guessType( member ) );
- }
-
- Text textAnn = member.getAnnotation( Text.class );
- if ( textAnn != null ) {
- setAccessible( member );
- textGetters.add( member );
- textNames.add( BinderHelper.getAttributeName( member, textAnn.name() ) );
- textBridges.add( BridgeFactory.guessType( member ) );
- }
-
- DocumentId documentIdAnn = member.getAnnotation( DocumentId.class );
- if ( documentIdAnn != null ) {
- if ( idKeywordName != null ) {
- throw new AssertionFailure( "Two document id assigned: "
- + idKeywordName + " and " + BinderHelper.getAttributeName(
member, documentIdAnn.name() ) );
- }
- idKeywordName = BinderHelper.getAttributeName( member, documentIdAnn.name()
);
- FieldBridge fieldBridge = BridgeFactory.guessType( member );
- if ( fieldBridge instanceof IdFieldBridge ) {
- idBridge = (IdFieldBridge) fieldBridge;
- }
- else {
- throw new HibernateException( "Bridge for document id does not
implement IdFieldBridge: " + member.getName() );
- }
- idBoost = getBoost( member );
- }
-
- org.hibernate.lucene.Field fieldAnn = member.getAnnotation(
org.hibernate.lucene.Field.class );
- if ( fieldAnn != null ) {
- setAccessible( member );
- fieldGetters.add( member );
- fieldNames.add( BinderHelper.getAttributeName( member, fieldAnn.name() ) );
- fieldStore.add( getStore( fieldAnn.store() ) );
- fieldIndex.add( getIndex( fieldAnn.index() ) );
- fieldBridges.add( BridgeFactory.guessType( member ) );
- }
- }
-
- private Field.Store getStore(Store store) {
- switch( store ) {
- case NO:
- return Field.Store.NO;
- case YES:
- return Field.Store.YES;
- case COMPRESS:
- return Field.Store.COMPRESS;
- default:
- throw new AssertionFailure( "Unexpected Store: " + store );
- }
- }
-
- private Field.Index getIndex(Index index) {
- switch( index ) {
- case NO:
- return Field.Index.NO;
- case NO_NORMS:
- return Field.Index.NO_NORMS;
- case TOKENIZED:
- return Field.Index.TOKENIZED;
- case UN_TOKENISED:
- return Field.Index.UN_TOKENIZED;
- default:
- throw new AssertionFailure( "Unexpected Index: " + index );
- }
- }
-
- private Float getBoost(XAnnotatedElement element) {
- if ( element == null ) return null;
- Boost boost = element.getAnnotation( Boost.class );
- return boost != null ?
- boost.value() :
- null;
- }
-
- private Object getMemberValue(T bean, XMember getter) {
- Object value;
- try {
- value = getter.invoke( bean );
- }
- catch (Exception e) {
- throw new IllegalStateException( "Could not get property value", e );
- }
- return value;
- }
-
- public Document getDocument(T instance, Serializable id) {
- Document doc = new Document();
- XClass instanceClass = reflectionManager.toXClass( instance.getClass() );
- Float boost = getBoost( instanceClass );
- if ( boost != null ) {
- doc.setBoost( boost );
- }
- {
- Field classField =
- new Field( CLASS_FIELDNAME, instanceClass.getName(), Field.Store.YES,
Field.Index.UN_TOKENIZED );
- doc.add( classField );
- idBridge.set( idKeywordName, id, doc, Field.Store.YES,
Field.Index.UN_TOKENIZED, idBoost );
- }
- for ( int i = 0; i < keywordNames.size(); i++ ) {
- XMember member = keywordGetters.get( i );
- Object value = getMemberValue( instance, member );
- keywordBridges.get( i ).set(
- keywordNames.get( i ), value, doc, Field.Store.YES,
- Field.Index.UN_TOKENIZED, getBoost( member )
- );
- }
- for ( int i = 0; i < textNames.size(); i++ ) {
- XMember member = textGetters.get( i );
- Object value = getMemberValue( instance, member );
- textBridges.get( i ).set(
- textNames.get( i ), value, doc, Field.Store.YES,
- Field.Index.TOKENIZED, getBoost( member )
- );
- }
- for ( int i = 0; i < unstoredNames.size(); i++ ) {
- XMember member = unstoredGetters.get( i );
- Object value = getMemberValue( instance, member );
- unstoredBridges.get( i ).set(
- unstoredNames.get( i ), value, doc, Field.Store.NO,
- Field.Index.TOKENIZED, getBoost( member )
- );
- }
- for ( int i = 0; i < fieldNames.size(); i++ ) {
- XMember member = fieldGetters.get( i );
- Object value = getMemberValue( instance, member );
- fieldBridges.get( i ).set(
- fieldNames.get( i ), value, doc, fieldStore.get( i ),
- fieldIndex.get( i ), getBoost( member )
- );
- }
- return doc;
- }
-
- public Term getTerm(Serializable id) {
- return new Term( idKeywordName, idBridge.objectToString( id ) );
- }
-
- public DirectoryProvider getDirectoryProvider() {
- return directoryProvider;
- }
-
- public Analyzer getAnalyzer() {
- return analyzer;
- }
-
- private static void setAccessible(XMember member) {
- if ( !Modifier.isPublic( member.getModifiers() ) ) {
- member.setAccessible( true );
- }
- }
-
- public IdFieldBridge getIdBridge() {
- return idBridge;
- }
-
- public String getIdKeywordName() {
- return idKeywordName;
- }
-
- public static Class getDocumentClass(Document document) {
- String className = document.get( DocumentBuilder.CLASS_FIELDNAME );
- try {
- return ReflectHelper.classForName( className );
- }
- catch (ClassNotFoundException e) {
- throw new HibernateException( "Unable to load indexed class: " +
className, e );
- }
- }
-
- public static Serializable getDocumentId(LuceneEventListener listener, Class clazz,
Document document) {
- DocumentBuilder builder = listener.getDocumentBuilders().get( clazz );
- if ( builder == null ) throw new HibernateException( "No Lucene
configuration set up for: " + clazz.getName() );
- return (Serializable) builder.getIdBridge().get( builder.getIdKeywordName(),
document );
- }
-
- public void postInitialize(Set<Class> indexedClasses) {
- //this method does not requires synchronization
- Class plainClass = reflectionManager.toClass( beanClass );
- Set<Class> tempMappedSubclasses = new HashSet<Class>();
- //together with the caller this creates a o(2), but I think it's still faster
than create the up hierarchy for each class
- for ( Class currentClass : indexedClasses ) {
- if ( plainClass.isAssignableFrom( currentClass ) ) tempMappedSubclasses.add(
currentClass );
- }
- mappedSubclasses = Collections.unmodifiableSet( tempMappedSubclasses );
- }
-
-
- public Set<Class> getMappedSubclasses() {
- return mappedSubclasses;
- }
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentId.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentId.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentId.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,22 +0,0 @@
-//$Id: $
-package org.hibernate.lucene;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Documented;
-
-/**
- * Declare a field as the document id. If set to a property, the property will be used
- * TODO: If set to a class, the class itself will be passed to the FieldBridge
- * Note that @{link org.hibernate.lucene.bridge.FieldBridge#get} must return the Entity
id
- *
- * @author Emmanuel Bernard
- */
-@Retention( RetentionPolicy.RUNTIME)
-(a)Target({ElementType.METHOD, ElementType.FIELD})
-@Documented
-public @interface DocumentId {
- String name() default "";
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Field.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Field.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Field.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,38 +0,0 @@
-//$Id: $
-/**
- * JavaDoc copy/pastle from the Apache Lucene project
- * Available under the ASL 2.0
http://www.apache.org/licenses/LICENSE-2.0
- */
-package org.hibernate.lucene;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Documented;
-
-/**
- * Mark a property as indexable
- *
- * @author Emmanuel Bernard
- */
-@Retention( RetentionPolicy.RUNTIME)
-(a)Target({ElementType.METHOD, ElementType.FIELD})
-@Documented
-public @interface Field {
- /**
- * Field name, default to the JavaBean property name
- */
- String name() default "";
-
- /**
- * Should the value be stored in the document
- */
- Store store() default Store.NO;
-
- /**
- * Defines how the Field should be indexed
- */
- Index index();
-
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/FieldBridge.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/FieldBridge.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/FieldBridge.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,22 +0,0 @@
-//$Id: $
-package org.hibernate.lucene;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Documented;
-
-import org.hibernate.annotations.Parameter;
-
-/**
- * specifies a given field bridge implementation
- * @author Emmanuel Bernard
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target({ElementType.FIELD, ElementType.METHOD})
-@Documented
-public @interface FieldBridge {
- public Class impl() default void.class;
- public Parameter[] params() default {};
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Index.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Index.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Index.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,29 +0,0 @@
-//$Id: $
-package org.hibernate.lucene;
-
-/**
- * Defines how an Field should be indexed
- */
-public enum Index {
- /** Do not index the field value. This field can thus not be searched,
- * but one can still access its contents provided it is
- * {@link Store stored}. */
- NO,
- /** Index the field's value so it can be searched. An Analyzer will be used
- * to tokenize and possibly further normalize the text before its
- * terms will be stored in the index. This is useful for common text.
- */
- TOKENIZED,
- /** Index the field's value without using an Analyzer, so it can be searched.
- * As no analyzer is used the value will be stored as a single term. This is
- * useful for unique Ids like product numbers.
- */
- UN_TOKENISED,
- /** Index the field's value without an Analyzer, and disable
- * the storing of norms. No norms means that index-time boosting
- * and field length normalization will be disabled. The benefit is
- * less memory usage as norms take up one byte per indexed field
- * for every document in the index.
- */
- NO_NORMS
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Indexed.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Indexed.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Indexed.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,21 +0,0 @@
-//$Id$
-package org.hibernate.lucene;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.TYPE)
-@Documented
-/**
- * Specifies that an entity is to be indexed by Lucene
- */
-public @interface Indexed {
- /**
- * The filename of the index
- */
- String index() default "";
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Keyword.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Keyword.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Keyword.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,28 +0,0 @@
-//$Id$
-package org.hibernate.lucene;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target({ElementType.METHOD, ElementType.FIELD})
-@Documented
-/**
- * Specifies that a property of an entity is a Lucene
- * keyword field
- * @deprecated use @Field(index=Index.UN_TOKENIZED, store=Store.YES) or @DocumentId when
id=true was used
- */
-@Deprecated
-public @interface Keyword {
- /**
- * The field name
- */
- String name() default "";
- /**
- * Specifies that this is the "identifier" keyword
- */
- boolean id() default false;
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Store.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Store.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Store.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,13 +0,0 @@
-//$Id: $
-package org.hibernate.lucene;
-
-/**
- * Whether or not the value is stored in the document
- *
- * @author Emmanuel Bernard
- */
-public enum Store {
- NO,
- YES,
- COMPRESS
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Text.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Text.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Text.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,24 +0,0 @@
-//$Id$
-package org.hibernate.lucene;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target({ElementType.METHOD, ElementType.FIELD})
-@Documented
-/**
- * Specifies that a property of an entity is a Lucene
- * text field
- * @deprecated use @Field(index=Index.TOKENIZED, store=Store.YES)
- */
-@Deprecated
-public @interface Text {
- /**
- * The field name
- */
- String name() default "";
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Unstored.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Unstored.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Unstored.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,24 +0,0 @@
-//$Id$
-package org.hibernate.lucene;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target({ElementType.METHOD, ElementType.FIELD})
-@Documented
-/**
- * Specifies that a property of an entity is a Lucene
- * unstored field
- * @deprecated use @Field(index=Index.TOKENIZED, store=Store.NO)
- */
-@Deprecated
-public @interface Unstored {
- /**
- * The field name
- */
- String name() default "";
-}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Boost.java
(from rev 10577,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java 2006-10-13
22:27:43 UTC (rev 10577)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Boost.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,20 @@
+//$Id: $
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Apply a boost factor on a field or a whole entity
+ *
+ * @author Emmanuel Bernard
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.TYPE, ElementType.METHOD, ElementType.FIELD} )
+@Documented
+public @interface Boost {
+ float value();
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/DateBridge.java
(from rev 10600,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DateBridge.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DateBridge.java 2006-10-17
23:58:05 UTC (rev 10600)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/DateBridge.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,24 @@
+//$Id: $
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.hibernate.lucene.bridge.Resolution;
+
+/**
+ * Defines the temporal resolution of a given field
+ * Date are stored as String in GMT
+ *
+ * @author Emmanuel Bernard
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.FIELD, ElementType.METHOD} )
+@Documented
+//TODO allow pattern like yyyyMMdd?
+public @interface DateBridge {
+ Resolution value();
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/DocumentId.java
(from rev 10611,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentId.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentId.java 2006-10-18
22:09:34 UTC (rev 10611)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/DocumentId.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,22 @@
+//$Id: $
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Declare a field as the document id. If set to a property, the property will be used
+ * TODO: If set to a class, the class itself will be passed to the FieldBridge
+ * Note that @{link org.hibernate.lucene.bridge.FieldBridge#get} must return the Entity
id
+ *
+ * @author Emmanuel Bernard
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.METHOD, ElementType.FIELD} )
+@Documented
+public @interface DocumentId {
+ String name() default "";
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Field.java
(from rev 10611,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Field.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Field.java 2006-10-18
22:09:34 UTC (rev 10611)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Field.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,38 @@
+//$Id: $
+/**
+ * JavaDoc copy/pastle from the Apache Lucene project
+ * Available under the ASL 2.0
http://www.apache.org/licenses/LICENSE-2.0
+ */
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Mark a property as indexable
+ *
+ * @author Emmanuel Bernard
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.METHOD, ElementType.FIELD} )
+@Documented
+public @interface Field {
+ /**
+ * Field name, default to the JavaBean property name
+ */
+ String name() default "";
+
+ /**
+ * Should the value be stored in the document
+ */
+ Store store() default Store.NO;
+
+ /**
+ * Defines how the Field should be indexed
+ */
+ Index index();
+
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/FieldBridge.java
(from rev 10565,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/FieldBridge.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/FieldBridge.java 2006-10-05
06:08:25 UTC (rev 10565)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/FieldBridge.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,24 @@
+//$Id: $
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.hibernate.annotations.Parameter;
+
+/**
+ * specifies a given field bridge implementation
+ *
+ * @author Emmanuel Bernard
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.FIELD, ElementType.METHOD} )
+@Documented
+public @interface FieldBridge {
+ public Class impl() default void.class;
+
+ public Parameter[] params() default {};
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Index.java
(from rev 10611,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Index.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Index.java 2006-10-18
22:09:34 UTC (rev 10611)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Index.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,34 @@
+//$Id: $
+package org.hibernate.lucene.annotations;
+
+/**
+ * Defines how an Field should be indexed
+ */
+public enum Index {
+ /**
+ * Do not index the field value. This field can thus not be searched,
+ * but one can still access its contents provided it is
+ * {@link Store stored}.
+ */
+ NO,
+ /**
+ * Index the field's value so it can be searched. An Analyzer will be used
+ * to tokenize and possibly further normalize the text before its
+ * terms will be stored in the index. This is useful for common text.
+ */
+ TOKENIZED,
+ /**
+ * Index the field's value without using an Analyzer, so it can be searched.
+ * As no analyzer is used the value will be stored as a single term. This is
+ * useful for unique Ids like product numbers.
+ */
+ UN_TOKENISED,
+ /**
+ * Index the field's value without an Analyzer, and disable
+ * the storing of norms. No norms means that index-time boosting
+ * and field length normalization will be disabled. The benefit is
+ * less memory usage as norms take up one byte per indexed field
+ * for every document in the index.
+ */
+ NO_NORMS
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Indexed.java
(from rev 10565,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Indexed.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Indexed.java 2006-10-05
06:08:25 UTC (rev 10565)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Indexed.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,21 @@
+//$Id$
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention( RetentionPolicy.RUNTIME )
+@Target( ElementType.TYPE )
+@Documented
+/**
+ * Specifies that an entity is to be indexed by Lucene
+ */
+public @interface Indexed {
+ /**
+ * The filename of the index
+ */
+ String index() default "";
+}
Property changes on:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Indexed.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Keyword.java
(from rev 10611,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Keyword.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Keyword.java 2006-10-18
22:09:34 UTC (rev 10611)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Keyword.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,29 @@
+//$Id$
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.METHOD, ElementType.FIELD} )
+@Documented
+/**
+ * Specifies that a property of an entity is a Lucene
+ * keyword field
+ * @deprecated use @Field(index=Index.UN_TOKENIZED, store=Store.YES) or @DocumentId when
id=true was used
+ */
+@Deprecated
+public @interface Keyword {
+ /**
+ * The field name
+ */
+ String name() default "";
+
+ /**
+ * Specifies that this is the "identifier" keyword
+ */
+ boolean id() default false;
+}
Property changes on:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Keyword.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Store.java
(from rev 10611,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Store.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Store.java 2006-10-18
22:09:34 UTC (rev 10611)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Store.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,13 @@
+//$Id: $
+package org.hibernate.lucene.annotations;
+
+/**
+ * Whether or not the value is stored in the document
+ *
+ * @author Emmanuel Bernard
+ */
+public enum Store {
+ NO,
+ YES,
+ COMPRESS
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Text.java
(from rev 10611,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Text.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Text.java 2006-10-18
22:09:34 UTC (rev 10611)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Text.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,24 @@
+//$Id$
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.METHOD, ElementType.FIELD} )
+@Documented
+/**
+ * Specifies that a property of an entity is a Lucene
+ * text field
+ * @deprecated use @Field(index=Index.TOKENIZED, store=Store.YES)
+ */
+@Deprecated
+public @interface Text {
+ /**
+ * The field name
+ */
+ String name() default "";
+}
Property changes on:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Text.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Unstored.java
(from rev 10611,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Unstored.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Unstored.java 2006-10-18
22:09:34 UTC (rev 10611)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Unstored.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,24 @@
+//$Id$
+package org.hibernate.lucene.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.METHOD, ElementType.FIELD} )
+@Documented
+/**
+ * Specifies that a property of an entity is a Lucene
+ * unstored field
+ * @deprecated use @Field(index=Index.TOKENIZED, store=Store.NO)
+ */
+@Deprecated
+public @interface Unstored {
+ /**
+ * The field name
+ */
+ String name() default "";
+}
Property changes on:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Unstored.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/AddWork.java
(from rev 10671,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/AddWork.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/AddWork.java 2006-11-01
04:27:26 UTC (rev 10671)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/AddWork.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,15 @@
+//$Id: $
+package org.hibernate.lucene.backend;
+
+import java.io.Serializable;
+
+import org.apache.lucene.document.Document;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class AddWork extends Work {
+ public AddWork(Serializable id, Class entity, Document document) {
+ super( id, entity, document );
+ }
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/DeleteWork.java
(from rev 10671,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/DeleteWork.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/DeleteWork.java 2006-11-01
04:27:26 UTC (rev 10671)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/DeleteWork.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,13 @@
+//$Id: $
+package org.hibernate.lucene.backend;
+
+import java.io.Serializable;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class DeleteWork extends Work {
+ public DeleteWork(Serializable id, Class entity) {
+ super( id, entity );
+ }
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/UpdateWork.java
(from rev 10671,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/UpdateWork.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/UpdateWork.java 2006-11-01
04:27:26 UTC (rev 10671)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/UpdateWork.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,15 @@
+//$Id: $
+package org.hibernate.lucene.backend;
+
+import java.io.Serializable;
+
+import org.apache.lucene.document.Document;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class UpdateWork extends Work {
+ public UpdateWork(Serializable id, Class entity, Document document) {
+ super( id, entity, document );
+ }
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/Work.java
(from rev 10671,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Work.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Work.java 2006-11-01
04:27:26 UTC (rev 10671)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/Work.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,40 @@
+//$Id: $
+package org.hibernate.lucene.backend;
+
+import java.io.Serializable;
+
+import org.apache.lucene.document.Document;
+
+/**
+ * Represent a Lucene unit work
+ *
+ * @author Emmanuel Bernard
+ */
+public abstract class Work implements Serializable {
+ private Document document;
+ private Class entity;
+ private Serializable id;
+
+ public Work(Serializable id, Class entity) {
+ this( id, entity, null );
+ }
+
+ public Work(Serializable id, Class entity, Document document) {
+ this.id = id;
+ this.entity = entity;
+ this.document = document;
+ }
+
+
+ public Document getDocument() {
+ return document;
+ }
+
+ public Class getEntity() {
+ return entity;
+ }
+
+ public Serializable getId() {
+ return id;
+ }
+}
Added:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/WorkQueue.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/WorkQueue.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/WorkQueue.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,24 @@
+//$Id: $
+package org.hibernate.lucene.backend;
+
+/**
+ * Set of work operations
+ *
+ * @author Emmanuel Bernard
+ */
+public interface WorkQueue {
+ /**
+ * Add a work
+ */
+ void add(Work work);
+
+ /**
+ * Execute works
+ */
+ void performWork();
+
+ /**
+ * Rollback works
+ */
+ void cancelWork();
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/Workspace.java
(from rev 10671,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Workspace.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Workspace.java 2006-11-01
04:27:26 UTC (rev 10671)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/Workspace.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,137 @@
+//$Id: $
+package org.hibernate.lucene.backend;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.hibernate.HibernateException;
+import org.hibernate.lucene.engine.DocumentBuilder;
+import org.hibernate.lucene.store.DirectoryProvider;
+
+/**
+ * Lucene workspace
+ * This is not intended to be used in a multithreaded environment
+ * <p/>
+ * One cannot execute modification through an IndexReader when an IndexWriter has been
acquired on the same underlying directory
+ * One cannot get an IndexWriter when an IndexReader have been acquired and modificed on
the same underlying directory
+ * The recommended approach is to execute all the modifications on the IndexReaders,
{@link #clean()} }, and acquire the
+ * index writers
+ *
+ * @author Emmanuel Bernard
+ */
+//TODO introduce the notion of read only IndexReader? We cannot enforce it because Lucene
use abstract classes, not interfaces
+public class Workspace {
+ private static Log log = LogFactory.getLog( Workspace.class );
+ private Map<Class, DocumentBuilder<Object>> documentBuilders;
+ private Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders;
+ private Map<DirectoryProvider, IndexReader> readers = new
HashMap<DirectoryProvider, IndexReader>();
+ private Map<DirectoryProvider, IndexWriter> writers = new
HashMap<DirectoryProvider, IndexWriter>();
+ private List<DirectoryProvider> lockedProviders = new
ArrayList<DirectoryProvider>();
+
+ public Workspace(Map<Class, DocumentBuilder<Object>> documentBuilders,
+ Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders) {
+ this.documentBuilders = documentBuilders;
+ this.lockableDirectoryProviders = lockableDirectoryProviders;
+ }
+
+
+ public DocumentBuilder getDocumentBuilder(Class entity) {
+ return documentBuilders.get( entity );
+ }
+
+ public IndexReader getIndexReader(Class entity) {
+ //TODO NPEs
+ DirectoryProvider provider = documentBuilders.get( entity ).getDirectoryProvider();
+ IndexReader reader = readers.get( provider );
+ if ( reader != null ) return reader;
+ lockProvider( provider );
+ try {
+ reader = IndexReader.open( provider.getDirectory() );
+ readers.put( provider, reader );
+ }
+ catch (IOException e) {
+ cleanUp( new HibernateException( "Unable to open IndexReader for " + entity,
e ) );
+ }
+ return reader;
+ }
+
+ public IndexWriter getIndexWriter(Class entity) {
+ DirectoryProvider provider = documentBuilders.get( entity ).getDirectoryProvider();
+ IndexWriter writer = writers.get( provider );
+ if ( writer != null ) return writer;
+ lockProvider( provider );
+ try {
+ writer = new IndexWriter(
+ provider.getDirectory(), documentBuilders.get( entity ).getAnalyzer(), false
+ ); //have been created at init time
+ writers.put( provider, writer );
+ }
+ catch (IOException e) {
+ cleanUp( new HibernateException( "Unable to open IndexWriter for " + entity,
e ) );
+ }
+ return writer;
+ }
+
+ private void lockProvider(DirectoryProvider provider) {
+ //make sure to use a semaphore
+ ReentrantLock lock = lockableDirectoryProviders.get( provider );
+ //of course a given thread cannot have a race cond with itself
+ if ( !lock.isHeldByCurrentThread() ) {
+ lock.lock();
+ lockedProviders.add( provider );
+ }
+ }
+
+ private void cleanUp(HibernateException originalException) {
+ //release all readers and writers, then reelase locks
+ HibernateException raisedException = originalException;
+ for ( IndexReader reader : readers.values() ) {
+ try {
+ reader.close();
+ }
+ catch (IOException e) {
+ if ( raisedException != null ) {
+ log.error( "Subsequent Exception while closing IndexReader", e );
+ }
+ else {
+ raisedException = new HibernateException( "Exception while closing
IndexReader", e );
+ }
+ }
+ }
+ for ( IndexWriter writer : writers.values() ) {
+ try {
+ writer.close();
+ }
+ catch (IOException e) {
+ if ( raisedException != null ) {
+ log.error( "Subsequent Exception while closing IndexWriter", e );
+ }
+ else {
+ raisedException = new HibernateException( "Exception while closing
IndexWriter", e );
+ }
+ }
+ }
+ for ( DirectoryProvider provider : lockedProviders ) {
+ lockableDirectoryProviders.get( provider ).unlock();
+ }
+ readers.clear();
+ writers.clear();
+ lockedProviders.clear();
+ if ( raisedException != null ) throw raisedException;
+ }
+
+ /**
+ * release resources consumed in the workspace if any
+ */
+ public void clean() {
+ cleanUp( null );
+ }
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/BatchLuceneWorkQueue.java
(from rev 10671,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkQueue.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkQueue.java 2006-11-01
04:27:26 UTC (rev 10671)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/BatchLuceneWorkQueue.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,65 @@
+//$Id: $
+package org.hibernate.lucene.backend.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.hibernate.lucene.engine.DocumentBuilder;
+import org.hibernate.lucene.store.DirectoryProvider;
+import org.hibernate.lucene.backend.impl.LuceneWorker;
+import org.hibernate.lucene.backend.WorkQueue;
+import org.hibernate.lucene.backend.Workspace;
+import org.hibernate.lucene.backend.Work;
+import org.hibernate.lucene.backend.UpdateWork;
+import org.hibernate.lucene.backend.DeleteWork;
+import org.hibernate.lucene.backend.AddWork;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class BatchLuceneWorkQueue implements WorkQueue {
+ private Workspace workspace;
+ private LuceneWorker worker;
+ private List<Work> queue = new ArrayList<Work>();
+
+ public BatchLuceneWorkQueue(Map<Class, DocumentBuilder<Object>>
documentBuilders,
+ Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders) {
+ workspace = new Workspace( documentBuilders, lockableDirectoryProviders );
+ worker = new LuceneWorker( workspace );
+ }
+
+ public void add(Work work) {
+ //TODO optimize by getting rid of dupe works
+ if ( work instanceof UpdateWork ) {
+ //split in 2 to optimize the process (reader first, writer next
+ queue.add( new DeleteWork( work.getId(), work.getEntity() ) );
+ queue.add( new AddWork( work.getId(), work.getEntity(), work.getDocument() ) );
+ }
+ else {
+ queue.add( work );
+ }
+ }
+
+ public void performWork() {
+ try {
+ //use of index reader
+ for ( Work work : queue ) {
+ if ( work instanceof DeleteWork ) worker.performWork( work );
+ }
+ workspace.clean(); //close readers
+ for ( Work work : queue ) {
+ if ( work instanceof AddWork ) worker.performWork( work );
+ }
+ }
+ finally {
+ workspace.clean();
+ queue.clear();
+ }
+ }
+
+ public void cancelWork() {
+ queue.clear();
+ }
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/LuceneWorker.java
(from rev 10674,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java 2006-11-01
06:55:20 UTC (rev 10674)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/LuceneWorker.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,116 @@
+//$Id: $
+package org.hibernate.lucene.backend.impl;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermDocs;
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.lucene.engine.DocumentBuilder;
+import org.hibernate.lucene.backend.Workspace;
+import org.hibernate.lucene.backend.DeleteWork;
+import org.hibernate.lucene.backend.AddWork;
+import org.hibernate.lucene.backend.UpdateWork;
+import org.hibernate.lucene.backend.Work;
+
+/**
+ * Stateless implementation that perform a work
+ *
+ * @author Emmanuel Bernard
+ */
+public class LuceneWorker {
+ private Workspace workspace;
+ private static Log log = LogFactory.getLog( LuceneWorker.class );
+
+ public LuceneWorker(Workspace workspace) {
+ this.workspace = workspace;
+ }
+
+ public void performWork(Work work) {
+ if ( AddWork.class.isAssignableFrom( work.getClass() ) ) {
+ performWork( (AddWork) work );
+ }
+ else if ( UpdateWork.class.isAssignableFrom( work.getClass() ) ) {
+ performWork( (UpdateWork) work );
+ }
+ else if ( DeleteWork.class.isAssignableFrom( work.getClass() ) ) {
+ performWork( (DeleteWork) work );
+ }
+ else {
+ throw new AssertionFailure( "Unknown work type: " + work.getClass() );
+ }
+ }
+
+ public void performWork(AddWork work) {
+ Class entity = work.getEntity();
+ Serializable id = work.getId();
+ Document document = work.getDocument();
+ add( entity, id, document );
+ }
+
+ private void add(Class entity, Serializable id, Document document) {
+ if ( log.isTraceEnabled() )
+ log.trace( "add to Lucene index: " + entity + "#" + id + ":
" + document );
+ IndexWriter writer = workspace.getIndexWriter( entity );
+ try {
+ writer.addDocument( document );
+ }
+ catch (IOException e) {
+ throw new HibernateException( "Unable to add to Lucene index: " + entity +
"#" + id, e );
+ }
+ }
+
+ public void performWork(UpdateWork work) {
+ Class entity = work.getEntity();
+ Serializable id = work.getId();
+ Document document = work.getDocument();
+ remove( entity, id );
+ add( entity, id, document );
+ }
+
+ public void performWork(DeleteWork work) {
+ Class entity = work.getEntity();
+ Serializable id = work.getId();
+ remove( entity, id );
+ }
+
+ private void remove(Class entity, Serializable id) {
+ log.trace( "remove from Lucene index: " + entity + "#" + id );
+ DocumentBuilder builder = workspace.getDocumentBuilder( entity );
+ Term term = builder.getTerm( id );
+ IndexReader reader = workspace.getIndexReader( entity );
+ TermDocs termDocs = null;
+ try {
+ //TODO is there a faster way?
+ //TODO include TermDocs into the workspace?
+ termDocs = reader.termDocs( term );
+ String entityName = entity.getName();
+ while ( termDocs.next() ) {
+ int docIndex = termDocs.doc();
+ if ( entityName.equals( reader.document( docIndex ).get(
DocumentBuilder.CLASS_FIELDNAME ) ) ) {
+ //remove only the one of the right class
+ //loop all to remove all the matches (defensive code)
+ reader.deleteDocument( docIndex );
+ }
+ }
+ }
+ catch (Exception e) {
+ throw new HibernateException( "Unable to remove from Lucene index: " +
entity + "#" + id, e );
+ }
+ finally {
+ if (termDocs != null) try {
+ termDocs.close();
+ }
+ catch (IOException e) {
+ log.warn( "Unable to close termDocs properly", e);
+ }
+ }
+ }
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/PostTransactionWorkQueueSynchronization.java
(from rev 10671,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkInSynchronization.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkInSynchronization.java 2006-11-01
04:27:26 UTC (rev 10671)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/PostTransactionWorkQueueSynchronization.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,36 @@
+//$Id: $
+package org.hibernate.lucene.backend.impl;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+
+import org.hibernate.lucene.backend.WorkQueue;
+
+/**
+ * Execute some work inside a transaction sychronization
+ *
+ * @author Emmanuel Bernard
+ */
+public class PostTransactionWorkQueueSynchronization implements Synchronization {
+ private WorkQueue workQueue;
+
+ public PostTransactionWorkQueueSynchronization(WorkQueue workQueue) {
+ this.workQueue = workQueue;
+ }
+
+ public void beforeCompletion() {
+ }
+
+ public void afterCompletion(int i) {
+ if ( Status.STATUS_COMMITTED == i ) {
+ workQueue.performWork();
+ }
+ else {
+ workQueue.cancelWork();
+ }
+ }
+
+ public static interface Work {
+ void perform();
+ }
+}
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -9,7 +9,6 @@
import org.hibernate.HibernateException;
import org.hibernate.annotations.Parameter;
-import org.hibernate.lucene.DateBridge;
import org.hibernate.reflection.XClass;
import org.hibernate.reflection.XMember;
@@ -69,7 +68,8 @@
public static FieldBridge guessType(XMember member) {
FieldBridge bridge = null;
- org.hibernate.lucene.FieldBridge bridgeAnn = member.getAnnotation(
org.hibernate.lucene.FieldBridge.class );
+ org.hibernate.lucene.annotations.FieldBridge bridgeAnn =
+ member.getAnnotation( org.hibernate.lucene.annotations.FieldBridge.class );
if ( bridgeAnn != null ) {
Class impl = bridgeAnn.impl();
try {
@@ -93,8 +93,8 @@
throw new HibernateException( "Unable to instanciate FieldBridge for " +
member.getName(), e );
}
}
- else if ( member.isAnnotationPresent( DateBridge.class ) ) {
- Resolution resolution = member.getAnnotation( DateBridge.class ).value();
+ else if ( member.isAnnotationPresent( org.hibernate.lucene.annotations.DateBridge.class
) ) {
+ Resolution resolution = member.getAnnotation(
org.hibernate.lucene.annotations.DateBridge.class ).value();
bridge = org.hibernate.lucene.bridge.DateBridge.getDateField( resolution );
}
else {
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/engine/DocumentBuilder.java
(from rev 10678,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java 2006-11-01
21:32:11 UTC (rev 10678)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/engine/DocumentBuilder.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -0,0 +1,329 @@
+//$Id$
+package org.hibernate.lucene.engine;
+
+import java.io.Serializable;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.index.Term;
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.annotations.Version;
+import org.hibernate.lucene.annotations.Boost;
+import org.hibernate.lucene.annotations.DocumentId;
+import org.hibernate.lucene.annotations.Index;
+import org.hibernate.lucene.annotations.Keyword;
+import org.hibernate.lucene.annotations.Store;
+import org.hibernate.lucene.annotations.Text;
+import org.hibernate.lucene.annotations.Unstored;
+import org.hibernate.lucene.bridge.BridgeFactory;
+import org.hibernate.lucene.bridge.FieldBridge;
+import org.hibernate.lucene.bridge.IdFieldBridge;
+import org.hibernate.lucene.event.LuceneEventListener;
+import org.hibernate.lucene.store.DirectoryProvider;
+import org.hibernate.lucene.util.BinderHelper;
+import org.hibernate.reflection.ReflectionManager;
+import org.hibernate.reflection.XAnnotatedElement;
+import org.hibernate.reflection.XClass;
+import org.hibernate.reflection.XMember;
+import org.hibernate.reflection.XProperty;
+import org.hibernate.util.ReflectHelper;
+
+/**
+ * Set up and provide a manager for indexes classes
+ *
+ * @author Gavin King
+ * @author Emmanuel Bernard
+ * @author Sylvain Vieujot
+ * @author Richard Hallier
+ */
+public class DocumentBuilder<T> {
+
+ static {
+ Version.touch(); //touch version
+ }
+
+ private final List<XMember> keywordGetters = new ArrayList<XMember>();
+ private final List<String> keywordNames = new ArrayList<String>();
+ private final List<FieldBridge> keywordBridges = new
ArrayList<FieldBridge>();
+ private final List<XMember> unstoredGetters = new ArrayList<XMember>();
+ private final List<String> unstoredNames = new ArrayList<String>();
+ private final List<FieldBridge> unstoredBridges = new
ArrayList<FieldBridge>();
+ private final List<XMember> textGetters = new ArrayList<XMember>();
+ private final List<String> textNames = new ArrayList<String>();
+ private final List<FieldBridge> textBridges = new ArrayList<FieldBridge>();
+ private final List<String> fieldNames = new ArrayList<String>();
+ private final List<XMember> fieldGetters = new ArrayList<XMember>();
+ private final List<FieldBridge> fieldBridges = new
ArrayList<FieldBridge>();
+ private final List<Field.Store> fieldStore = new ArrayList<Field.Store>();
+ private final List<Field.Index> fieldIndex = new ArrayList<Field.Index>();
+
+ private final XClass beanClass;
+ private final DirectoryProvider directoryProvider;
+ private String idKeywordName;
+ private final Analyzer analyzer;
+ private Float idBoost;
+ public static final String CLASS_FIELDNAME = "_hibernate_class";
+ private IdFieldBridge idBridge;
+ private Set<Class> mappedSubclasses = new HashSet<Class>();
+ private ReflectionManager reflectionManager;
+
+
+ public DocumentBuilder(XClass clazz, Analyzer analyzer, DirectoryProvider directory,
+ ReflectionManager reflectionManager) {
+ this.beanClass = clazz;
+ this.analyzer = analyzer;
+ this.directoryProvider = directory;
+ //FIXME get rid of it when boost is stored?
+ this.reflectionManager = reflectionManager;
+
+ if ( clazz == null ) throw new AssertionFailure( "Unable to build a
DocumentBuilder with a null class" );
+
+ for ( XClass currClass = beanClass; currClass != null; currClass =
currClass.getSuperclass() ) {
+ //rejecting non properties because the object is loaded from Hibernate, so indexing a
non property does not make sense
+ List<XProperty> methods = currClass.getDeclaredProperties(
XClass.ACCESS_PROPERTY );
+ for ( XProperty method : methods ) {
+ initializeMember( method );
+ }
+
+ List<XProperty> fields = currClass.getDeclaredProperties( XClass.ACCESS_FIELD
);
+ for ( XProperty field : fields ) {
+ initializeMember( field );
+ }
+ }
+
+ if ( idKeywordName == null ) {
+ throw new HibernateException( "No document id for: " + clazz.getName() );
+ }
+ }
+
+ private void initializeMember(XProperty member) {
+ Keyword keywordAnn = member.getAnnotation( Keyword.class );
+ if ( keywordAnn != null ) {
+ String name = BinderHelper.getAttributeName( member, keywordAnn.name() );
+ if ( keywordAnn.id() ) {
+ idKeywordName = name;
+ idBoost = getBoost( member );
+ FieldBridge fieldBridge = BridgeFactory.guessType( member );
+ if ( fieldBridge instanceof IdFieldBridge ) {
+ idBridge = (IdFieldBridge) fieldBridge;
+ }
+ else {
+ throw new HibernateException(
+ "Bridge for document id does not implement IdFieldBridge: " +
member.getName() );
+ }
+ }
+ else {
+ setAccessible( member );
+ keywordGetters.add( member );
+ keywordNames.add( name );
+ keywordBridges.add( BridgeFactory.guessType( member ) );
+ }
+ }
+
+ Unstored unstoredAnn = member.getAnnotation( Unstored.class );
+ if ( unstoredAnn != null ) {
+ setAccessible( member );
+ unstoredGetters.add( member );
+ unstoredNames.add( BinderHelper.getAttributeName( member, unstoredAnn.name() ) );
+ unstoredBridges.add( BridgeFactory.guessType( member ) );
+ }
+
+ Text textAnn = member.getAnnotation( Text.class );
+ if ( textAnn != null ) {
+ setAccessible( member );
+ textGetters.add( member );
+ textNames.add( BinderHelper.getAttributeName( member, textAnn.name() ) );
+ textBridges.add( BridgeFactory.guessType( member ) );
+ }
+
+ DocumentId documentIdAnn = member.getAnnotation( DocumentId.class );
+ if ( documentIdAnn != null ) {
+ if ( idKeywordName != null ) {
+ throw new AssertionFailure( "Two document id assigned: "
+ + idKeywordName + " and " + BinderHelper.getAttributeName( member,
documentIdAnn.name() ) );
+ }
+ idKeywordName = BinderHelper.getAttributeName( member, documentIdAnn.name() );
+ FieldBridge fieldBridge = BridgeFactory.guessType( member );
+ if ( fieldBridge instanceof IdFieldBridge ) {
+ idBridge = (IdFieldBridge) fieldBridge;
+ }
+ else {
+ throw new HibernateException(
+ "Bridge for document id does not implement IdFieldBridge: " +
member.getName() );
+ }
+ idBoost = getBoost( member );
+ }
+
+ org.hibernate.lucene.annotations.Field fieldAnn =
+ member.getAnnotation( org.hibernate.lucene.annotations.Field.class );
+ if ( fieldAnn != null ) {
+ setAccessible( member );
+ fieldGetters.add( member );
+ fieldNames.add( BinderHelper.getAttributeName( member, fieldAnn.name() ) );
+ fieldStore.add( getStore( fieldAnn.store() ) );
+ fieldIndex.add( getIndex( fieldAnn.index() ) );
+ fieldBridges.add( BridgeFactory.guessType( member ) );
+ }
+ }
+
+ private Field.Store getStore(Store store) {
+ switch (store) {
+ case NO:
+ return Field.Store.NO;
+ case YES:
+ return Field.Store.YES;
+ case COMPRESS:
+ return Field.Store.COMPRESS;
+ default:
+ throw new AssertionFailure( "Unexpected Store: " + store );
+ }
+ }
+
+ private Field.Index getIndex(Index index) {
+ switch (index) {
+ case NO:
+ return Field.Index.NO;
+ case NO_NORMS:
+ return Field.Index.NO_NORMS;
+ case TOKENIZED:
+ return Field.Index.TOKENIZED;
+ case UN_TOKENISED:
+ return Field.Index.UN_TOKENIZED;
+ default:
+ throw new AssertionFailure( "Unexpected Index: " + index );
+ }
+ }
+
+ private Float getBoost(XAnnotatedElement element) {
+ if ( element == null ) return null;
+ Boost boost = element.getAnnotation( Boost.class );
+ return boost != null ?
+ boost.value() :
+ null;
+ }
+
+ private Object getMemberValue(T bean, XMember getter) {
+ Object value;
+ try {
+ value = getter.invoke( bean );
+ }
+ catch (Exception e) {
+ throw new IllegalStateException( "Could not get property value", e );
+ }
+ return value;
+ }
+
+ public Document getDocument(T instance, Serializable id) {
+ Document doc = new Document();
+ XClass instanceClass = reflectionManager.toXClass( instance.getClass() );
+ Float boost = getBoost( instanceClass );
+ if ( boost != null ) {
+ doc.setBoost( boost );
+ }
+ {
+ Field classField =
+ new Field( CLASS_FIELDNAME, instanceClass.getName(), Field.Store.YES,
Field.Index.UN_TOKENIZED );
+ doc.add( classField );
+ idBridge.set( idKeywordName, id, doc, Field.Store.YES, Field.Index.UN_TOKENIZED,
idBoost );
+ }
+ for ( int i = 0; i < keywordNames.size(); i++ ) {
+ XMember member = keywordGetters.get( i );
+ Object value = getMemberValue( instance, member );
+ keywordBridges.get( i ).set(
+ keywordNames.get( i ), value, doc, Field.Store.YES,
+ Field.Index.UN_TOKENIZED, getBoost( member )
+ );
+ }
+ for ( int i = 0; i < textNames.size(); i++ ) {
+ XMember member = textGetters.get( i );
+ Object value = getMemberValue( instance, member );
+ textBridges.get( i ).set(
+ textNames.get( i ), value, doc, Field.Store.YES,
+ Field.Index.TOKENIZED, getBoost( member )
+ );
+ }
+ for ( int i = 0; i < unstoredNames.size(); i++ ) {
+ XMember member = unstoredGetters.get( i );
+ Object value = getMemberValue( instance, member );
+ unstoredBridges.get( i ).set(
+ unstoredNames.get( i ), value, doc, Field.Store.NO,
+ Field.Index.TOKENIZED, getBoost( member )
+ );
+ }
+ for ( int i = 0; i < fieldNames.size(); i++ ) {
+ XMember member = fieldGetters.get( i );
+ Object value = getMemberValue( instance, member );
+ fieldBridges.get( i ).set(
+ fieldNames.get( i ), value, doc, fieldStore.get( i ),
+ fieldIndex.get( i ), getBoost( member )
+ );
+ }
+ return doc;
+ }
+
+ public Term getTerm(Serializable id) {
+ return new Term( idKeywordName, idBridge.objectToString( id ) );
+ }
+
+ public DirectoryProvider getDirectoryProvider() {
+ return directoryProvider;
+ }
+
+ public Analyzer getAnalyzer() {
+ return analyzer;
+ }
+
+ private static void setAccessible(XMember member) {
+ if ( !Modifier.isPublic( member.getModifiers() ) ) {
+ member.setAccessible( true );
+ }
+ }
+
+ public IdFieldBridge getIdBridge() {
+ return idBridge;
+ }
+
+ public String getIdKeywordName() {
+ return idKeywordName;
+ }
+
+ public static Class getDocumentClass(Document document) {
+ String className = document.get( DocumentBuilder.CLASS_FIELDNAME );
+ try {
+ return ReflectHelper.classForName( className );
+ }
+ catch (ClassNotFoundException e) {
+ throw new HibernateException( "Unable to load indexed class: " + className,
e );
+ }
+ }
+
+ public static Serializable getDocumentId(LuceneEventListener listener, Class clazz,
Document document) {
+ DocumentBuilder builder = listener.getDocumentBuilders().get( clazz );
+ if ( builder == null ) throw new HibernateException( "No Lucene configuration set
up for: " + clazz.getName() );
+ return (Serializable) builder.getIdBridge().get( builder.getIdKeywordName(), document
);
+ }
+
+ public void postInitialize(Set<Class> indexedClasses) {
+ //this method does not requires synchronization
+ Class plainClass = reflectionManager.toClass( beanClass );
+ Set<Class> tempMappedSubclasses = new HashSet<Class>();
+ //together with the caller this creates a o(2), but I think it's still faster than
create the up hierarchy for each class
+ for ( Class currentClass : indexedClasses ) {
+ if ( plainClass.isAssignableFrom( currentClass ) ) tempMappedSubclasses.add(
currentClass );
+ }
+ mappedSubclasses = Collections.unmodifiableSet( tempMappedSubclasses );
+ }
+
+
+ public Set<Class> getMappedSubclasses() {
+ return mappedSubclasses;
+ }
+}
Property changes on:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/engine/DocumentBuilder.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/AddWork.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/AddWork.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/AddWork.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,15 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import java.io.Serializable;
-
-import org.apache.lucene.document.Document;
-
-/**
- * @author Emmanuel Bernard
- */
-public class AddWork extends Work {
- public AddWork(Serializable id, Class entity, Document document) {
- super( id, entity, document );
- }
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/DeleteWork.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/DeleteWork.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/DeleteWork.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,13 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import java.io.Serializable;
-
-/**
- * @author Emmanuel Bernard
- */
-public class DeleteWork extends Work {
- public DeleteWork(Serializable id, Class entity) {
- super( id, entity );
- }
-}
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,13 +1,11 @@
//$Id$
package org.hibernate.lucene.event;
-import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.transaction.Status;
@@ -16,9 +14,6 @@
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.Term;
import org.hibernate.HibernateException;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
@@ -30,9 +25,16 @@
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.event.PostUpdateEvent;
import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.lucene.DocumentBuilder;
import org.hibernate.lucene.Environment;
-import org.hibernate.lucene.Indexed;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.backend.AddWork;
+import org.hibernate.lucene.backend.DeleteWork;
+import org.hibernate.lucene.backend.UpdateWork;
+import org.hibernate.lucene.backend.Work;
+import org.hibernate.lucene.backend.WorkQueue;
+import org.hibernate.lucene.backend.impl.BatchLuceneWorkQueue;
+import org.hibernate.lucene.backend.impl.PostTransactionWorkQueueSynchronization;
+import org.hibernate.lucene.engine.DocumentBuilder;
import org.hibernate.lucene.store.DirectoryProvider;
import org.hibernate.lucene.store.DirectoryProviderFactory;
import org.hibernate.mapping.PersistentClass;
@@ -161,9 +163,9 @@
}
private void processWork(Work work, AbstractEvent event) {
- WorkQueue workQueue = new WorkQueue( documentBuilders, lockableDirectoryProviders );
+ WorkQueue workQueue = new BatchLuceneWorkQueue( documentBuilders,
lockableDirectoryProviders );
workQueue.add( work );
- WorkInSynchronization sync = new WorkInSynchronization( workQueue );
+ PostTransactionWorkQueueSynchronization sync = new
PostTransactionWorkQueueSynchronization( workQueue );
if ( event.getSession().isTransactionInProgress() ) {
event.getSession().getTransaction().registerSynchronization( sync );
}
@@ -171,51 +173,4 @@
sync.afterCompletion( Status.STATUS_COMMITTED );
}
}
-
- @Deprecated
- private void remove(DocumentBuilder<?> builder, Serializable id) {
- //FIXME lookup by term id and filter by test _hibernate_class
- Term term = builder.getTerm( id );
- log.debug( "removing: " + term );
- DirectoryProvider directoryProvider = builder.getDirectoryProvider();
- Lock lock = lockableDirectoryProviders.get( directoryProvider );
- lock.lock();
- try {
-
- IndexReader reader = IndexReader.open( directoryProvider.getDirectory() );
- reader.deleteDocuments( term );
- reader.close();
- }
- catch (IOException ioe) {
- throw new HibernateException( ioe );
- }
- finally {
- lock.unlock();
- }
- }
-
- @Deprecated
- private void add(final Object entity, final DocumentBuilder<Object> builder, final
Serializable id) {
- Document doc = builder.getDocument( entity, id );
- if ( log.isDebugEnabled() ) {
- log.debug( "adding: " + doc );
- }
- DirectoryProvider directoryProvider = builder.getDirectoryProvider();
- Lock lock = lockableDirectoryProviders.get( directoryProvider );
- lock.lock();
- try {
- IndexWriter writer = new IndexWriter(
- directoryProvider.getDirectory(), builder.getAnalyzer(), false
- ); //have been created at init time
- writer.addDocument( doc );
- writer.close();
- }
- catch (IOException ioe) {
- throw new HibernateException( ioe );
- }
- finally {
- lock.unlock();
- }
- }
-
}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/UpdateWork.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/UpdateWork.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/UpdateWork.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,15 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import java.io.Serializable;
-
-import org.apache.lucene.document.Document;
-
-/**
- * @author Emmanuel Bernard
- */
-public class UpdateWork extends Work {
- public UpdateWork(Serializable id, Class entity, Document document) {
- super( id, entity, document );
- }
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Work.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Work.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Work.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,40 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import java.io.Serializable;
-
-import org.apache.lucene.document.Document;
-
-/**
- * Represent a Lucene unit work
- *
- * @author Emmanuel Bernard
- */
-public abstract class Work implements Serializable {
- private Document document;
- private Class entity;
- private Serializable id;
-
- public Work(Serializable id, Class entity) {
- this( id, entity, null );
- }
-
- public Work(Serializable id, Class entity, Document document) {
- this.id = id;
- this.entity = entity;
- this.document = document;
- }
-
-
- public Document getDocument() {
- return document;
- }
-
- public Class getEntity() {
- return entity;
- }
-
- public Serializable getId() {
- return id;
- }
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkInSynchronization.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkInSynchronization.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkInSynchronization.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,34 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-
-/**
- * Execute some work inside a transaction sychronization
- *
- * @author Emmanuel Bernard
- */
-public class WorkInSynchronization implements Synchronization {
- private WorkQueue workQueue;
-
- public WorkInSynchronization(WorkQueue workQueue) {
- this.workQueue = workQueue;
- }
-
- public void beforeCompletion() {
- }
-
- public void afterCompletion(int i) {
- if ( Status.STATUS_COMMITTED == i ) {
- workQueue.performWork();
- }
- else {
- workQueue.cancelWork();
- }
- }
-
- public static interface Work {
- void perform();
- }
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkQueue.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkQueue.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/WorkQueue.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,58 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.hibernate.lucene.DocumentBuilder;
-import org.hibernate.lucene.store.DirectoryProvider;
-
-/**
- * @author Emmanuel Bernard
- */
-public class WorkQueue {
- private Workspace workspace;
- private Worker worker;
- private List<Work> queue = new ArrayList<Work>();
-
- public WorkQueue(Map<Class, DocumentBuilder<Object>> documentBuilders,
- Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders) {
- workspace = new Workspace( documentBuilders, lockableDirectoryProviders );
- worker = new Worker( workspace );
- }
-
- public void add(Work work) {
- //TODO optimize by getting rid of dupe works
- if ( work instanceof UpdateWork ) {
- //split in 2 to optimize the process (reader first, writer next
- queue.add( new DeleteWork( work.getId(), work.getEntity() ) );
- queue.add( new AddWork( work.getId(), work.getEntity(), work.getDocument() ) );
- }
- else {
- queue.add( work );
- }
- }
-
- public void performWork() {
- try {
- //use of index reader
- for ( Work work : queue ) {
- if ( work instanceof DeleteWork ) worker.performWork( work );
- }
- workspace.clean(); //close readers
- for ( Work work : queue ) {
- if ( work instanceof AddWork ) worker.performWork( work );
- }
- }
- finally {
- workspace.clean();
- queue.clear();
- }
- }
-
- public void cancelWork() {
- queue.clear();
- }
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Worker.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,111 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import java.io.IOException;
-import java.io.Serializable;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermDocs;
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.lucene.DocumentBuilder;
-
-/**
- * Stateless implementation that perform a work
- *
- * @author Emmanuel Bernard
- */
-public class Worker {
- private Workspace workspace;
- private static Log log = LogFactory.getLog( Worker.class );
-
- public Worker(Workspace workspace) {
- this.workspace = workspace;
- }
-
- public void performWork(Work work) {
- if ( AddWork.class.isAssignableFrom( work.getClass() ) ) {
- performWork( (AddWork) work );
- }
- else if ( UpdateWork.class.isAssignableFrom( work.getClass() ) ) {
- performWork( (UpdateWork) work );
- }
- else if ( DeleteWork.class.isAssignableFrom( work.getClass() ) ) {
- performWork( (DeleteWork) work );
- }
- else {
- throw new AssertionFailure( "Unknown work type: " + work.getClass() );
- }
- }
-
- public void performWork(AddWork work) {
- Class entity = work.getEntity();
- Serializable id = work.getId();
- Document document = work.getDocument();
- add( entity, id, document );
- }
-
- private void add(Class entity, Serializable id, Document document) {
- if ( log.isTraceEnabled() )
- log.trace( "add to Lucene index: " + entity + "#" + id + ":
" + document );
- IndexWriter writer = workspace.getIndexWriter( entity );
- try {
- writer.addDocument( document );
- }
- catch (IOException e) {
- throw new HibernateException( "Unable to add to Lucene index: " + entity +
"#" + id, e );
- }
- }
-
- public void performWork(UpdateWork work) {
- Class entity = work.getEntity();
- Serializable id = work.getId();
- Document document = work.getDocument();
- remove( entity, id );
- add( entity, id, document );
- }
-
- public void performWork(DeleteWork work) {
- Class entity = work.getEntity();
- Serializable id = work.getId();
- remove( entity, id );
- }
-
- private void remove(Class entity, Serializable id) {
- log.trace( "remove from Lucene index: " + entity + "#" + id );
- DocumentBuilder builder = workspace.getDocumentBuilder( entity );
- Term term = builder.getTerm( id );
- IndexReader reader = workspace.getIndexReader( entity );
- TermDocs termDocs = null;
- try {
- //TODO is there a faster way?
- //TODO include TermDocs into the workspace?
- termDocs = reader.termDocs( term );
- String entityName = entity.getName();
- while ( termDocs.next() ) {
- int docIndex = termDocs.doc();
- if ( entityName.equals( reader.document( docIndex ).get(
DocumentBuilder.CLASS_FIELDNAME ) ) ) {
- //remove only the one of the right class
- //loop all to remove all the matches (defensive code)
- reader.deleteDocument( docIndex );
- }
- }
- }
- catch (Exception e) {
- throw new HibernateException( "Unable to remove from Lucene index: " +
entity + "#" + id, e );
- }
- finally {
- if (termDocs != null) try {
- termDocs.close();
- }
- catch (IOException e) {
- log.warn( "Unable to close termDocs properly", e);
- }
- }
- }
-}
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Workspace.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Workspace.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/Workspace.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,137 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.event;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriter;
-import org.hibernate.HibernateException;
-import org.hibernate.lucene.DocumentBuilder;
-import org.hibernate.lucene.store.DirectoryProvider;
-
-/**
- * Lucene workspace
- * This is not intended to be used in a multithreaded environment
- * <p/>
- * One cannot execute modification through an IndexReader when an IndexWriter has been
acquired on the same underlying directory
- * One cannot get an IndexWriter when an IndexReader have been acquired and modificed on
the same underlying directory
- * The recommended approach is to execute all the modifications on the IndexReaders,
{@link #clean()} }, and acquire the
- * index writers
- *
- * @author Emmanuel Bernard
- */
-//TODO introduce the notion of read only IndexReader? We cannot enforce it because Lucene
use abstract classes, not interfaces
-public class Workspace {
- private static Log log = LogFactory.getLog( Workspace.class );
- private Map<Class, DocumentBuilder<Object>> documentBuilders;
- private Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders;
- private Map<DirectoryProvider, IndexReader> readers = new
HashMap<DirectoryProvider, IndexReader>();
- private Map<DirectoryProvider, IndexWriter> writers = new
HashMap<DirectoryProvider, IndexWriter>();
- private List<DirectoryProvider> lockedProviders = new
ArrayList<DirectoryProvider>();
-
- public Workspace(Map<Class, DocumentBuilder<Object>> documentBuilders,
- Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders) {
- this.documentBuilders = documentBuilders;
- this.lockableDirectoryProviders = lockableDirectoryProviders;
- }
-
-
- public DocumentBuilder getDocumentBuilder(Class entity) {
- return documentBuilders.get( entity );
- }
-
- public IndexReader getIndexReader(Class entity) {
- //TODO NPEs
- DirectoryProvider provider = documentBuilders.get( entity ).getDirectoryProvider();
- IndexReader reader = readers.get( provider );
- if ( reader != null ) return reader;
- lockProvider( provider );
- try {
- reader = IndexReader.open( provider.getDirectory() );
- readers.put( provider, reader );
- }
- catch (IOException e) {
- cleanUp( new HibernateException( "Unable to open IndexReader for " + entity,
e ) );
- }
- return reader;
- }
-
- public IndexWriter getIndexWriter(Class entity) {
- DirectoryProvider provider = documentBuilders.get( entity ).getDirectoryProvider();
- IndexWriter writer = writers.get( provider );
- if ( writer != null ) return writer;
- lockProvider( provider );
- try {
- writer = new IndexWriter(
- provider.getDirectory(), documentBuilders.get( entity ).getAnalyzer(), false
- ); //have been created at init time
- writers.put( provider, writer );
- }
- catch (IOException e) {
- cleanUp( new HibernateException( "Unable to open IndexWriter for " + entity,
e ) );
- }
- return writer;
- }
-
- private void lockProvider(DirectoryProvider provider) {
- //make sure to use a semaphore
- ReentrantLock lock = lockableDirectoryProviders.get( provider );
- //of course a given thread cannot have a race cond with itself
- if ( !lock.isHeldByCurrentThread() ) {
- lock.lock();
- lockedProviders.add( provider );
- }
- }
-
- private void cleanUp(HibernateException originalException) {
- //release all readers and writers, then reelase locks
- HibernateException raisedException = originalException;
- for ( IndexReader reader : readers.values() ) {
- try {
- reader.close();
- }
- catch (IOException e) {
- if ( raisedException != null ) {
- log.error( "Subsequent Exception while closing IndexReader", e );
- }
- else {
- raisedException = new HibernateException( "Exception while closing
IndexReader", e );
- }
- }
- }
- for ( IndexWriter writer : writers.values() ) {
- try {
- writer.close();
- }
- catch (IOException e) {
- if ( raisedException != null ) {
- log.error( "Subsequent Exception while closing IndexWriter", e );
- }
- else {
- raisedException = new HibernateException( "Exception while closing
IndexWriter", e );
- }
- }
- }
- for ( DirectoryProvider provider : lockedProviders ) {
- lockableDirectoryProviders.get( provider ).unlock();
- }
- readers.clear();
- writers.clear();
- lockedProviders.clear();
- if ( raisedException != null ) throw raisedException;
- }
-
- /**
- * release resources consumed in the workspace if any
- */
- public void clean() {
- cleanUp( null );
- }
-}
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/IteratorImpl.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/IteratorImpl.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/IteratorImpl.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -27,7 +27,7 @@
}
public Object next() {
- Object object = session.get( entityInfos.get(index).clazz, entityInfos.get(index).id
);
+ Object object = session.get( entityInfos.get( index ).clazz, entityInfos.get( index
).id );
index++;
return object;
}
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -14,15 +14,15 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.document.Document;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MultiSearcher;
import org.apache.lucene.search.Searcher;
-import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.index.Term;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
@@ -34,7 +34,7 @@
import org.hibernate.engine.query.ParameterMetadata;
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.impl.AbstractQueryImpl;
-import org.hibernate.lucene.DocumentBuilder;
+import org.hibernate.lucene.engine.DocumentBuilder;
import org.hibernate.lucene.event.LuceneEventListener;
/**
@@ -76,18 +76,18 @@
Searcher searcher = buildSearcher( listener );
Hits hits;
try {
- org.apache.lucene.search.Query query = filterQueryByClasses(luceneQuery);
+ org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
hits = searcher.search( query );
setResultSize( hits );
int first = first();
int max = max( first, hits );
- List<EntityInfo> entityInfos = new ArrayList<EntityInfo>(max - first +
1);
+ List<EntityInfo> entityInfos = new ArrayList<EntityInfo>( max - first + 1
);
for ( int index = first; index <= max; index++ ) {
Document document = hits.doc( index );
EntityInfo entityInfo = new EntityInfo();
entityInfo.clazz = DocumentBuilder.getDocumentClass( document );
entityInfo.id = DocumentBuilder.getDocumentId( listener, entityInfo.clazz, document
);
- entityInfos.add(entityInfo);
+ entityInfos.add( entityInfo );
}
return new IteratorImpl( entityInfos, (Session) this.session );
}
@@ -140,8 +140,8 @@
Searcher searcher = buildSearcher( listener );
Hits hits;
try {
- org.apache.lucene.search.Query query = filterQueryByClasses(luceneQuery);
- log.warn(query.toString());
+ org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
+ log.warn( query.toString() );
hits = searcher.search( query );
setResultSize( hits );
int first = first();
@@ -178,14 +178,14 @@
private org.apache.lucene.search.Query
filterQueryByClasses(org.apache.lucene.search.Query luceneQuery) {
//A query filter is more practical than a manual class filtering post query (esp on
scrollable resultsets)
//it also probably minimise the memory footprint
- if (classesAndSubclasses == null) {
+ if ( classesAndSubclasses == null ) {
return luceneQuery;
}
else {
BooleanQuery classFilter = new BooleanQuery();
//annihilate the scoring impact of DocumentBuilder.CLASS_FIELDNAME
classFilter.setBoost( 0 );
- for (Class clazz : classesAndSubclasses) {
+ for ( Class clazz : classesAndSubclasses ) {
Term t = new Term( DocumentBuilder.CLASS_FIELDNAME, clazz.getName() );
TermQuery termQuery = new TermQuery( t );
classFilter.add( termQuery, BooleanClause.Occur.SHOULD );
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/ScrollableResultsImpl.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/ScrollableResultsImpl.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/ScrollableResultsImpl.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -17,7 +17,7 @@
import org.hibernate.HibernateException;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
-import org.hibernate.lucene.DocumentBuilder;
+import org.hibernate.lucene.engine.DocumentBuilder;
import org.hibernate.lucene.event.LuceneEventListener;
import org.hibernate.type.Type;
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProvider.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProvider.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProvider.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -17,7 +17,9 @@
* @author Sylvain Vieujot
*/
public interface DirectoryProvider<TDirectory extends Directory> {
- /** get the information to initialize the directory and build its hashCode */
+ /**
+ * get the information to initialize the directory and build its hashCode
+ */
void initialize(String directoryProviderName, Properties properties);
/**
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProviderFactory.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProviderFactory.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProviderFactory.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -7,12 +7,12 @@
import java.util.Properties;
import org.hibernate.HibernateException;
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.reflection.ReflectionManager;
import org.hibernate.reflection.XClass;
-import org.hibernate.reflection.ReflectionManager;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.AnnotationConfiguration;
-import org.hibernate.lucene.Indexed;
import org.hibernate.util.ReflectHelper;
import org.hibernate.util.StringHelper;
@@ -20,14 +20,14 @@
* Create a Lucene directory provider
* <p/>
* Lucene directory providers are configured through properties
- * - hibernate.lucene.default.* and
- * - hibernate.lucene.<indexname>.*
- *
+ * - hibernate.lucene.default.* and
+ * - hibernate.lucene.<indexname>.*
+ * <p/>
* <indexname> properties have precedence over default
- *
+ * <p/>
* The implementation is described by
* hibernate.lucene.[default|indexname].directory_provider
- *
+ * <p/>
* If none is defined the default value is FSDirectory
*
* @author Emmanuel Bernard
@@ -39,10 +39,10 @@
private static String LUCENE_DEFAULT = LUCENE_PREFIX + "default.";
private static String DEFAULT_DIRECTORY_PROVIDER = FSDirectoryProvider.class.getName();
- //TODO for the public?
- //public DirectoryProvider<?> createDirectoryProvider(XClass entity,
Configuration cfg) {
+ //TODO for the public?
+ //public DirectoryProvider<?> createDirectoryProvider(XClass entity, Configuration
cfg) {
- public DirectoryProvider<?> createDirectoryProvider(XClass entity,
Configuration cfg) {
+ public DirectoryProvider<?> createDirectoryProvider(XClass entity, Configuration
cfg) {
//get properties
String directoryProviderName = getDirectoryProviderName( entity, cfg );
Properties indexProps = getDirectoryProperties( cfg, directoryProviderName );
@@ -54,8 +54,8 @@
}
DirectoryProvider<?> provider = null;
try {
- @SuppressWarnings("unchecked")
- Class<DirectoryProvider> directoryClass = ReflectHelper.classForName(
+ @SuppressWarnings( "unchecked" )
+ Class<DirectoryProvider> directoryClass = ReflectHelper.classForName(
className, DirectoryProviderFactory.class
);
provider = directoryClass.newInstance();
@@ -94,10 +94,10 @@
}
public static String getDirectoryProviderName(XClass clazz, Configuration cfg) {
- //yuk
- ReflectionManager reflectionManager =
- ( (AnnotationConfiguration) cfg
).createExtendedMappings().getReflectionManager();
- //get the most specialized (ie subclass > superclass) non default index name
+ //yuk
+ ReflectionManager reflectionManager =
+ ( (AnnotationConfiguration) cfg ).createExtendedMappings().getReflectionManager();
+ //get the most specialized (ie subclass > superclass) non default index name
//if none extract the name from the most generic (superclass > subclass) @Indexed
class in the hierarchy
//FIXME I'm inclined to get rid of the default value
PersistentClass pc = cfg.getClassMapping( clazz.getName() );
@@ -105,7 +105,7 @@
do {
XClass currentClazz = reflectionManager.toXClass( pc.getMappedClass() );
Indexed indexAnn = currentClazz.getAnnotation( Indexed.class );
- if (indexAnn != null) {
+ if ( indexAnn != null ) {
if ( indexAnn.index().length() != 0 ) {
return indexAnn.index();
}
@@ -113,14 +113,16 @@
rootIndex = currentClazz;
}
}
- pc = pc.getSuperclass();
- } while (pc != null);
+ pc = pc.getSuperclass();
+ }
+ while ( pc != null );
//there is nobody outthere with a non default @Indexed.index
- if (rootIndex != null) {
+ if ( rootIndex != null ) {
return rootIndex.getName();
}
else {
- throw new HibernateException("Trying to extract the index name from a non
@Indexed class: " + clazz.getName() );
+ throw new HibernateException(
+ "Trying to extract the index name from a non @Indexed class: " +
clazz.getName() );
}
}
}
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/FSDirectoryProvider.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/FSDirectoryProvider.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/FSDirectoryProvider.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -45,8 +45,8 @@
boolean create = !file.exists();
indexName = file.getCanonicalPath();
directory = FSDirectory.getDirectory( indexName, create );
- if (create) {
- IndexWriter iw = new IndexWriter(directory, new StandardAnalyzer(), create );
+ if ( create ) {
+ IndexWriter iw = new IndexWriter( directory, new StandardAnalyzer(), create );
iw.close();
}
}
@@ -65,9 +65,9 @@
// this code is actually broken since the value change after initialize call
// but from a practical POV this is fine since we only call this method
// after initialize call
- if (obj == this) return true;
- if (obj == null || ! (obj instanceof FSDirectoryProvider) ) return false;
- return indexName.equals( ( (FSDirectoryProvider) obj).indexName );
+ if ( obj == this ) return true;
+ if ( obj == null || !( obj instanceof FSDirectoryProvider ) ) return false;
+ return indexName.equals( ( (FSDirectoryProvider) obj ).indexName );
}
@Override
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/RAMDirectoryProvider.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/RAMDirectoryProvider.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/RAMDirectoryProvider.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -24,7 +24,7 @@
indexName = directoryProviderName;
directory = new RAMDirectory();
try {
- IndexWriter iw = new IndexWriter(directory, new StandardAnalyzer(), true );
+ IndexWriter iw = new IndexWriter( directory, new StandardAnalyzer(), true );
iw.close();
}
catch (IOException e) {
@@ -41,9 +41,9 @@
// this code is actually broken since the value change after initialize call
// but from a practical POV this is fine since we only call this method
// after initialize call
- if (obj == this) return true;
- if (obj == null || ! (obj instanceof RAMDirectoryProvider) ) return false;
- return indexName.equals( ( (RAMDirectoryProvider) obj).indexName );
+ if ( obj == this ) return true;
+ if ( obj == null || !( obj instanceof RAMDirectoryProvider ) ) return false;
+ return indexName.equals( ( (RAMDirectoryProvider) obj ).indexName );
}
@Override
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/util/BinderHelper.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/util/BinderHelper.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/util/BinderHelper.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,27 +1,23 @@
//$Id: $
package org.hibernate.lucene.util;
-import java.lang.reflect.Method;
-import java.lang.reflect.Member;
-import java.lang.reflect.Field;
-import java.beans.Introspector;
-
-import org.hibernate.util.StringHelper;
import org.hibernate.reflection.XMember;
+import org.hibernate.util.StringHelper;
/**
* @author Emmanuel Bernard
*/
public abstract class BinderHelper {
- private BinderHelper() {}
+ private BinderHelper() {
+ }
/**
* Get attribute name out of member unless overriden by <code>name</code>
*/
public static String getAttributeName(XMember member, String name) {
return StringHelper.isNotEmpty( name ) ?
- name :
- member.getName(); //explicit field name
+ name :
+ member.getName(); //explicit field name
}
}
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/AlternateDocument.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/AlternateDocument.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/AlternateDocument.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -3,15 +3,14 @@
import javax.persistence.Entity;
import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
import javax.persistence.Lob;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.DocumentId;
-import org.hibernate.lucene.Field;
-import org.hibernate.lucene.Store;
-import org.hibernate.lucene.Index;
-import org.hibernate.lucene.Boost;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.DocumentId;
+import org.hibernate.lucene.annotations.Field;
+import org.hibernate.lucene.annotations.Store;
+import org.hibernate.lucene.annotations.Index;
+import org.hibernate.lucene.annotations.Boost;
/**
* Example of 2 entities mapped in the same index
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Clock.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Clock.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Clock.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -4,9 +4,9 @@
import javax.persistence.Entity;
import javax.persistence.Id;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Keyword;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.Text;
+import org.hibernate.lucene.annotations.Keyword;
/**
* @author Emmanuel Bernard
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Document.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Document.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Document.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -6,15 +6,12 @@
import javax.persistence.Id;
import javax.persistence.Lob;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.Keyword;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Unstored;
-import org.hibernate.lucene.Boost;
-import org.hibernate.lucene.Field;
-import org.hibernate.lucene.Index;
-import org.hibernate.lucene.DocumentId;
-import org.hibernate.lucene.Store;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.Boost;
+import org.hibernate.lucene.annotations.Field;
+import org.hibernate.lucene.annotations.Index;
+import org.hibernate.lucene.annotations.DocumentId;
+import org.hibernate.lucene.annotations.Store;
@Entity
@Indexed(index = "Documents")
@@ -38,7 +35,7 @@
@GeneratedValue
//@Keyword(id = true)
@DocumentId
- public Long getId() {
+ public Long getId() {
return id;
}
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/bridge/Cloud.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/bridge/Cloud.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/bridge/Cloud.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -6,11 +6,11 @@
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
-import org.hibernate.lucene.Keyword;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.DateBridge;
-import org.hibernate.lucene.FieldBridge;
+import org.hibernate.lucene.annotations.Keyword;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.Text;
+import org.hibernate.lucene.annotations.DateBridge;
+import org.hibernate.lucene.annotations.FieldBridge;
import org.hibernate.lucene.bridge.Resolution;
import org.hibernate.annotations.Parameter;
@@ -143,7 +143,7 @@
}
@Text
- public String getString() {
+ public String getString() {
return string;
}
@@ -222,7 +222,7 @@
}
@Keyword
- @DateBridge( Resolution.MILLISECOND )
+ @DateBridge( Resolution.MILLISECOND )
public Date getDateMillisecond() {
return dateMillisecond;
}
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/fieldAccess/Document.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/fieldAccess/Document.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/fieldAccess/Document.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -6,11 +6,11 @@
import javax.persistence.Entity;
import javax.persistence.Lob;
-import org.hibernate.lucene.Unstored;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Keyword;
-import org.hibernate.lucene.Boost;
-import org.hibernate.lucene.Indexed;
+import org.hibernate.lucene.annotations.Unstored;
+import org.hibernate.lucene.annotations.Text;
+import org.hibernate.lucene.annotations.Keyword;
+import org.hibernate.lucene.annotations.Boost;
+import org.hibernate.lucene.annotations.Indexed;
/**
* @author Richard Hallier
@@ -24,7 +24,7 @@
private Long id;
@Text
- @Boost(2)
+ @Boost(2)
private String title;
@Unstored(name = "Abstract")
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Animal.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Animal.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Animal.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,9 +1,9 @@
//$Id: $
package org.hibernate.lucene.test.inheritance;
-import org.hibernate.lucene.Keyword;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Indexed;
+import org.hibernate.lucene.annotations.Keyword;
+import org.hibernate.lucene.annotations.Text;
+import org.hibernate.lucene.annotations.Indexed;
import javax.persistence.Entity;
import javax.persistence.Id;
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Mammal.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Mammal.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Mammal.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -1,9 +1,8 @@
//$Id: $
package org.hibernate.lucene.test.inheritance;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.Keyword;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.Keyword;
import javax.persistence.Entity;
@@ -16,7 +15,7 @@
private int mammalNbr;
@Keyword
- public int getMammalNbr() {
+ public int getMammalNbr() {
return mammalNbr;
}
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/AlternateBook.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/AlternateBook.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/AlternateBook.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -4,10 +4,10 @@
import javax.persistence.Entity;
import javax.persistence.Id;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.DocumentId;
-import org.hibernate.lucene.Field;
-import org.hibernate.lucene.Index;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.DocumentId;
+import org.hibernate.lucene.annotations.Field;
+import org.hibernate.lucene.annotations.Index;
/**
* @author Emmanuel Bernard
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Book.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Book.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Book.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -4,10 +4,10 @@
import javax.persistence.Entity;
import javax.persistence.Id;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.Keyword;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Unstored;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.Text;
+import org.hibernate.lucene.annotations.Keyword;
+import org.hibernate.lucene.annotations.Unstored;
/**
* @author Emmanuel Bernard
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Clock.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Clock.java 2006-11-01
22:53:30 UTC (rev 10680)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Clock.java 2006-11-01
23:06:05 UTC (rev 10681)
@@ -4,9 +4,9 @@
import javax.persistence.Entity;
import javax.persistence.Id;
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Keyword;
+import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.lucene.annotations.Text;
+import org.hibernate.lucene.annotations.Keyword;
/**
* @author Emmanuel Bernard