Hibernate SVN: r17632 - beanvalidation/api/trunk/src/main/java/javax/validation/metadata.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-10-06 13:00:53 -0400 (Tue, 06 Oct 2009)
New Revision: 17632
Modified:
beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java
Log:
Enhance JavaDoc
Modified: beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java
===================================================================
--- beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java 2009-10-06 16:59:36 UTC (rev 17631)
+++ beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java 2009-10-06 17:00:53 UTC (rev 17632)
@@ -55,7 +55,7 @@
ConstraintFinder findConstraints();
/**
- * Declare restrictions on retrived constraints.
+ * Declare restrictions on retrieved constraints.
* Restrictions are cumulative.
*
* A <code>ConstraintFinder</code> is not thread-safe. The set of matching
14 years, 7 months
Hibernate SVN: r17631 - beanvalidation/api/trunk/src/main/java/javax/validation/metadata.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-10-06 12:59:36 -0400 (Tue, 06 Oct 2009)
New Revision: 17631
Modified:
beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java
Log:
Enhance JavaDoc
Modified: beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java
===================================================================
--- beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java 2009-10-06 13:38:43 UTC (rev 17630)
+++ beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java 2009-10-06 16:59:36 UTC (rev 17631)
@@ -81,7 +81,7 @@
*
* Defaults to <code>Scope.HIERARCHY</code>
*
- * @param scope exected scope
+ * @param scope expected scope
* @return <code>this</code> following the chaining method pattern
*/
ConstraintFinder lookingAt(Scope scope);
14 years, 7 months
Hibernate SVN: r17630 - in search/trunk: hibernate-search-archetype/src/main/resources/archetype-resources/src/test/java/java/example and 68 other directories.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2009-10-06 09:38:43 -0400 (Tue, 06 Oct 2009)
New Revision: 17630
Modified:
search/trunk/hibernate-search-archetype/src/main/resources/archetype-resources/src/main/java/example/Author.java
search/trunk/hibernate-search-archetype/src/main/resources/archetype-resources/src/main/java/example/Book.java
search/trunk/hibernate-search-archetype/src/main/resources/archetype-resources/src/test/java/java/example/IndexAndSearchTest.java
search/trunk/src/main/java/org/hibernate/search/Environment.java
search/trunk/src/main/java/org/hibernate/search/FullTextFilter.java
search/trunk/src/main/java/org/hibernate/search/FullTextQuery.java
search/trunk/src/main/java/org/hibernate/search/FullTextSession.java
search/trunk/src/main/java/org/hibernate/search/MassIndexer.java
search/trunk/src/main/java/org/hibernate/search/ProjectionConstants.java
search/trunk/src/main/java/org/hibernate/search/Search.java
search/trunk/src/main/java/org/hibernate/search/SearchException.java
search/trunk/src/main/java/org/hibernate/search/SearchFactory.java
search/trunk/src/main/java/org/hibernate/search/Version.java
search/trunk/src/main/java/org/hibernate/search/analyzer/Discriminator.java
search/trunk/src/main/java/org/hibernate/search/annotations/Analyzer.java
search/trunk/src/main/java/org/hibernate/search/annotations/AnalyzerDef.java
search/trunk/src/main/java/org/hibernate/search/annotations/AnalyzerDefs.java
search/trunk/src/main/java/org/hibernate/search/annotations/AnalyzerDiscriminator.java
search/trunk/src/main/java/org/hibernate/search/annotations/Boost.java
search/trunk/src/main/java/org/hibernate/search/annotations/ClassBridge.java
search/trunk/src/main/java/org/hibernate/search/annotations/ClassBridges.java
search/trunk/src/main/java/org/hibernate/search/annotations/ContainedIn.java
search/trunk/src/main/java/org/hibernate/search/annotations/DateBridge.java
search/trunk/src/main/java/org/hibernate/search/annotations/DocumentId.java
search/trunk/src/main/java/org/hibernate/search/annotations/DynamicBoost.java
search/trunk/src/main/java/org/hibernate/search/annotations/Factory.java
search/trunk/src/main/java/org/hibernate/search/annotations/Field.java
search/trunk/src/main/java/org/hibernate/search/annotations/FieldBridge.java
search/trunk/src/main/java/org/hibernate/search/annotations/Fields.java
search/trunk/src/main/java/org/hibernate/search/annotations/FilterCacheModeType.java
search/trunk/src/main/java/org/hibernate/search/annotations/FullTextFilterDef.java
search/trunk/src/main/java/org/hibernate/search/annotations/FullTextFilterDefs.java
search/trunk/src/main/java/org/hibernate/search/annotations/Index.java
search/trunk/src/main/java/org/hibernate/search/annotations/Indexed.java
search/trunk/src/main/java/org/hibernate/search/annotations/IndexedEmbedded.java
search/trunk/src/main/java/org/hibernate/search/annotations/Key.java
search/trunk/src/main/java/org/hibernate/search/annotations/Parameter.java
search/trunk/src/main/java/org/hibernate/search/annotations/ProvidedId.java
search/trunk/src/main/java/org/hibernate/search/annotations/Resolution.java
search/trunk/src/main/java/org/hibernate/search/annotations/Similarity.java
search/trunk/src/main/java/org/hibernate/search/annotations/Store.java
search/trunk/src/main/java/org/hibernate/search/annotations/TermVector.java
search/trunk/src/main/java/org/hibernate/search/annotations/TokenFilterDef.java
search/trunk/src/main/java/org/hibernate/search/annotations/TokenizerDef.java
search/trunk/src/main/java/org/hibernate/search/backend/AddLuceneWork.java
search/trunk/src/main/java/org/hibernate/search/backend/BackendQueueProcessorFactory.java
search/trunk/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java
search/trunk/src/main/java/org/hibernate/search/backend/LuceneIndexingParameters.java
search/trunk/src/main/java/org/hibernate/search/backend/LuceneWork.java
search/trunk/src/main/java/org/hibernate/search/backend/OptimizeLuceneWork.java
search/trunk/src/main/java/org/hibernate/search/backend/PurgeAllLuceneWork.java
search/trunk/src/main/java/org/hibernate/search/backend/QueueingProcessor.java
search/trunk/src/main/java/org/hibernate/search/backend/TransactionContext.java
search/trunk/src/main/java/org/hibernate/search/backend/Work.java
search/trunk/src/main/java/org/hibernate/search/backend/WorkQueue.java
search/trunk/src/main/java/org/hibernate/search/backend/WorkType.java
search/trunk/src/main/java/org/hibernate/search/backend/WorkVisitor.java
search/trunk/src/main/java/org/hibernate/search/backend/Worker.java
search/trunk/src/main/java/org/hibernate/search/backend/WorkerFactory.java
search/trunk/src/main/java/org/hibernate/search/backend/Workspace.java
search/trunk/src/main/java/org/hibernate/search/backend/configuration/ConfigurationParseHelper.java
search/trunk/src/main/java/org/hibernate/search/backend/configuration/IndexWriterSetting.java
search/trunk/src/main/java/org/hibernate/search/backend/configuration/MaskedProperty.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/EventSourceTransactionContext.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/PostTransactionWorkQueueSynchronization.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/TransactionalWorker.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/BatchBackend.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/DirectoryProviderWorkspace.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/LuceneBatchBackend.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/blackhole/BlackHoleBackendQueueProcessorFactory.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JGroupsBackendQueueProcessor.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JGroupsBackendQueueProcessorFactory.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JGroupsMasterMessageListener.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/MasterJGroupsBackendQueueProcessorFactory.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/SlaveJGroupsBackendQueueProcessorFactory.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/jms/AbstractJMSHibernateSearchController.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/jms/JMSBackendQueueProcessor.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/jms/JMSBackendQueueProcessorFactory.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/DpSelectionDelegate.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/DpSelectionVisitor.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessorFactory.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPResources.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDirectoryWorkProcessor.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/QueueProcessors.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/AddWorkDelegate.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/DeleteExtWorkDelegate.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/DeleteWorkDelegate.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/LuceneWorkDelegate.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/LuceneWorkVisitor.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/OptimizeWorkDelegate.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/PurgeAllWorkDelegate.java
search/trunk/src/main/java/org/hibernate/search/batchindexing/BatchCoordinator.java
search/trunk/src/main/java/org/hibernate/search/batchindexing/BatchIndexingWorkspace.java
search/trunk/src/main/java/org/hibernate/search/batchindexing/EntityConsumerLuceneworkProducer.java
search/trunk/src/main/java/org/hibernate/search/batchindexing/Executors.java
search/trunk/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java
search/trunk/src/main/java/org/hibernate/search/batchindexing/IdentifierProducer.java
search/trunk/src/main/java/org/hibernate/search/batchindexing/MassIndexerProgressMonitor.java
search/trunk/src/main/java/org/hibernate/search/batchindexing/ProducerConsumerQueue.java
search/trunk/src/main/java/org/hibernate/search/bridge/BridgeFactory.java
search/trunk/src/main/java/org/hibernate/search/bridge/FieldBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/LuceneOptions.java
search/trunk/src/main/java/org/hibernate/search/bridge/ParameterizedBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/String2FieldBridgeAdaptor.java
search/trunk/src/main/java/org/hibernate/search/bridge/StringBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/TwoWayFieldBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/TwoWayString2FieldBridgeAdaptor.java
search/trunk/src/main/java/org/hibernate/search/bridge/TwoWayStringBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/BigDecimalBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/BigIntegerBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/BooleanBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/CharacterBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/ClassBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DateBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DoubleBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/EnumBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/FloatBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/IntegerBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/LongBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/NumberBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/ShortBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/StringBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/UriBridge.java
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/UrlBridge.java
search/trunk/src/main/java/org/hibernate/search/cfg/AnalyzerDefMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/ConcatStringBridge.java
search/trunk/src/main/java/org/hibernate/search/cfg/DocumentIdMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/EntityDescriptor.java
search/trunk/src/main/java/org/hibernate/search/cfg/EntityMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/FieldBridgeMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/PropertyDescriptor.java
search/trunk/src/main/java/org/hibernate/search/cfg/PropertyMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/SearchConfiguration.java
search/trunk/src/main/java/org/hibernate/search/cfg/SearchConfigurationFromHibernateCore.java
search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/TokenFilterDefMapping.java
search/trunk/src/main/java/org/hibernate/search/engine/BoostStrategy.java
search/trunk/src/main/java/org/hibernate/search/engine/DefaultBoostStrategy.java
search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilder.java
search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java
search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java
search/trunk/src/main/java/org/hibernate/search/engine/DocumentExtractor.java
search/trunk/src/main/java/org/hibernate/search/engine/EntityInfo.java
search/trunk/src/main/java/org/hibernate/search/engine/EntityState.java
search/trunk/src/main/java/org/hibernate/search/engine/FilterDef.java
search/trunk/src/main/java/org/hibernate/search/engine/Loader.java
search/trunk/src/main/java/org/hibernate/search/engine/LoaderHelper.java
search/trunk/src/main/java/org/hibernate/search/engine/LuceneOptionsImpl.java
search/trunk/src/main/java/org/hibernate/search/engine/MultiClassesQueryLoader.java
search/trunk/src/main/java/org/hibernate/search/engine/ObjectLoader.java
search/trunk/src/main/java/org/hibernate/search/engine/ObjectLoaderHelper.java
search/trunk/src/main/java/org/hibernate/search/engine/ProjectionLoader.java
search/trunk/src/main/java/org/hibernate/search/engine/QueryLoader.java
search/trunk/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java
search/trunk/src/main/java/org/hibernate/search/event/ContextHolder.java
search/trunk/src/main/java/org/hibernate/search/event/EventListenerRegister.java
search/trunk/src/main/java/org/hibernate/search/event/FullTextIndexCollectionEventListener.java
search/trunk/src/main/java/org/hibernate/search/event/FullTextIndexEventListener.java
search/trunk/src/main/java/org/hibernate/search/filter/AndDocIdSet.java
search/trunk/src/main/java/org/hibernate/search/filter/CachingWrapperFilter.java
search/trunk/src/main/java/org/hibernate/search/filter/ChainedFilter.java
search/trunk/src/main/java/org/hibernate/search/filter/EmptyDocIdBitSet.java
search/trunk/src/main/java/org/hibernate/search/filter/FilterCachingStrategy.java
search/trunk/src/main/java/org/hibernate/search/filter/FilterKey.java
search/trunk/src/main/java/org/hibernate/search/filter/FilterOptimizationHelper.java
search/trunk/src/main/java/org/hibernate/search/filter/FullTextFilterImplementor.java
search/trunk/src/main/java/org/hibernate/search/filter/MRUFilterCachingStrategy.java
search/trunk/src/main/java/org/hibernate/search/filter/ShardSensitiveOnlyFilter.java
search/trunk/src/main/java/org/hibernate/search/filter/StandardFilterKey.java
search/trunk/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java
search/trunk/src/main/java/org/hibernate/search/impl/InitContext.java
search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java
search/trunk/src/main/java/org/hibernate/search/impl/MassIndexerImpl.java
search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java
search/trunk/src/main/java/org/hibernate/search/impl/SimpleIndexingProgressMonitor.java
search/trunk/src/main/java/org/hibernate/search/impl/SolrAnalyzerBuilder.java
search/trunk/src/main/java/org/hibernate/search/jpa/FullTextEntityManager.java
search/trunk/src/main/java/org/hibernate/search/jpa/FullTextQuery.java
search/trunk/src/main/java/org/hibernate/search/jpa/Search.java
search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java
search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java
search/trunk/src/main/java/org/hibernate/search/query/FullTextFilterImpl.java
search/trunk/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java
search/trunk/src/main/java/org/hibernate/search/query/IteratorImpl.java
search/trunk/src/main/java/org/hibernate/search/query/QueryHits.java
search/trunk/src/main/java/org/hibernate/search/query/ScrollableResultsImpl.java
search/trunk/src/main/java/org/hibernate/search/reader/CacheableMultiReader.java
search/trunk/src/main/java/org/hibernate/search/reader/NotSharedReaderProvider.java
search/trunk/src/main/java/org/hibernate/search/reader/ReaderProvider.java
search/trunk/src/main/java/org/hibernate/search/reader/ReaderProviderFactory.java
search/trunk/src/main/java/org/hibernate/search/reader/ReaderProviderHelper.java
search/trunk/src/main/java/org/hibernate/search/reader/SharedReaderProvider.java
search/trunk/src/main/java/org/hibernate/search/reader/SharingBufferReaderProvider.java
search/trunk/src/main/java/org/hibernate/search/store/DirectoryProvider.java
search/trunk/src/main/java/org/hibernate/search/store/DirectoryProviderFactory.java
search/trunk/src/main/java/org/hibernate/search/store/DirectoryProviderHelper.java
search/trunk/src/main/java/org/hibernate/search/store/FSDirectoryProvider.java
search/trunk/src/main/java/org/hibernate/search/store/FSMasterDirectoryProvider.java
search/trunk/src/main/java/org/hibernate/search/store/FSSlaveDirectoryProvider.java
search/trunk/src/main/java/org/hibernate/search/store/IdHashShardingStrategy.java
search/trunk/src/main/java/org/hibernate/search/store/IndexShardingStrategy.java
search/trunk/src/main/java/org/hibernate/search/store/LockFactoryFactory.java
search/trunk/src/main/java/org/hibernate/search/store/NotShardedStrategy.java
search/trunk/src/main/java/org/hibernate/search/store/RAMDirectoryProvider.java
search/trunk/src/main/java/org/hibernate/search/store/optimization/IncrementalOptimizerStrategy.java
search/trunk/src/main/java/org/hibernate/search/store/optimization/NoOpOptimizerStrategy.java
search/trunk/src/main/java/org/hibernate/search/store/optimization/OptimizerStrategy.java
search/trunk/src/main/java/org/hibernate/search/util/ContextHelper.java
search/trunk/src/main/java/org/hibernate/search/util/DelegateNamedAnalyzer.java
search/trunk/src/main/java/org/hibernate/search/util/FileHelper.java
search/trunk/src/main/java/org/hibernate/search/util/FilterCacheModeTypeHelper.java
search/trunk/src/main/java/org/hibernate/search/util/HibernateSearchResourceLoader.java
search/trunk/src/main/java/org/hibernate/search/util/LoggerFactory.java
search/trunk/src/main/java/org/hibernate/search/util/PluginLoader.java
search/trunk/src/main/java/org/hibernate/search/util/ReflectionHelper.java
search/trunk/src/main/java/org/hibernate/search/util/ScopedAnalyzer.java
search/trunk/src/main/java/org/hibernate/search/util/WeakIdentityHashMap.java
search/trunk/src/main/java/org/hibernate/search/util/XMLHelper.java
search/trunk/src/test/java/org/hibernate/search/test/AlternateDocument.java
search/trunk/src/test/java/org/hibernate/search/test/Clock.java
search/trunk/src/test/java/org/hibernate/search/test/Document.java
search/trunk/src/test/java/org/hibernate/search/test/FSDirectoryTest.java
search/trunk/src/test/java/org/hibernate/search/test/PurgeTest.java
search/trunk/src/test/java/org/hibernate/search/test/RamDirectoryTest.java
search/trunk/src/test/java/org/hibernate/search/test/SearchTestCase.java
search/trunk/src/test/java/org/hibernate/search/test/SerializationTestHelper.java
search/trunk/src/test/java/org/hibernate/search/test/TestCase.java
search/trunk/src/test/java/org/hibernate/search/test/TransactionTest.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/AbstractTestAnalyzer.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/AlarmEntity.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/AnalyzerTest.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/Article.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/BlogEntry.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/DoubleAnalyzerTest.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/LanguageDiscriminator.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/MyComponent.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/MyEntity.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test1Analyzer.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test2Analyzer.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test3Analyzer.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test4Analyzer.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/AnalyzerInheritanceTest.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/BaseClass.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/ISOLatin1Analyzer.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/SubClass.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/InsertWhitespaceFilter.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/InsertWhitespaceFilterFactory.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/SolrAnalyzerTest.java
search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/Team.java
search/trunk/src/test/java/org/hibernate/search/test/batchindexing/AncientBook.java
search/trunk/src/test/java/org/hibernate/search/test/batchindexing/Book.java
search/trunk/src/test/java/org/hibernate/search/test/batchindexing/Dvd.java
search/trunk/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java
search/trunk/src/test/java/org/hibernate/search/test/batchindexing/ModernBook.java
search/trunk/src/test/java/org/hibernate/search/test/batchindexing/SearchIndexerTest.java
search/trunk/src/test/java/org/hibernate/search/test/batchindexing/TitleAble.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/BridgeTest.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/CatDeptsFieldsClassBridge.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/CatFieldsClassBridge.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/ClassBridgeTest.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/Cloud.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/CloudType.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/DateSplitBridge.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/Department.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/Departments.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/EquipmentType.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/Gangster.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/PaddedIntegerBridge.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/TruncateFieldBridge.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/TruncateStringBridge.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/UnresolvedBridgeTest.java
search/trunk/src/test/java/org/hibernate/search/test/classloading/Animal.java
search/trunk/src/test/java/org/hibernate/search/test/classloading/NoAnnotationsTest.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/Address.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/ConfigurationParseHelperTest.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/ConfigurationReadTestCase.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/Country.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/CustomBackendTest.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/EventListenerRegisterTest.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/LuceneIndexingParametersTest.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/MaskedPropertiesTest.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/ShardsConfigurationTest.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/UselessShardingStrategy.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/User.java
search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/CustomLockFactoryFactory.java
search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/CustomLockProviderTest.java
search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/DirectoryProviderHelperTest.java
search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/FSSlaveAndMasterDPTest.java
search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/MultipleSFTestCase.java
search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/SnowStorm.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/Address.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/Author.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/Country.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/EmbeddedTest.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/NonIndexedEntity.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/Order.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/Owner.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/Person.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/Product.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/State.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/StateCandidate.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/Tower.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/Address.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/BusinessContact.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/Contact.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/DoubleInsertEmbeddedTest.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/PersonalContact.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/Phone.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Address.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Attribute.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/AttributeValue.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/NestedEmbeddedTest.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Person.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Place.java
search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Product.java
search/trunk/src/test/java/org/hibernate/search/test/engine/BusLine.java
search/trunk/src/test/java/org/hibernate/search/test/engine/BusStop.java
search/trunk/src/test/java/org/hibernate/search/test/engine/EventListenerSerializationTest.java
search/trunk/src/test/java/org/hibernate/search/test/engine/LazyCollectionsUpdatingTest.java
search/trunk/src/test/java/org/hibernate/search/test/engine/RollbackTransactionTest.java
search/trunk/src/test/java/org/hibernate/search/test/fieldAccess/Document.java
search/trunk/src/test/java/org/hibernate/search/test/fieldAccess/FieldAccessTest.java
search/trunk/src/test/java/org/hibernate/search/test/filter/AndDocIdSetsTest.java
search/trunk/src/test/java/org/hibernate/search/test/filter/BestDriversFilter.java
search/trunk/src/test/java/org/hibernate/search/test/filter/Driver.java
search/trunk/src/test/java/org/hibernate/search/test/filter/ExcludeAllFilter.java
search/trunk/src/test/java/org/hibernate/search/test/filter/ExcludeAllFilterFactory.java
search/trunk/src/test/java/org/hibernate/search/test/filter/FilterTest.java
search/trunk/src/test/java/org/hibernate/search/test/filter/FiltersOptimizationTest.java
search/trunk/src/test/java/org/hibernate/search/test/filter/InstanceBasedExcludeAllFilter.java
search/trunk/src/test/java/org/hibernate/search/test/filter/SecurityFilterFactory.java
search/trunk/src/test/java/org/hibernate/search/test/filter/Soap.java
search/trunk/src/test/java/org/hibernate/search/test/id/Animal.java
search/trunk/src/test/java/org/hibernate/search/test/id/EmbeddedIdTest.java
search/trunk/src/test/java/org/hibernate/search/test/id/ImplicitIdTest.java
search/trunk/src/test/java/org/hibernate/search/test/id/Person.java
search/trunk/src/test/java/org/hibernate/search/test/id/PersonPK.java
search/trunk/src/test/java/org/hibernate/search/test/id/PersonPKBridge.java
search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdPerson.java
search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdPersonSub.java
search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdTest.java
search/trunk/src/test/java/org/hibernate/search/test/indexingStrategy/ManualIndexingStrategyTest.java
search/trunk/src/test/java/org/hibernate/search/test/inheritance/Animal.java
search/trunk/src/test/java/org/hibernate/search/test/inheritance/Being.java
search/trunk/src/test/java/org/hibernate/search/test/inheritance/Bird.java
search/trunk/src/test/java/org/hibernate/search/test/inheritance/Eagle.java
search/trunk/src/test/java/org/hibernate/search/test/inheritance/Fish.java
search/trunk/src/test/java/org/hibernate/search/test/inheritance/InheritanceTest.java
search/trunk/src/test/java/org/hibernate/search/test/inheritance/Mammal.java
search/trunk/src/test/java/org/hibernate/search/test/jgroups/common/JGroupsCommonTest.java
search/trunk/src/test/java/org/hibernate/search/test/jgroups/common/MultipleSessionsSearchTestCase.java
search/trunk/src/test/java/org/hibernate/search/test/jgroups/master/JGroupsMasterTest.java
search/trunk/src/test/java/org/hibernate/search/test/jgroups/master/TShirt.java
search/trunk/src/test/java/org/hibernate/search/test/jgroups/slave/JGroupsReceiver.java
search/trunk/src/test/java/org/hibernate/search/test/jgroups/slave/JGroupsSlaveTest.java
search/trunk/src/test/java/org/hibernate/search/test/jgroups/slave/TShirt.java
search/trunk/src/test/java/org/hibernate/search/test/jms/master/JMSMasterTest.java
search/trunk/src/test/java/org/hibernate/search/test/jms/master/MDBSearchController.java
search/trunk/src/test/java/org/hibernate/search/test/jms/master/TShirt.java
search/trunk/src/test/java/org/hibernate/search/test/jms/slave/JMSSlaveTest.java
search/trunk/src/test/java/org/hibernate/search/test/jms/slave/SearchQueueChecker.java
search/trunk/src/test/java/org/hibernate/search/test/jms/slave/TShirt.java
search/trunk/src/test/java/org/hibernate/search/test/jpa/Bretzel.java
search/trunk/src/test/java/org/hibernate/search/test/jpa/EntityManagerSerializationTest.java
search/trunk/src/test/java/org/hibernate/search/test/jpa/EntityManagerTest.java
search/trunk/src/test/java/org/hibernate/search/test/jpa/JPATestCase.java
search/trunk/src/test/java/org/hibernate/search/test/optimizer/Construction.java
search/trunk/src/test/java/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyTest.java
search/trunk/src/test/java/org/hibernate/search/test/optimizer/OptimizerTestCase.java
search/trunk/src/test/java/org/hibernate/search/test/optimizer/Worker.java
search/trunk/src/test/java/org/hibernate/search/test/perf/Boat.java
search/trunk/src/test/java/org/hibernate/search/test/perf/IndexTestDontRun.java
search/trunk/src/test/java/org/hibernate/search/test/perf/SearcherThread.java
search/trunk/src/test/java/org/hibernate/search/test/query/AlternateBook.java
search/trunk/src/test/java/org/hibernate/search/test/query/Author.java
search/trunk/src/test/java/org/hibernate/search/test/query/Book.java
search/trunk/src/test/java/org/hibernate/search/test/query/Clock.java
search/trunk/src/test/java/org/hibernate/search/test/query/ElectricalProperties.java
search/trunk/src/test/java/org/hibernate/search/test/query/Employee.java
search/trunk/src/test/java/org/hibernate/search/test/query/LuceneQuerySortTest.java
search/trunk/src/test/java/org/hibernate/search/test/query/LuceneQueryTest.java
search/trunk/src/test/java/org/hibernate/search/test/query/MultiClassesQueryLoaderTest.java
search/trunk/src/test/java/org/hibernate/search/test/query/Music.java
search/trunk/src/test/java/org/hibernate/search/test/query/Person.java
search/trunk/src/test/java/org/hibernate/search/test/query/ProjectionQueryTest.java
search/trunk/src/test/java/org/hibernate/search/test/query/ProjectionToDelimStringResultTransformer.java
search/trunk/src/test/java/org/hibernate/search/test/query/ProjectionToMapResultTransformer.java
search/trunk/src/test/java/org/hibernate/search/test/query/QueryLoaderTest.java
search/trunk/src/test/java/org/hibernate/search/test/query/QueryUnindexedEntityTest.java
search/trunk/src/test/java/org/hibernate/search/test/query/ScrollableResultsTest.java
search/trunk/src/test/java/org/hibernate/search/test/query/TermVectorTest.java
search/trunk/src/test/java/org/hibernate/search/test/query/boost/BoostedDescriptionLibrary.java
search/trunk/src/test/java/org/hibernate/search/test/query/boost/BoostedFieldDescriptionLibrary.java
search/trunk/src/test/java/org/hibernate/search/test/query/boost/BoostedGetDescriptionLibrary.java
search/trunk/src/test/java/org/hibernate/search/test/query/boost/CustomBoostStrategy.java
search/trunk/src/test/java/org/hibernate/search/test/query/boost/CustomFieldBoostStrategy.java
search/trunk/src/test/java/org/hibernate/search/test/query/boost/DynamicBoostedDescriptionLibrary.java
search/trunk/src/test/java/org/hibernate/search/test/query/boost/DynamicBoostingTest.java
search/trunk/src/test/java/org/hibernate/search/test/query/boost/FieldBoostTest.java
search/trunk/src/test/java/org/hibernate/search/test/query/boost/Library.java
search/trunk/src/test/java/org/hibernate/search/test/query/criteria/AbstractCar.java
search/trunk/src/test/java/org/hibernate/search/test/query/criteria/Bike.java
search/trunk/src/test/java/org/hibernate/search/test/query/criteria/CombiCar.java
search/trunk/src/test/java/org/hibernate/search/test/query/criteria/MixedCriteriaTest.java
search/trunk/src/test/java/org/hibernate/search/test/query/criteria/SportCar.java
search/trunk/src/test/java/org/hibernate/search/test/query/explain/Dvd.java
search/trunk/src/test/java/org/hibernate/search/test/query/explain/ExplanationTest.java
search/trunk/src/test/java/org/hibernate/search/test/reader/Detective.java
search/trunk/src/test/java/org/hibernate/search/test/reader/NotSharedReaderPerfTest.java
search/trunk/src/test/java/org/hibernate/search/test/reader/ReaderPerfTestCase.java
search/trunk/src/test/java/org/hibernate/search/test/reader/SharedBufferedReaderPerfTest.java
search/trunk/src/test/java/org/hibernate/search/test/reader/SharedReaderPerfTest.java
search/trunk/src/test/java/org/hibernate/search/test/reader/Suspect.java
search/trunk/src/test/java/org/hibernate/search/test/reader/functionality/FilterOnDirectoryTest.java
search/trunk/src/test/java/org/hibernate/search/test/reader/functionality/SharingBufferIndexProviderTest.java
search/trunk/src/test/java/org/hibernate/search/test/reader/functionality/TestableSharingBufferReaderProvider.java
search/trunk/src/test/java/org/hibernate/search/test/reader/performance/AbstractActivity.java
search/trunk/src/test/java/org/hibernate/search/test/reader/performance/BufferSharingReaderPerfTest.java
search/trunk/src/test/java/org/hibernate/search/test/reader/performance/IndexFillRunnable.java
search/trunk/src/test/java/org/hibernate/search/test/reader/performance/InsertActivity.java
search/trunk/src/test/java/org/hibernate/search/test/reader/performance/NotSharedReaderPerfTest.java
search/trunk/src/test/java/org/hibernate/search/test/reader/performance/ReaderPerformance.java
search/trunk/src/test/java/org/hibernate/search/test/reader/performance/SearchActivity.java
search/trunk/src/test/java/org/hibernate/search/test/reader/performance/SharedReaderPerfTest.java
search/trunk/src/test/java/org/hibernate/search/test/reader/performance/UpdateActivity.java
search/trunk/src/test/java/org/hibernate/search/test/session/Categorie.java
search/trunk/src/test/java/org/hibernate/search/test/session/DelegationWrapper.java
search/trunk/src/test/java/org/hibernate/search/test/session/Domain.java
search/trunk/src/test/java/org/hibernate/search/test/session/Email.java
search/trunk/src/test/java/org/hibernate/search/test/session/Entite.java
search/trunk/src/test/java/org/hibernate/search/test/session/MassIndexTest.java
search/trunk/src/test/java/org/hibernate/search/test/session/MassIndexUsingManualFlushTest.java
search/trunk/src/test/java/org/hibernate/search/test/session/OptimizeTest.java
search/trunk/src/test/java/org/hibernate/search/test/session/SessionTest.java
search/trunk/src/test/java/org/hibernate/search/test/shards/Animal.java
search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategy.java
search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategyTest.java
search/trunk/src/test/java/org/hibernate/search/test/shards/DirectoryProviderForQueryTest.java
search/trunk/src/test/java/org/hibernate/search/test/shards/Email.java
search/trunk/src/test/java/org/hibernate/search/test/shards/Furniture.java
search/trunk/src/test/java/org/hibernate/search/test/shards/IdShardingStrategyTest.java
search/trunk/src/test/java/org/hibernate/search/test/shards/ShardsTest.java
search/trunk/src/test/java/org/hibernate/search/test/shards/SpecificShardingStrategy.java
search/trunk/src/test/java/org/hibernate/search/test/similarity/Can.java
search/trunk/src/test/java/org/hibernate/search/test/similarity/DummySimilarity.java
search/trunk/src/test/java/org/hibernate/search/test/similarity/DummySimilarity2.java
search/trunk/src/test/java/org/hibernate/search/test/similarity/SimilarityTest.java
search/trunk/src/test/java/org/hibernate/search/test/similarity/Trash.java
search/trunk/src/test/java/org/hibernate/search/test/util/AnalyzerUtils.java
search/trunk/src/test/java/org/hibernate/search/test/util/FileHelperTest.java
search/trunk/src/test/java/org/hibernate/search/test/util/FullTextSessionBuilder.java
search/trunk/src/test/java/org/hibernate/search/test/util/PluginLoaderTest.java
search/trunk/src/test/java/org/hibernate/search/test/util/textbuilder/SentenceInventor.java
search/trunk/src/test/java/org/hibernate/search/test/util/textbuilder/TextProductionTest.java
search/trunk/src/test/java/org/hibernate/search/test/util/textbuilder/WordDictionary.java
search/trunk/src/test/java/org/hibernate/search/test/worker/AsyncWorkerTest.java
search/trunk/src/test/java/org/hibernate/search/test/worker/ConcurrencyTest.java
search/trunk/src/test/java/org/hibernate/search/test/worker/Drink.java
search/trunk/src/test/java/org/hibernate/search/test/worker/Employee.java
search/trunk/src/test/java/org/hibernate/search/test/worker/Employer.java
search/trunk/src/test/java/org/hibernate/search/test/worker/Food.java
search/trunk/src/test/java/org/hibernate/search/test/worker/SyncWorkerTest.java
search/trunk/src/test/java/org/hibernate/search/test/worker/WorkerTestCase.java
search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/EmailAddress.java
search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/Person.java
search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/SpecialPerson.java
search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/WorkDuplicationTest.java
search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/WorkSequencesTest.java
Log:
(HSEARCH-403) Fix copyright notice and end-of-line terminators in source code
Modified: search/trunk/hibernate-search-archetype/src/main/resources/archetype-resources/src/main/java/example/Author.java
===================================================================
--- search/trunk/hibernate-search-archetype/src/main/resources/archetype-resources/src/main/java/example/Author.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/hibernate-search-archetype/src/main/resources/archetype-resources/src/main/java/example/Author.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package example;
import org.hibernate.search.annotations.*;
Modified: search/trunk/hibernate-search-archetype/src/main/resources/archetype-resources/src/main/java/example/Book.java
===================================================================
--- search/trunk/hibernate-search-archetype/src/main/resources/archetype-resources/src/main/java/example/Book.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/hibernate-search-archetype/src/main/resources/archetype-resources/src/main/java/example/Book.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,88 +1,112 @@
-package example;
-
-import org.hibernate.search.annotations.*;
-import org.apache.solr.analysis.*;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.ManyToMany;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
-import example.Author;
-
-/**
- *
- */
-@Entity
-@AnalyzerDef(name = "customanalyzer",
- tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
- filters = {
- @TokenFilterDef(factory = LowerCaseFilterFactory.class),
- @TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
- @Parameter(name = "language", value = "English")
- })
- })
-@Indexed
-public class Book {
-
- private Integer id;
- private String title;
- private String subtitle;
- private Set<Author> authors = new HashSet<Author>();
- private Date publicationDate;
-
- @IndexedEmbedded
- @ManyToMany
- public Set<Author> getAuthors() {
- return authors;
- }
-
- public void setAuthors(Set<Author> authors) {
- this.authors = authors;
- }
-
- public Book() {
- }
-
- @Field(index = Index.TOKENIZED, store = Store.YES)
- @Analyzer(definition = "customanalyzer")
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- @Id
- @DocumentId
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- @Field(index = Index.TOKENIZED, store = Store.NO)
- @Analyzer(definition = "customanalyzer")
- public String getSubtitle() {
- return subtitle;
- }
-
- public void setSubtitle(String subtitle) {
- this.subtitle = subtitle;
- }
-
- @Field(index = Index.UN_TOKENIZED, store = Store.YES)
- @DateBridge(resolution = Resolution.DAY)
- public Date getPublicationDate() {
- return publicationDate;
- }
-
- public void setPublicationDate(Date publicationDate) {
- this.publicationDate = publicationDate;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package example;
+
+import org.hibernate.search.annotations.*;
+import org.apache.solr.analysis.*;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import example.Author;
+
+/**
+ *
+ */
+@Entity
+@AnalyzerDef(name = "customanalyzer",
+ tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
+ filters = {
+ @TokenFilterDef(factory = LowerCaseFilterFactory.class),
+ @TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
+ @Parameter(name = "language", value = "English")
+ })
+ })
+@Indexed
+public class Book {
+
+ private Integer id;
+ private String title;
+ private String subtitle;
+ private Set<Author> authors = new HashSet<Author>();
+ private Date publicationDate;
+
+ @IndexedEmbedded
+ @ManyToMany
+ public Set<Author> getAuthors() {
+ return authors;
+ }
+
+ public void setAuthors(Set<Author> authors) {
+ this.authors = authors;
+ }
+
+ public Book() {
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.YES)
+ @Analyzer(definition = "customanalyzer")
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Id
+ @DocumentId
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.NO)
+ @Analyzer(definition = "customanalyzer")
+ public String getSubtitle() {
+ return subtitle;
+ }
+
+ public void setSubtitle(String subtitle) {
+ this.subtitle = subtitle;
+ }
+
+ @Field(index = Index.UN_TOKENIZED, store = Store.YES)
+ @DateBridge(resolution = Resolution.DAY)
+ public Date getPublicationDate() {
+ return publicationDate;
+ }
+
+ public void setPublicationDate(Date publicationDate) {
+ this.publicationDate = publicationDate;
+ }
+}
Modified: search/trunk/hibernate-search-archetype/src/main/resources/archetype-resources/src/test/java/java/example/IndexAndSearchTest.java
===================================================================
--- search/trunk/hibernate-search-archetype/src/main/resources/archetype-resources/src/test/java/java/example/IndexAndSearchTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/hibernate-search-archetype/src/main/resources/archetype-resources/src/test/java/java/example/IndexAndSearchTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package example;
import org.apache.lucene.queryParser.MultiFieldQueryParser;
Modified: search/trunk/src/main/java/org/hibernate/search/Environment.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/Environment.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/Environment.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,82 +1,105 @@
-// $Id$
-package org.hibernate.search;
-
-/**
- * @author Emmanuel Bernard
- * @author Hardy Ferentschik
- */
-public final class Environment {
- /**
- * Enable listeners auto registration in Hibernate Annotations and EntityManager. Default to true.
- */
- public static final String AUTOREGISTER_LISTENERS = "hibernate.search.autoregister_listeners";
-
- /**
- * Defines the indexing strategy, default <code>event</code>
- * Other options <code>manual</code>
- */
- public static final String INDEXING_STRATEGY = "hibernate.search.indexing_strategy";
-
- /**
- * Default Lucene analyser
- */
- public static final String ANALYZER_CLASS = "hibernate.search.analyzer";
-
- /**
- * Default Lucene similarity
- */
- public static final String SIMILARITY_CLASS = "hibernate.search.similarity";
-
- public static final String WORKER_PREFIX = "hibernate.search.worker.";
- public static final String WORKER_SCOPE = WORKER_PREFIX + "scope";
- public static final String WORKER_BACKEND = WORKER_PREFIX + "backend";
- public static final String WORKER_EXECUTION = WORKER_PREFIX + "execution";
-
- /**
- * Defines the maximum number of indexing operation batched per transaction
- */
- public static final String WORKER_BATCHSIZE = WORKER_PREFIX + "batch_size";
-
- /**
- * only used then execution is async
- * Thread pool size
- * default 1
- */
- public static final String WORKER_THREADPOOL_SIZE = Environment.WORKER_PREFIX + "thread_pool.size";
-
- /**
- * Size of the buffer queue (besides the thread pool size)
- * <ul>
- * <li>only used then execution is async</li>
- * <li>default infinite</li>
- * </ul>
- */
- public static final String WORKER_WORKQUEUE_SIZE = Environment.WORKER_PREFIX + "buffer_queue.max";
-
- /**
- * define the reader prefix
- */
- public static final String READER_PREFIX = "hibernate.search.reader.";
-
- /**
- * define the reader strategy used
- */
- public static final String READER_STRATEGY = READER_PREFIX + "strategy";
-
- /**
- * filter caching strategy class (must have a no-arg constructor and implement FilterCachingStrategy)
- */
- public static final String FILTER_CACHING_STRATEGY = "hibernate.search.filter.cache_strategy";
-
- /**
- * number of docidresults cached in hard reference.
- */
- public static final String CACHE_DOCIDRESULTS_SIZE = "hibernate.search.filter.cache_docidresults.size";
-
- /**
- * batch backend implementation class (must have a no-arg constructor and implement BatchBackend)
- * also prefix for configuration settings of the batch backend
- */
- public static final String BATCH_BACKEND = "hibernate.search.batchbackend";
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search;
+
+/**
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+public final class Environment {
+ /**
+ * Enable listeners auto registration in Hibernate Annotations and EntityManager. Default to true.
+ */
+ public static final String AUTOREGISTER_LISTENERS = "hibernate.search.autoregister_listeners";
+
+ /**
+ * Defines the indexing strategy, default <code>event</code>
+ * Other options <code>manual</code>
+ */
+ public static final String INDEXING_STRATEGY = "hibernate.search.indexing_strategy";
+
+ /**
+ * Default Lucene analyser
+ */
+ public static final String ANALYZER_CLASS = "hibernate.search.analyzer";
+
+ /**
+ * Default Lucene similarity
+ */
+ public static final String SIMILARITY_CLASS = "hibernate.search.similarity";
+
+ public static final String WORKER_PREFIX = "hibernate.search.worker.";
+ public static final String WORKER_SCOPE = WORKER_PREFIX + "scope";
+ public static final String WORKER_BACKEND = WORKER_PREFIX + "backend";
+ public static final String WORKER_EXECUTION = WORKER_PREFIX + "execution";
+
+ /**
+ * Defines the maximum number of indexing operation batched per transaction
+ */
+ public static final String WORKER_BATCHSIZE = WORKER_PREFIX + "batch_size";
+
+ /**
+ * only used then execution is async
+ * Thread pool size
+ * default 1
+ */
+ public static final String WORKER_THREADPOOL_SIZE = Environment.WORKER_PREFIX + "thread_pool.size";
+
+ /**
+ * Size of the buffer queue (besides the thread pool size)
+ * <ul>
+ * <li>only used then execution is async</li>
+ * <li>default infinite</li>
+ * </ul>
+ */
+ public static final String WORKER_WORKQUEUE_SIZE = Environment.WORKER_PREFIX + "buffer_queue.max";
+
+ /**
+ * define the reader prefix
+ */
+ public static final String READER_PREFIX = "hibernate.search.reader.";
+
+ /**
+ * define the reader strategy used
+ */
+ public static final String READER_STRATEGY = READER_PREFIX + "strategy";
+
+ /**
+ * filter caching strategy class (must have a no-arg constructor and implement FilterCachingStrategy)
+ */
+ public static final String FILTER_CACHING_STRATEGY = "hibernate.search.filter.cache_strategy";
+
+ /**
+ * number of docidresults cached in hard reference.
+ */
+ public static final String CACHE_DOCIDRESULTS_SIZE = "hibernate.search.filter.cache_docidresults.size";
+
+ /**
+ * batch backend implementation class (must have a no-arg constructor and implement BatchBackend)
+ * also prefix for configuration settings of the batch backend
+ */
+ public static final String BATCH_BACKEND = "hibernate.search.batchbackend";
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/FullTextFilter.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/FullTextFilter.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/FullTextFilter.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search;
/**
Modified: search/trunk/src/main/java/org/hibernate/search/FullTextQuery.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/FullTextQuery.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/FullTextQuery.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search;
import org.apache.lucene.search.Filter;
Modified: search/trunk/src/main/java/org/hibernate/search/FullTextSession.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/FullTextSession.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/FullTextSession.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,80 +1,103 @@
-//$Id$
-package org.hibernate.search;
-
-import java.io.Serializable;
-
-import org.hibernate.classic.Session;
-
-/**
- * Extends the Hibernate {@link Session} with fulltext search and indexing capabilities.
- *
- * @author Emmanuel Bernard
- */
-public interface FullTextSession extends Session {
-
- /**
- * Create a fulltext query on top of a native Lucene query returning the matching objects
- * of type <code>entities</code> and their respective subclasses.
- *
- * @param luceneQuery The native Lucene query to be rn against the Lucene index.
- * @param entities List of classes for type filtering. The query result will only return entities of
- * the specified types and their respective subtype. If no class is specified no type filtering will take place.
- *
- * @return A <code>FullTextQuery</code> wrapping around the native Lucene wuery.
- *
- * @throws IllegalArgumentException if entityType is <code>null</code> or not a class or superclass annotated with <code>@Indexed</code>.
- */
- FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class<?>... entities);
-
- /**
- * Force the (re)indexing of a given <b>managed</b> object.
- * Indexation is batched per transaction: if a transaction is active, the operation
- * will not affect the index at least until commit.
- *
- * @param entity The entity to index - must not be <code>null</code>.
- *
- * @throws IllegalArgumentException if entity is null or not an @Indexed entity
- */
- <T> void index(T entity);
-
- /**
- * @return the <code>SearchFactory</code> instance.
- */
- SearchFactory getSearchFactory();
-
- /**
- * Remove the entity with the type <code>entityType</code> and the identifier <code>id</code> from the index.
- * If <code>id == null</code> all indexed entities of this type and its indexed subclasses are deleted. In this
- * case this method behaves like {@link #purgeAll(Class)}.
- *
- * @param entityType The type of the entity to delete.
- * @param id The id of the entity to delete.
- *
- * @throws IllegalArgumentException if entityType is <code>null</code> or not a class or superclass annotated with <code>@Indexed</code>.
- */
- public <T> void purge(Class<T> entityType, Serializable id);
-
- /**
- * Remove all entities from of particular class and all its subclasses from the index.
- *
- * @param entityType The class of the entities to remove.
- *
- * @throws IllegalArgumentException if entityType is <code>null</code> or not a class or superclass annotated with <code>@Indexed</code>.
- */
- public <T> void purgeAll(Class<T> entityType);
-
- /**
- * Flush all index changes forcing Hibernate Search to apply all changes to the index not waiting for the batch limit.
- */
- public void flushToIndexes();
-
- /**
- * Creates a MassIndexer to rebuild the indexes of some
- * or all indexed entity types.
- * Instances cannot be reused.
- * @param types optionally restrict the operation to selected types
- * @return
- */
- public MassIndexer createIndexer(Class<?>... types);
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search;
+
+import java.io.Serializable;
+
+import org.hibernate.classic.Session;
+
+/**
+ * Extends the Hibernate {@link Session} with fulltext search and indexing capabilities.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface FullTextSession extends Session {
+
+ /**
+ * Create a fulltext query on top of a native Lucene query returning the matching objects
+ * of type <code>entities</code> and their respective subclasses.
+ *
+ * @param luceneQuery The native Lucene query to be rn against the Lucene index.
+ * @param entities List of classes for type filtering. The query result will only return entities of
+ * the specified types and their respective subtype. If no class is specified no type filtering will take place.
+ *
+ * @return A <code>FullTextQuery</code> wrapping around the native Lucene wuery.
+ *
+ * @throws IllegalArgumentException if entityType is <code>null</code> or not a class or superclass annotated with <code>@Indexed</code>.
+ */
+ FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class<?>... entities);
+
+ /**
+ * Force the (re)indexing of a given <b>managed</b> object.
+ * Indexation is batched per transaction: if a transaction is active, the operation
+ * will not affect the index at least until commit.
+ *
+ * @param entity The entity to index - must not be <code>null</code>.
+ *
+ * @throws IllegalArgumentException if entity is null or not an @Indexed entity
+ */
+ <T> void index(T entity);
+
+ /**
+ * @return the <code>SearchFactory</code> instance.
+ */
+ SearchFactory getSearchFactory();
+
+ /**
+ * Remove the entity with the type <code>entityType</code> and the identifier <code>id</code> from the index.
+ * If <code>id == null</code> all indexed entities of this type and its indexed subclasses are deleted. In this
+ * case this method behaves like {@link #purgeAll(Class)}.
+ *
+ * @param entityType The type of the entity to delete.
+ * @param id The id of the entity to delete.
+ *
+ * @throws IllegalArgumentException if entityType is <code>null</code> or not a class or superclass annotated with <code>@Indexed</code>.
+ */
+ public <T> void purge(Class<T> entityType, Serializable id);
+
+ /**
+ * Remove all entities from of particular class and all its subclasses from the index.
+ *
+ * @param entityType The class of the entities to remove.
+ *
+ * @throws IllegalArgumentException if entityType is <code>null</code> or not a class or superclass annotated with <code>@Indexed</code>.
+ */
+ public <T> void purgeAll(Class<T> entityType);
+
+ /**
+ * Flush all index changes forcing Hibernate Search to apply all changes to the index not waiting for the batch limit.
+ */
+ public void flushToIndexes();
+
+ /**
+ * Creates a MassIndexer to rebuild the indexes of some
+ * or all indexed entity types.
+ * Instances cannot be reused.
+ * @param types optionally restrict the operation to selected types
+ * @return
+ */
+ public MassIndexer createIndexer(Class<?>... types);
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/MassIndexer.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/MassIndexer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/MassIndexer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search;
import java.util.concurrent.Future;
Modified: search/trunk/src/main/java/org/hibernate/search/ProjectionConstants.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/ProjectionConstants.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/ProjectionConstants.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search;
/**
Modified: search/trunk/src/main/java/org/hibernate/search/Search.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/Search.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/Search.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,34 +1,57 @@
-//$Id$
-package org.hibernate.search;
-
-import org.hibernate.Session;
-import org.hibernate.search.impl.FullTextSessionImpl;
-
-/**
- * Helper class to get a FullTextSession out of a regular session.
- *
- * @author Emmanuel Bernard
- * @author Hardy Ferentschik
- */
-public final class Search {
-
- private Search() {
- }
-
- public static FullTextSession getFullTextSession(Session session) {
- if (session instanceof FullTextSessionImpl) {
- return (FullTextSession) session;
- }
- else {
- return new FullTextSessionImpl(session);
- }
- }
-
- /**
- * @deprecated As of release 3.1.0, replaced by {@link #getFullTextSession(Session)}
- */
- @Deprecated
- public static FullTextSession createFullTextSession(Session session) {
- return getFullTextSession(session);
- }
-}
\ No newline at end of file
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search;
+
+import org.hibernate.Session;
+import org.hibernate.search.impl.FullTextSessionImpl;
+
+/**
+ * Helper class to get a FullTextSession out of a regular session.
+ *
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+public final class Search {
+
+ private Search() {
+ }
+
+ public static FullTextSession getFullTextSession(Session session) {
+ if (session instanceof FullTextSessionImpl) {
+ return (FullTextSession) session;
+ }
+ else {
+ return new FullTextSessionImpl(session);
+ }
+ }
+
+ /**
+ * @deprecated As of release 3.1.0, replaced by {@link #getFullTextSession(Session)}
+ */
+ @Deprecated
+ public static FullTextSession createFullTextSession(Session session) {
+ return getFullTextSession(session);
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/SearchException.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/SearchException.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/SearchException.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search;
/**
@@ -23,4 +46,4 @@
public SearchException(Throwable cause) {
super( cause );
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/main/java/org/hibernate/search/SearchFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/SearchFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/SearchFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search;
import org.apache.lucene.analysis.Analyzer;
Modified: search/trunk/src/main/java/org/hibernate/search/Version.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/Version.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/Version.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search;
import org.hibernate.search.util.LoggerFactory;
Modified: search/trunk/src/main/java/org/hibernate/search/analyzer/Discriminator.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/analyzer/Discriminator.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/analyzer/Discriminator.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.analyzer;
/**
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/Analyzer.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/Analyzer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/Analyzer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Retention;
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/AnalyzerDef.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/AnalyzerDef.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/AnalyzerDef.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Retention;
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/AnalyzerDefs.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/AnalyzerDefs.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/AnalyzerDefs.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Retention;
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/AnalyzerDiscriminator.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/AnalyzerDiscriminator.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/AnalyzerDiscriminator.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Retention;
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/Boost.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/Boost.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/Boost.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,43 @@
-//$Id$
-package org.hibernate.search.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();
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.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();
+}
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/ClassBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/ClassBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/ClassBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
@@ -65,4 +88,4 @@
*/
public Parameter[] params() default {};
-}
\ No newline at end of file
+}
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/ClassBridges.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/ClassBridges.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/ClassBridges.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
@@ -20,4 +43,4 @@
* this annotation.
*/
ClassBridge[] value() default {};
-}
\ No newline at end of file
+}
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/ContainedIn.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/ContainedIn.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/ContainedIn.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Retention;
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/DateBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/DateBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/DateBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,25 +1,48 @@
-//$Id$
-package org.hibernate.search.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.search.annotations.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?
-//TODO allow base timezone?
-public @interface DateBridge {
- Resolution resolution();
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.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.search.annotations.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?
+//TODO allow base timezone?
+public @interface DateBridge {
+ Resolution resolution();
+}
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/DocumentId.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/DocumentId.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/DocumentId.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,22 +1,45 @@
-//$Id$
-package org.hibernate.search.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.search.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 "";
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.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.search.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 "";
+}
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/DynamicBoost.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/DynamicBoost.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/DynamicBoost.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
@@ -26,4 +49,4 @@
* @see org.hibernate.search.engine.BoostStrategy
*/
public abstract Class<? extends BoostStrategy> impl();
-}
\ No newline at end of file
+}
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/Factory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/Factory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/Factory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Retention;
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/Field.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/Field.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/Field.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,62 +1,86 @@
-//$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.search.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
- * defaults to no.
- */
- Store store() default Store.NO;
-
- /**
- * Defines how the Field should be indexed
- * defaults to tokenized
- */
- Index index() default Index.TOKENIZED;
-
- /**
- * Define term vector storage requirements,
- * default to NO.
- */
- TermVector termVector() default TermVector.NO;
-
- /**
- * Define an analyzer for the field, default to
- * the inherited analyzer
- */
- Analyzer analyzer() default @Analyzer;
-
-
- /**
- * Boost factor, default 1
- */
- Boost boost() default @Boost( value = 1.0F );
-
- /**
- * Field bridge used. Default is autowired.
- */
- FieldBridge bridge() default @FieldBridge;
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+/**
+ * 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.search.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
+ * defaults to no.
+ */
+ Store store() default Store.NO;
+
+ /**
+ * Defines how the Field should be indexed
+ * defaults to tokenized
+ */
+ Index index() default Index.TOKENIZED;
+
+ /**
+ * Define term vector storage requirements,
+ * default to NO.
+ */
+ TermVector termVector() default TermVector.NO;
+
+ /**
+ * Define an analyzer for the field, default to
+ * the inherited analyzer
+ */
+ Analyzer analyzer() default @Analyzer;
+
+
+ /**
+ * Boost factor, default 1
+ */
+ Boost boost() default @Boost( value = 1.0F );
+
+ /**
+ * Field bridge used. Default is autowired.
+ */
+ FieldBridge bridge() default @FieldBridge;
+}
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/FieldBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/FieldBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/FieldBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,23 +1,46 @@
-//$Id$
-package org.hibernate.search.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;
-
-/**
- * specifies a given field bridge implementation
- *
- * @author Emmanuel Bernard
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( {ElementType.FIELD, ElementType.METHOD} )
-@Documented
-public @interface FieldBridge {
- //default to embed @FieldBridge in @Field
- public Class<?> impl() default void.class;
-
- public Parameter[] params() default {};
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.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;
+
+/**
+ * specifies a given field bridge implementation
+ *
+ * @author Emmanuel Bernard
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.FIELD, ElementType.METHOD} )
+@Documented
+public @interface FieldBridge {
+ //default to embed @FieldBridge in @Field
+ public Class<?> impl() default void.class;
+
+ public Parameter[] params() default {};
+}
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/Fields.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/Fields.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/Fields.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Retention;
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/FilterCacheModeType.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/FilterCacheModeType.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/FilterCacheModeType.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
/**
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/FullTextFilterDef.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/FullTextFilterDef.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/FullTextFilterDef.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Retention;
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/FullTextFilterDefs.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/FullTextFilterDefs.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/FullTextFilterDefs.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Retention;
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/Index.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/Index.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/Index.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,34 +1,57 @@
-//$Id$
-package org.hibernate.search.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_TOKENIZED,
- /**
- * 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
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.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_TOKENIZED,
+ /**
+ * 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
+}
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/Indexed.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/Indexed.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/Indexed.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,21 +1,44 @@
-//$Id$
-package org.hibernate.search.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 {
- /**
- * @return The filename of the index
- */
- String index() default "";
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.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 {
+ /**
+ * @return The filename of the index
+ */
+ String index() default "";
+}
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/IndexedEmbedded.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/IndexedEmbedded.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/IndexedEmbedded.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Retention;
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/Key.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/Key.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/Key.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Retention;
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/Parameter.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/Parameter.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/Parameter.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Target;
@@ -16,4 +39,4 @@
String name();
String value();
-}
\ No newline at end of file
+}
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/ProvidedId.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/ProvidedId.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/ProvidedId.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/Resolution.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/Resolution.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/Resolution.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,17 +1,40 @@
-//$Id$
-package org.hibernate.search.annotations;
-
-/**
- * Date indexing resolution.
- *
- * @author Emmanuel Bernard
- */
-public enum Resolution {
- YEAR,
- MONTH,
- DAY,
- HOUR,
- MINUTE,
- SECOND,
- MILLISECOND
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.annotations;
+
+/**
+ * Date indexing resolution.
+ *
+ * @author Emmanuel Bernard
+ */
+public enum Resolution {
+ YEAR,
+ MONTH,
+ DAY,
+ HOUR,
+ MINUTE,
+ SECOND,
+ MILLISECOND
+}
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/Similarity.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/Similarity.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/Similarity.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/Store.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/Store.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/Store.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,16 +1,39 @@
-//$Id$
-package org.hibernate.search.annotations;
-
-/**
- * Whether or not the value is stored in the document
- *
- * @author Emmanuel Bernard
- */
-public enum Store {
- /** does not store the value in the index */
- NO,
- /** stores the value in the index */
- YES,
- /** stores the value in the index in a compressed form */
- COMPRESS
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.annotations;
+
+/**
+ * Whether or not the value is stored in the document
+ *
+ * @author Emmanuel Bernard
+ */
+public enum Store {
+ /** does not store the value in the index */
+ NO,
+ /** stores the value in the index */
+ YES,
+ /** stores the value in the index in a compressed form */
+ COMPRESS
+}
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/TermVector.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/TermVector.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/TermVector.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
/**
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/TokenFilterDef.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/TokenFilterDef.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/TokenFilterDef.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
@@ -27,4 +50,4 @@
* @return Optional parameters passed to the <code>TokenFilterFactory</code>.
*/
public abstract Parameter[] params() default { };
-}
\ No newline at end of file
+}
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/TokenizerDef.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/TokenizerDef.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/TokenizerDef.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.annotations;
import java.lang.annotation.Retention;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/AddLuceneWork.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/AddLuceneWork.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/AddLuceneWork.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,44 +1,67 @@
-//$Id$
-package org.hibernate.search.backend;
-
-import java.io.Serializable;
-import java.util.Map;
-
-import org.apache.lucene.document.Document;
-
-/**
- * @author Emmanuel Bernard
- */
-public class AddLuceneWork extends LuceneWork implements Serializable {
-
- private static final long serialVersionUID = -2450349312813297371L;
-
- private final Map<String, String> fieldToAnalyzerMap;
-
- public AddLuceneWork(Serializable id, String idInString, Class entity, Document document) {
- this( id, idInString, entity, document, false );
- }
-
- public AddLuceneWork(Serializable id, String idInString, Class entity, Document document, boolean batch) {
- this( id, idInString, entity, document, null, batch );
- }
-
- public AddLuceneWork(Serializable id, String idInString, Class entity, Document document, Map<String, String> fieldToAnalyzerMap) {
- this( id, idInString, entity, document, fieldToAnalyzerMap, false );
- }
-
- public AddLuceneWork(Serializable id, String idInString, Class entity, Document document, Map<String, String> fieldToAnalyzerMap, boolean batch) {
- super( id, idInString, entity, document, batch );
- this.fieldToAnalyzerMap = fieldToAnalyzerMap;
- }
-
- public Map<String, String> getFieldToAnalyzerMap() {
- return fieldToAnalyzerMap;
- }
-
- @Override
- public <T> T getWorkDelegate(final WorkVisitor<T> visitor) {
- return visitor.getDelegate( this );
- }
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.apache.lucene.document.Document;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class AddLuceneWork extends LuceneWork implements Serializable {
+
+ private static final long serialVersionUID = -2450349312813297371L;
+
+ private final Map<String, String> fieldToAnalyzerMap;
+
+ public AddLuceneWork(Serializable id, String idInString, Class entity, Document document) {
+ this( id, idInString, entity, document, false );
+ }
+
+ public AddLuceneWork(Serializable id, String idInString, Class entity, Document document, boolean batch) {
+ this( id, idInString, entity, document, null, batch );
+ }
+
+ public AddLuceneWork(Serializable id, String idInString, Class entity, Document document, Map<String, String> fieldToAnalyzerMap) {
+ this( id, idInString, entity, document, fieldToAnalyzerMap, false );
+ }
+
+ public AddLuceneWork(Serializable id, String idInString, Class entity, Document document, Map<String, String> fieldToAnalyzerMap, boolean batch) {
+ super( id, idInString, entity, document, batch );
+ this.fieldToAnalyzerMap = fieldToAnalyzerMap;
+ }
+
+ public Map<String, String> getFieldToAnalyzerMap() {
+ return fieldToAnalyzerMap;
+ }
+
+ @Override
+ public <T> T getWorkDelegate(final WorkVisitor<T> visitor) {
+ return visitor.getDelegate( this );
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/BackendQueueProcessorFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/BackendQueueProcessorFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/BackendQueueProcessorFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend;
import java.util.Properties;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,22 +1,45 @@
-//$Id$
-package org.hibernate.search.backend;
-
-import java.io.Serializable;
-
-/**
- * @author Emmanuel Bernard
- */
-public class DeleteLuceneWork extends LuceneWork implements Serializable {
-
- private static final long serialVersionUID = -854604138119230246L;
-
- public DeleteLuceneWork(Serializable id, String idInString, Class entity) {
- super( id, idInString, entity );
- }
-
- @Override
- public <T> T getWorkDelegate(final WorkVisitor<T> visitor) {
- return visitor.getDelegate( this );
- }
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend;
+
+import java.io.Serializable;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class DeleteLuceneWork extends LuceneWork implements Serializable {
+
+ private static final long serialVersionUID = -854604138119230246L;
+
+ public DeleteLuceneWork(Serializable id, String idInString, Class entity) {
+ super( id, idInString, entity );
+ }
+
+ @Override
+ public <T> T getWorkDelegate(final WorkVisitor<T> visitor) {
+ return visitor.getDelegate( this );
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/LuceneIndexingParameters.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/LuceneIndexingParameters.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/LuceneIndexingParameters.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/LuceneWork.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/LuceneWork.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/LuceneWork.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,72 +1,95 @@
-//$Id$
-package org.hibernate.search.backend;
-
-import java.io.Serializable;
-
-import org.apache.lucene.document.Document;
-
-/**
- * Represent a Serializable Lucene unit work
- *
- * WARNING: This class aims to be serializable and passed in an asynchronous way across VMs
- * any non backward compatible serialization change should be done with great care
- * and publically announced. Specifically, new versions of Hibernate Search should be
- * able to handle changes produced by older versions of Hibernate Search if reasonably possible.
- * That is why each subclass susceptible to be pass along have a magic serialization number.
- * NOTE: we are relying on Lucene's Document to play nice unfortunately
- *
- * @author Emmanuel Bernard
- * @author Hardy Ferentschik
- * @author Sanne Grinovero
- */
-public abstract class LuceneWork implements Serializable {
-
- private final Document document;
- private final Class entityClass;
- private final Serializable id;
-
- /**
- * Flag indicating if this lucene work has to be indexed in batch mode.
- */
- private final boolean batch;
- private final String idInString;
-
- public LuceneWork(Serializable id, String idInString, Class entity) {
- this( id, idInString, entity, null );
- }
-
- public LuceneWork(Serializable id, String idInString, Class entity, Document document) {
- this( id, idInString, entity, document, false );
- }
-
- public LuceneWork(Serializable id, String idInString, Class entity, Document document, boolean batch) {
- this.id = id;
- this.idInString = idInString;
- this.entityClass = entity;
- this.document = document;
- this.batch = batch;
- }
-
- public boolean isBatch() {
- return batch;
- }
-
- public Document getDocument() {
- return document;
- }
-
- public Class getEntityClass() {
- return entityClass;
- }
-
- public Serializable getId() {
- return id;
- }
-
- public String getIdInString() {
- return idInString;
- }
-
- public abstract <T> T getWorkDelegate(WorkVisitor<T> visitor);
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend;
+
+import java.io.Serializable;
+
+import org.apache.lucene.document.Document;
+
+/**
+ * Represent a Serializable Lucene unit work
+ *
+ * WARNING: This class aims to be serializable and passed in an asynchronous way across VMs
+ * any non backward compatible serialization change should be done with great care
+ * and publically announced. Specifically, new versions of Hibernate Search should be
+ * able to handle changes produced by older versions of Hibernate Search if reasonably possible.
+ * That is why each subclass susceptible to be pass along have a magic serialization number.
+ * NOTE: we are relying on Lucene's Document to play nice unfortunately
+ *
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ * @author Sanne Grinovero
+ */
+public abstract class LuceneWork implements Serializable {
+
+ private final Document document;
+ private final Class entityClass;
+ private final Serializable id;
+
+ /**
+ * Flag indicating if this lucene work has to be indexed in batch mode.
+ */
+ private final boolean batch;
+ private final String idInString;
+
+ public LuceneWork(Serializable id, String idInString, Class entity) {
+ this( id, idInString, entity, null );
+ }
+
+ public LuceneWork(Serializable id, String idInString, Class entity, Document document) {
+ this( id, idInString, entity, document, false );
+ }
+
+ public LuceneWork(Serializable id, String idInString, Class entity, Document document, boolean batch) {
+ this.id = id;
+ this.idInString = idInString;
+ this.entityClass = entity;
+ this.document = document;
+ this.batch = batch;
+ }
+
+ public boolean isBatch() {
+ return batch;
+ }
+
+ public Document getDocument() {
+ return document;
+ }
+
+ public Class getEntityClass() {
+ return entityClass;
+ }
+
+ public Serializable getId() {
+ return id;
+ }
+
+ public String getIdInString() {
+ return idInString;
+ }
+
+ public abstract <T> T getWorkDelegate(WorkVisitor<T> visitor);
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/OptimizeLuceneWork.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/OptimizeLuceneWork.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/OptimizeLuceneWork.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/PurgeAllLuceneWork.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/PurgeAllLuceneWork.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/PurgeAllLuceneWork.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/QueueingProcessor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/QueueingProcessor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/QueueingProcessor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,40 +1,63 @@
-//$Id$
-package org.hibernate.search.backend;
-
-/**
- * Pile work operations
- * No thread safety has to be implemented, the queue being scoped already
- * The implementation must be "stateless" wrt the queue through (ie not store the queue state)
- *
- * FIXME this Interface does not make much sense, since the impl will not be changed
- *
- * @author Emmanuel Bernard
- */
-public interface QueueingProcessor {
- /**
- * Add a work
- * TODO move that somewhere else, it does not really fit here
- */
- void add(Work work, WorkQueue workQueue);
-
- /**
- * prepare resources for a later performWorks call
- */
- void prepareWorks(WorkQueue workQueue);
-
- /**
- * Execute works
- */
- void performWorks(WorkQueue workQueue);
-
- /**
- * Rollback works
- */
- void cancelWorks(WorkQueue workQueue);
-
- /**
- * clean resources
- * This method should log errors rather than raise an exception
- */
- void close();
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend;
+
+/**
+ * Pile work operations
+ * No thread safety has to be implemented, the queue being scoped already
+ * The implementation must be "stateless" wrt the queue through (ie not store the queue state)
+ *
+ * FIXME this Interface does not make much sense, since the impl will not be changed
+ *
+ * @author Emmanuel Bernard
+ */
+public interface QueueingProcessor {
+ /**
+ * Add a work
+ * TODO move that somewhere else, it does not really fit here
+ */
+ void add(Work work, WorkQueue workQueue);
+
+ /**
+ * prepare resources for a later performWorks call
+ */
+ void prepareWorks(WorkQueue workQueue);
+
+ /**
+ * Execute works
+ */
+ void performWorks(WorkQueue workQueue);
+
+ /**
+ * Rollback works
+ */
+ void cancelWorks(WorkQueue workQueue);
+
+ /**
+ * clean resources
+ * This method should log errors rather than raise an exception
+ */
+ void close();
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/TransactionContext.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/TransactionContext.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/TransactionContext.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend;
import javax.transaction.Synchronization;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/Work.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/Work.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/Work.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/WorkQueue.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/WorkQueue.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/WorkQueue.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend;
import java.util.List;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/WorkType.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/WorkType.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/WorkType.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend;
/**
Modified: search/trunk/src/main/java/org/hibernate/search/backend/WorkVisitor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/WorkVisitor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/WorkVisitor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend;
/**
Modified: search/trunk/src/main/java/org/hibernate/search/backend/Worker.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/Worker.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/Worker.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,32 +1,55 @@
-//$Id$
-package org.hibernate.search.backend;
-
-import java.util.Properties;
-
-import org.hibernate.search.engine.SearchFactoryImplementor;
-
-/**
- * Perform work for a given session. This implementation has to be multi threaded.
- *
- * @author Emmanuel Bernard
- */
-public interface Worker {
- //Use of EventSource since it's the common subinterface for Session and SessionImplementor
- //the alternative would have been to do a subcasting or to retrieve 2 parameters :(
- void performWork(Work work, TransactionContext transactionContext);
-
- void initialize(Properties props, SearchFactoryImplementor searchFactoryImplementor);
-
- /**
- * clean resources
- * This method can return exceptions
- */
- void close();
-
- /**
- * Flush any work queue.
- *
- * @param transactionContext the current transaction (context).
- */
- void flushWorks(TransactionContext transactionContext);
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend;
+
+import java.util.Properties;
+
+import org.hibernate.search.engine.SearchFactoryImplementor;
+
+/**
+ * Perform work for a given session. This implementation has to be multi threaded.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface Worker {
+ //Use of EventSource since it's the common subinterface for Session and SessionImplementor
+ //the alternative would have been to do a subcasting or to retrieve 2 parameters :(
+ void performWork(Work work, TransactionContext transactionContext);
+
+ void initialize(Properties props, SearchFactoryImplementor searchFactoryImplementor);
+
+ /**
+ * clean resources
+ * This method can return exceptions
+ */
+ void close();
+
+ /**
+ * Flush any work queue.
+ *
+ * @param transactionContext the current transaction (context).
+ */
+ void flushWorks(TransactionContext transactionContext);
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/WorkerFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/WorkerFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/WorkerFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,50 +1,73 @@
-//$Id$
-package org.hibernate.search.backend;
-
-import java.util.Map;
-import java.util.Properties;
-
-import org.hibernate.search.Environment;
-import org.hibernate.search.backend.impl.TransactionalWorker;
-import org.hibernate.search.cfg.SearchConfiguration;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.util.PluginLoader;
-import org.hibernate.util.StringHelper;
-
-/**
- * @author Emmanuel Bernard
- */
-public abstract class WorkerFactory {
-
- private static Properties getProperties(SearchConfiguration cfg) {
- Properties props = cfg.getProperties();
- Properties workerProperties = new Properties();
- for (Map.Entry entry : props.entrySet()) {
- String key = (String) entry.getKey();
- if ( key.startsWith( Environment.WORKER_PREFIX ) ) {
- //key.substring( Environment.WORKER_PREFIX.length() )
- workerProperties.setProperty( key, (String) entry.getValue() );
- }
- }
- return workerProperties;
- }
-
- public static Worker createWorker(SearchConfiguration cfg, SearchFactoryImplementor searchFactoryImplementor) {
- Properties props = getProperties( cfg );
- String impl = props.getProperty( Environment.WORKER_SCOPE );
- Worker worker;
- if ( StringHelper.isEmpty( impl ) ) {
- worker = new TransactionalWorker();
- }
- else if ( "transaction".equalsIgnoreCase( impl ) ) {
- worker = new TransactionalWorker();
- }
- else {
- worker = PluginLoader.instanceFromName( Worker.class,
- impl, WorkerFactory.class, "worker" );
- }
- worker.initialize( props, searchFactoryImplementor );
- return worker;
- }
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.hibernate.search.Environment;
+import org.hibernate.search.backend.impl.TransactionalWorker;
+import org.hibernate.search.cfg.SearchConfiguration;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.util.PluginLoader;
+import org.hibernate.util.StringHelper;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public abstract class WorkerFactory {
+
+ private static Properties getProperties(SearchConfiguration cfg) {
+ Properties props = cfg.getProperties();
+ Properties workerProperties = new Properties();
+ for (Map.Entry entry : props.entrySet()) {
+ String key = (String) entry.getKey();
+ if ( key.startsWith( Environment.WORKER_PREFIX ) ) {
+ //key.substring( Environment.WORKER_PREFIX.length() )
+ workerProperties.setProperty( key, (String) entry.getValue() );
+ }
+ }
+ return workerProperties;
+ }
+
+ public static Worker createWorker(SearchConfiguration cfg, SearchFactoryImplementor searchFactoryImplementor) {
+ Properties props = getProperties( cfg );
+ String impl = props.getProperty( Environment.WORKER_SCOPE );
+ Worker worker;
+ if ( StringHelper.isEmpty( impl ) ) {
+ worker = new TransactionalWorker();
+ }
+ else if ( "transaction".equalsIgnoreCase( impl ) ) {
+ worker = new TransactionalWorker();
+ }
+ else {
+ worker = PluginLoader.instanceFromName( Worker.class,
+ impl, WorkerFactory.class, "worker" );
+ }
+ worker.initialize( props, searchFactoryImplementor );
+ return worker;
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/Workspace.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/Workspace.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/Workspace.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,190 +1,213 @@
-//$Id$
-package org.hibernate.search.backend;
-
-import java.io.IOException;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.SimpleAnalyzer;
-import org.apache.lucene.index.IndexWriter;
-import org.slf4j.Logger;
-
-import org.hibernate.search.SearchException;
-import org.hibernate.search.SearchFactory;
-import org.hibernate.search.engine.DocumentBuilderIndexedEntity;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.store.DirectoryProvider;
-import org.hibernate.search.store.optimization.OptimizerStrategy;
-import org.hibernate.search.util.LoggerFactory;
-
-/**
- * Lucene workspace for a DirectoryProvider.<p/>
- * Before using {@link #getIndexWriter} the lock must be acquired,
- * and resources must be closed before releasing the lock.
- *
- * @author Emmanuel Bernard
- * @author Hardy Ferentschik
- * @author Sanne Grinovero
- */
-//TODO renaming to "DirectoryWorkspace" would be nice.
-public class Workspace {
-
- private static final Logger log = LoggerFactory.make();
- private static final Analyzer SIMPLE_ANALYZER = new SimpleAnalyzer();
- private static final IndexWriter.MaxFieldLength maxFieldLength =
- new IndexWriter.MaxFieldLength( IndexWriter.DEFAULT_MAX_FIELD_LENGTH );
-
- // invariant state:
-
- private final SearchFactoryImplementor searchFactoryImplementor;
- private final DirectoryProvider<?> directoryProvider;
- private final OptimizerStrategy optimizerStrategy;
- private final ReentrantLock lock;
- private final Set<Class<?>> entitiesInDirectory;
- private final LuceneIndexingParameters indexingParams;
-
- // variable state:
-
- /**
- * Current open IndexWriter, or null when closed. Guarded by synchronization.
- */
- private IndexWriter writer;
-
- /**
- * Keeps a count of modification operations done on the index.
- */
- private final AtomicLong operations = new AtomicLong( 0L );
-
- public Workspace(SearchFactoryImplementor searchFactoryImplementor, DirectoryProvider<?> provider) {
- this.searchFactoryImplementor = searchFactoryImplementor;
- this.directoryProvider = provider;
- this.optimizerStrategy = searchFactoryImplementor.getOptimizerStrategy( directoryProvider );
- this.entitiesInDirectory = searchFactoryImplementor.getClassesInDirectoryProvider( provider );
- this.indexingParams = searchFactoryImplementor.getIndexingParameters( directoryProvider );
- this.lock = searchFactoryImplementor.getDirectoryProviderLock( provider );
- }
-
- public <T> DocumentBuilderIndexedEntity<T> getDocumentBuilder(Class<T> entity) {
- return searchFactoryImplementor.getDocumentBuilderIndexedEntity( entity );
- }
-
- public Analyzer getAnalyzer(String name) {
- return searchFactoryImplementor.getAnalyzer( name );
- }
-
- /**
- * If optimization has not been forced give a chance to configured OptimizerStrategy
- * to optimize the index.
- */
- public void optimizerPhase() {
- lock.lock();
- try {
- // used getAndSet(0) because Workspace is going to be reused by next transaction.
- synchronized ( optimizerStrategy ) {
- optimizerStrategy.addTransaction( operations.getAndSet( 0L ) );
- optimizerStrategy.optimize( this );
- }
- }
- finally {
- lock.unlock();
- }
- }
-
- /**
- * Used by OptimizeLuceneWork after index optimization to flag that
- * optimization has been forced.
- * @see OptimizeLuceneWork
- * @see SearchFactory#optimize()
- * @see SearchFactory#optimize(Class)
- */
- public void optimize() {
- lock.lock();
- try {
- //Needs to ensure the optimizerStrategy is accessed in threadsafe way
- synchronized (optimizerStrategy) {
- optimizerStrategy.optimizationForced();
- }
- }
- finally {
- lock.unlock();
- }
- }
-
- /**
- * Gets the IndexWriter, opening one if needed.
- * @param batchmode when true the indexWriter settings for batch mode will be applied.
- * Ignored if IndexWriter is open already.
- * @throws SearchException on a IOException during index opening.
- * @return a new IndexWriter or one already open.
- */
- public synchronized IndexWriter getIndexWriter(boolean batchmode) {
- if ( writer != null )
- return writer;
- try {
- writer = new IndexWriter( directoryProvider.getDirectory(), SIMPLE_ANALYZER, false, maxFieldLength ); // has been created at init time
- indexingParams.applyToWriter( writer, batchmode );
- log.trace( "IndexWriter opened" );
- }
- catch ( IOException e ) {
- writer = null;
- throw new SearchException( "Unable to open IndexWriter", e );
- }
- return writer;
- }
-
- /**
- * Commits changes to a previously opened IndexWriter.
- *
- * @throws SearchException on IOException during Lucene close operation,
- * or if there is no IndexWriter to close.
- */
- public synchronized void commitIndexWriter() {
- if ( writer != null ) {
- try {
- writer.commit();
- log.trace( "Index changes commited." );
- }
- catch ( IOException e ) {
- throw new SearchException( "Exception while commiting index changes", e );
- }
- }
- }
-
- /**
- * Closes a previously opened IndexWriter.
- * @throws SearchException on IOException during Lucene close operation
- */
- public synchronized void closeIndexWriter() {
- IndexWriter toClose = writer;
- writer = null;
- if ( toClose != null ) {
- try {
- toClose.close();
- log.trace( "IndexWriter closed" );
- }
- catch ( IOException e ) {
- throw new SearchException( "Exception while closing IndexWriter", e );
- }
- }
- }
-
- /**
- * Increment the counter of modification operations done on the index.
- * Used (currently only) by the OptimizerStrategy.
- * @param modCount the increment to add to the counter.
- */
- public void incrementModificationCounter(int modCount) {
- operations.addAndGet( modCount );
- }
-
- /**
- * @return The unmodifiable set of entity types being indexed
- * in the underlying Lucene Directory backing this Workspace.
- */
- public Set<Class<?>> getEntitiesInDirectory() {
- return entitiesInDirectory;
- }
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend;
+
+import java.io.IOException;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.SimpleAnalyzer;
+import org.apache.lucene.index.IndexWriter;
+import org.slf4j.Logger;
+
+import org.hibernate.search.SearchException;
+import org.hibernate.search.SearchFactory;
+import org.hibernate.search.engine.DocumentBuilderIndexedEntity;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.store.optimization.OptimizerStrategy;
+import org.hibernate.search.util.LoggerFactory;
+
+/**
+ * Lucene workspace for a DirectoryProvider.<p/>
+ * Before using {@link #getIndexWriter} the lock must be acquired,
+ * and resources must be closed before releasing the lock.
+ *
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ * @author Sanne Grinovero
+ */
+//TODO renaming to "DirectoryWorkspace" would be nice.
+public class Workspace {
+
+ private static final Logger log = LoggerFactory.make();
+ private static final Analyzer SIMPLE_ANALYZER = new SimpleAnalyzer();
+ private static final IndexWriter.MaxFieldLength maxFieldLength =
+ new IndexWriter.MaxFieldLength( IndexWriter.DEFAULT_MAX_FIELD_LENGTH );
+
+ // invariant state:
+
+ private final SearchFactoryImplementor searchFactoryImplementor;
+ private final DirectoryProvider<?> directoryProvider;
+ private final OptimizerStrategy optimizerStrategy;
+ private final ReentrantLock lock;
+ private final Set<Class<?>> entitiesInDirectory;
+ private final LuceneIndexingParameters indexingParams;
+
+ // variable state:
+
+ /**
+ * Current open IndexWriter, or null when closed. Guarded by synchronization.
+ */
+ private IndexWriter writer;
+
+ /**
+ * Keeps a count of modification operations done on the index.
+ */
+ private final AtomicLong operations = new AtomicLong( 0L );
+
+ public Workspace(SearchFactoryImplementor searchFactoryImplementor, DirectoryProvider<?> provider) {
+ this.searchFactoryImplementor = searchFactoryImplementor;
+ this.directoryProvider = provider;
+ this.optimizerStrategy = searchFactoryImplementor.getOptimizerStrategy( directoryProvider );
+ this.entitiesInDirectory = searchFactoryImplementor.getClassesInDirectoryProvider( provider );
+ this.indexingParams = searchFactoryImplementor.getIndexingParameters( directoryProvider );
+ this.lock = searchFactoryImplementor.getDirectoryProviderLock( provider );
+ }
+
+ public <T> DocumentBuilderIndexedEntity<T> getDocumentBuilder(Class<T> entity) {
+ return searchFactoryImplementor.getDocumentBuilderIndexedEntity( entity );
+ }
+
+ public Analyzer getAnalyzer(String name) {
+ return searchFactoryImplementor.getAnalyzer( name );
+ }
+
+ /**
+ * If optimization has not been forced give a chance to configured OptimizerStrategy
+ * to optimize the index.
+ */
+ public void optimizerPhase() {
+ lock.lock();
+ try {
+ // used getAndSet(0) because Workspace is going to be reused by next transaction.
+ synchronized ( optimizerStrategy ) {
+ optimizerStrategy.addTransaction( operations.getAndSet( 0L ) );
+ optimizerStrategy.optimize( this );
+ }
+ }
+ finally {
+ lock.unlock();
+ }
+ }
+
+ /**
+ * Used by OptimizeLuceneWork after index optimization to flag that
+ * optimization has been forced.
+ * @see OptimizeLuceneWork
+ * @see SearchFactory#optimize()
+ * @see SearchFactory#optimize(Class)
+ */
+ public void optimize() {
+ lock.lock();
+ try {
+ //Needs to ensure the optimizerStrategy is accessed in threadsafe way
+ synchronized (optimizerStrategy) {
+ optimizerStrategy.optimizationForced();
+ }
+ }
+ finally {
+ lock.unlock();
+ }
+ }
+
+ /**
+ * Gets the IndexWriter, opening one if needed.
+ * @param batchmode when true the indexWriter settings for batch mode will be applied.
+ * Ignored if IndexWriter is open already.
+ * @throws SearchException on a IOException during index opening.
+ * @return a new IndexWriter or one already open.
+ */
+ public synchronized IndexWriter getIndexWriter(boolean batchmode) {
+ if ( writer != null )
+ return writer;
+ try {
+ writer = new IndexWriter( directoryProvider.getDirectory(), SIMPLE_ANALYZER, false, maxFieldLength ); // has been created at init time
+ indexingParams.applyToWriter( writer, batchmode );
+ log.trace( "IndexWriter opened" );
+ }
+ catch ( IOException e ) {
+ writer = null;
+ throw new SearchException( "Unable to open IndexWriter", e );
+ }
+ return writer;
+ }
+
+ /**
+ * Commits changes to a previously opened IndexWriter.
+ *
+ * @throws SearchException on IOException during Lucene close operation,
+ * or if there is no IndexWriter to close.
+ */
+ public synchronized void commitIndexWriter() {
+ if ( writer != null ) {
+ try {
+ writer.commit();
+ log.trace( "Index changes commited." );
+ }
+ catch ( IOException e ) {
+ throw new SearchException( "Exception while commiting index changes", e );
+ }
+ }
+ }
+
+ /**
+ * Closes a previously opened IndexWriter.
+ * @throws SearchException on IOException during Lucene close operation
+ */
+ public synchronized void closeIndexWriter() {
+ IndexWriter toClose = writer;
+ writer = null;
+ if ( toClose != null ) {
+ try {
+ toClose.close();
+ log.trace( "IndexWriter closed" );
+ }
+ catch ( IOException e ) {
+ throw new SearchException( "Exception while closing IndexWriter", e );
+ }
+ }
+ }
+
+ /**
+ * Increment the counter of modification operations done on the index.
+ * Used (currently only) by the OptimizerStrategy.
+ * @param modCount the increment to add to the counter.
+ */
+ public void incrementModificationCounter(int modCount) {
+ operations.addAndGet( modCount );
+ }
+
+ /**
+ * @return The unmodifiable set of entity types being indexed
+ * in the underlying Lucene Directory backing this Workspace.
+ */
+ public Set<Class<?>> getEntitiesInDirectory() {
+ return entitiesInDirectory;
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/configuration/ConfigurationParseHelper.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/configuration/ConfigurationParseHelper.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/configuration/ConfigurationParseHelper.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.configuration;
import java.util.Properties;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/configuration/IndexWriterSetting.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/configuration/IndexWriterSetting.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/configuration/IndexWriterSetting.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.configuration;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/configuration/MaskedProperty.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/configuration/MaskedProperty.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/configuration/MaskedProperty.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.configuration;
import java.io.IOException;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,217 +1,240 @@
-//$Id$
-package org.hibernate.search.backend.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import org.slf4j.Logger;
-
-import org.hibernate.Hibernate;
-import org.hibernate.util.StringHelper;
-import org.hibernate.search.Environment;
-import org.hibernate.search.backend.BackendQueueProcessorFactory;
-import org.hibernate.search.backend.LuceneWork;
-import org.hibernate.search.backend.QueueingProcessor;
-import org.hibernate.search.backend.Work;
-import org.hibernate.search.backend.WorkQueue;
-import org.hibernate.search.backend.WorkType;
-import org.hibernate.search.backend.configuration.ConfigurationParseHelper;
-import org.hibernate.search.backend.impl.blackhole.BlackHoleBackendQueueProcessorFactory;
-import org.hibernate.search.backend.impl.jgroups.MasterJGroupsBackendQueueProcessorFactory;
-import org.hibernate.search.backend.impl.jgroups.SlaveJGroupsBackendQueueProcessorFactory;
-import org.hibernate.search.backend.impl.jms.JMSBackendQueueProcessorFactory;
-import org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessorFactory;
-import org.hibernate.search.engine.DocumentBuilderIndexedEntity;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.engine.DocumentBuilderContainedEntity;
-import org.hibernate.search.util.LoggerFactory;
-import org.hibernate.search.util.PluginLoader;
-
-/**
- * Batch work until {@link #performWorks} is called.
- * The work is then executed synchronously or asynchronously.
- *
- * @author Emmanuel Bernard
- */
-public class BatchedQueueingProcessor implements QueueingProcessor {
-
- private static final Logger log = LoggerFactory.make();
-
- private final boolean sync;
- private final int batchSize;
- private final ExecutorService executorService;
- private final BackendQueueProcessorFactory backendQueueProcessorFactory;
- private final SearchFactoryImplementor searchFactoryImplementor;
-
- public BatchedQueueingProcessor(SearchFactoryImplementor searchFactoryImplementor, Properties properties) {
- this.searchFactoryImplementor = searchFactoryImplementor;
- this.sync = isConfiguredAsSync( properties );
-
- //default to a simple asynchronous operation
- int min = ConfigurationParseHelper.getIntValue( properties, Environment.WORKER_THREADPOOL_SIZE, 1 );
- //no queue limit
- int queueSize = ConfigurationParseHelper.getIntValue(
- properties, Environment.WORKER_WORKQUEUE_SIZE, Integer.MAX_VALUE
- );
-
- batchSize = ConfigurationParseHelper.getIntValue( properties, Environment.WORKER_BATCHSIZE, 0 );
-
- if ( !sync ) {
- /**
- * choose min = max with a sizable queue to be able to
- * actually queue operations
- * The locking mechanism preventing much of the scalability
- * anyway, the idea is really to have a buffer
- * If the queue limit is reached, the operation is executed by the main thread
- */
- executorService = new ThreadPoolExecutor(
- min, min, 60, TimeUnit.SECONDS,
- new LinkedBlockingQueue<Runnable>( queueSize ),
- new ThreadPoolExecutor.CallerRunsPolicy()
- );
- }
- else {
- executorService = null;
- }
- String backend = properties.getProperty( Environment.WORKER_BACKEND );
- if ( StringHelper.isEmpty( backend ) || "lucene".equalsIgnoreCase( backend ) ) {
- backendQueueProcessorFactory = new LuceneBackendQueueProcessorFactory();
- }
- else if ( "jms".equalsIgnoreCase( backend ) ) {
- backendQueueProcessorFactory = new JMSBackendQueueProcessorFactory();
- }
- else if ( "blackhole".equalsIgnoreCase( backend ) ) {
- backendQueueProcessorFactory = new BlackHoleBackendQueueProcessorFactory();
- }
- else if ( "jgroupsMaster".equals( backend ) ) {
- backendQueueProcessorFactory = new MasterJGroupsBackendQueueProcessorFactory();
- }
- else if ( "jgroupsSlave".equals( backend ) ) {
- backendQueueProcessorFactory = new SlaveJGroupsBackendQueueProcessorFactory();
- }
- else {
- backendQueueProcessorFactory = PluginLoader.instanceFromName( BackendQueueProcessorFactory.class,
- backend, BatchedQueueingProcessor.class, "processor" );
- }
- backendQueueProcessorFactory.initialize( properties, searchFactoryImplementor );
- searchFactoryImplementor.setBackendQueueProcessorFactory( backendQueueProcessorFactory );
- }
-
- public void add(Work work, WorkQueue workQueue) {
- //don't check for builder it's done in prepareWork
- //FIXME WorkType.COLLECTION does not play well with batchSize
- workQueue.add( work );
- if ( batchSize > 0 && workQueue.size() >= batchSize ) {
- WorkQueue subQueue = workQueue.splitQueue();
- prepareWorks( subQueue );
- performWorks( subQueue );
- }
- }
-
- public void prepareWorks(WorkQueue workQueue) {
- List<Work> queue = workQueue.getQueue();
- int initialSize = queue.size();
- List<LuceneWork> luceneQueue = new ArrayList<LuceneWork>( initialSize ); //TODO load factor for containedIn
- /**
- * Collection work type are process second, so if the owner entity has already been processed for whatever reason
- * the work will be ignored.
- * However if the owner entity has not been processed, an "UPDATE" work is executed
- *
- * Processing collection works last is mandatory to avoid reindexing a object to be deleted
- */
- processWorkByLayer( queue, initialSize, luceneQueue, Layer.FIRST );
- processWorkByLayer( queue, initialSize, luceneQueue, Layer.SECOND );
- workQueue.setSealedQueue( luceneQueue );
- }
-
- private <T> void processWorkByLayer(List<Work> queue, int initialSize, List<LuceneWork> luceneQueue, Layer layer) {
- for ( int i = 0; i < initialSize; i++ ) {
- @SuppressWarnings("unchecked")
- Work<T> work = queue.get( i );
- if ( work != null ) {
- if ( layer.isRightLayer( work.getType() ) ) {
- queue.set( i, null ); // help GC and avoid 2 loaded queues in memory
- addWorkToBuilderQueue( luceneQueue, work );
- }
- }
- }
- }
-
- private <T> void addWorkToBuilderQueue(List<LuceneWork> luceneQueue, Work<T> work) {
- @SuppressWarnings("unchecked")
- Class<T> entityClass = work.getEntityClass() != null ?
- work.getEntityClass() :
- Hibernate.getClass( work.getEntity() );
- DocumentBuilderIndexedEntity<T> entityBuilder = searchFactoryImplementor.getDocumentBuilderIndexedEntity( entityClass );
- if ( entityBuilder != null ) {
- entityBuilder.addWorkToQueue(
- entityClass, work.getEntity(), work.getId(), work.getType(), luceneQueue, searchFactoryImplementor
- );
- return;
- }
-
- //might be a entity contained in
- DocumentBuilderContainedEntity<T> containedInBuilder = searchFactoryImplementor.getDocumentBuilderContainedEntity( entityClass );
- if ( containedInBuilder != null ) {
- containedInBuilder.addWorkToQueue(
- entityClass, work.getEntity(), work.getId(), work.getType(), luceneQueue, searchFactoryImplementor
- );
- }
- }
-
- public void performWorks(WorkQueue workQueue) {
- Runnable processor = backendQueueProcessorFactory.getProcessor( workQueue.getSealedQueue() );
- if ( sync ) {
- processor.run();
- }
- else {
- executorService.execute( processor );
- }
- }
-
- public void cancelWorks(WorkQueue workQueue) {
- workQueue.clear();
- }
-
- public void close() {
- //gracefully stop
- if ( executorService != null && !executorService.isShutdown() ) {
- executorService.shutdown();
- try {
- executorService.awaitTermination( Long.MAX_VALUE, TimeUnit.SECONDS );
- }
- catch ( InterruptedException e ) {
- log.error( "Unable to properly shut down asynchronous indexing work", e );
- }
- }
- //and stop the backend
- backendQueueProcessorFactory.close();
- }
-
- private static enum Layer {
- FIRST,
- SECOND;
-
- public boolean isRightLayer(WorkType type) {
- if ( this == FIRST && type != WorkType.COLLECTION ) {
- return true;
- }
- return this == SECOND && type == WorkType.COLLECTION;
- }
- }
-
- /**
- * @param properties the configuration to parse
- * @return true if the configuration uses sync indexing
- */
- public static boolean isConfiguredAsSync(Properties properties){
- //default to sync if none defined
- return !"async".equalsIgnoreCase( properties.getProperty( Environment.WORKER_EXECUTION ) );
- }
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.slf4j.Logger;
+
+import org.hibernate.Hibernate;
+import org.hibernate.util.StringHelper;
+import org.hibernate.search.Environment;
+import org.hibernate.search.backend.BackendQueueProcessorFactory;
+import org.hibernate.search.backend.LuceneWork;
+import org.hibernate.search.backend.QueueingProcessor;
+import org.hibernate.search.backend.Work;
+import org.hibernate.search.backend.WorkQueue;
+import org.hibernate.search.backend.WorkType;
+import org.hibernate.search.backend.configuration.ConfigurationParseHelper;
+import org.hibernate.search.backend.impl.blackhole.BlackHoleBackendQueueProcessorFactory;
+import org.hibernate.search.backend.impl.jgroups.MasterJGroupsBackendQueueProcessorFactory;
+import org.hibernate.search.backend.impl.jgroups.SlaveJGroupsBackendQueueProcessorFactory;
+import org.hibernate.search.backend.impl.jms.JMSBackendQueueProcessorFactory;
+import org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessorFactory;
+import org.hibernate.search.engine.DocumentBuilderIndexedEntity;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.engine.DocumentBuilderContainedEntity;
+import org.hibernate.search.util.LoggerFactory;
+import org.hibernate.search.util.PluginLoader;
+
+/**
+ * Batch work until {@link #performWorks} is called.
+ * The work is then executed synchronously or asynchronously.
+ *
+ * @author Emmanuel Bernard
+ */
+public class BatchedQueueingProcessor implements QueueingProcessor {
+
+ private static final Logger log = LoggerFactory.make();
+
+ private final boolean sync;
+ private final int batchSize;
+ private final ExecutorService executorService;
+ private final BackendQueueProcessorFactory backendQueueProcessorFactory;
+ private final SearchFactoryImplementor searchFactoryImplementor;
+
+ public BatchedQueueingProcessor(SearchFactoryImplementor searchFactoryImplementor, Properties properties) {
+ this.searchFactoryImplementor = searchFactoryImplementor;
+ this.sync = isConfiguredAsSync( properties );
+
+ //default to a simple asynchronous operation
+ int min = ConfigurationParseHelper.getIntValue( properties, Environment.WORKER_THREADPOOL_SIZE, 1 );
+ //no queue limit
+ int queueSize = ConfigurationParseHelper.getIntValue(
+ properties, Environment.WORKER_WORKQUEUE_SIZE, Integer.MAX_VALUE
+ );
+
+ batchSize = ConfigurationParseHelper.getIntValue( properties, Environment.WORKER_BATCHSIZE, 0 );
+
+ if ( !sync ) {
+ /**
+ * choose min = max with a sizable queue to be able to
+ * actually queue operations
+ * The locking mechanism preventing much of the scalability
+ * anyway, the idea is really to have a buffer
+ * If the queue limit is reached, the operation is executed by the main thread
+ */
+ executorService = new ThreadPoolExecutor(
+ min, min, 60, TimeUnit.SECONDS,
+ new LinkedBlockingQueue<Runnable>( queueSize ),
+ new ThreadPoolExecutor.CallerRunsPolicy()
+ );
+ }
+ else {
+ executorService = null;
+ }
+ String backend = properties.getProperty( Environment.WORKER_BACKEND );
+ if ( StringHelper.isEmpty( backend ) || "lucene".equalsIgnoreCase( backend ) ) {
+ backendQueueProcessorFactory = new LuceneBackendQueueProcessorFactory();
+ }
+ else if ( "jms".equalsIgnoreCase( backend ) ) {
+ backendQueueProcessorFactory = new JMSBackendQueueProcessorFactory();
+ }
+ else if ( "blackhole".equalsIgnoreCase( backend ) ) {
+ backendQueueProcessorFactory = new BlackHoleBackendQueueProcessorFactory();
+ }
+ else if ( "jgroupsMaster".equals( backend ) ) {
+ backendQueueProcessorFactory = new MasterJGroupsBackendQueueProcessorFactory();
+ }
+ else if ( "jgroupsSlave".equals( backend ) ) {
+ backendQueueProcessorFactory = new SlaveJGroupsBackendQueueProcessorFactory();
+ }
+ else {
+ backendQueueProcessorFactory = PluginLoader.instanceFromName( BackendQueueProcessorFactory.class,
+ backend, BatchedQueueingProcessor.class, "processor" );
+ }
+ backendQueueProcessorFactory.initialize( properties, searchFactoryImplementor );
+ searchFactoryImplementor.setBackendQueueProcessorFactory( backendQueueProcessorFactory );
+ }
+
+ public void add(Work work, WorkQueue workQueue) {
+ //don't check for builder it's done in prepareWork
+ //FIXME WorkType.COLLECTION does not play well with batchSize
+ workQueue.add( work );
+ if ( batchSize > 0 && workQueue.size() >= batchSize ) {
+ WorkQueue subQueue = workQueue.splitQueue();
+ prepareWorks( subQueue );
+ performWorks( subQueue );
+ }
+ }
+
+ public void prepareWorks(WorkQueue workQueue) {
+ List<Work> queue = workQueue.getQueue();
+ int initialSize = queue.size();
+ List<LuceneWork> luceneQueue = new ArrayList<LuceneWork>( initialSize ); //TODO load factor for containedIn
+ /**
+ * Collection work type are process second, so if the owner entity has already been processed for whatever reason
+ * the work will be ignored.
+ * However if the owner entity has not been processed, an "UPDATE" work is executed
+ *
+ * Processing collection works last is mandatory to avoid reindexing a object to be deleted
+ */
+ processWorkByLayer( queue, initialSize, luceneQueue, Layer.FIRST );
+ processWorkByLayer( queue, initialSize, luceneQueue, Layer.SECOND );
+ workQueue.setSealedQueue( luceneQueue );
+ }
+
+ private <T> void processWorkByLayer(List<Work> queue, int initialSize, List<LuceneWork> luceneQueue, Layer layer) {
+ for ( int i = 0; i < initialSize; i++ ) {
+ @SuppressWarnings("unchecked")
+ Work<T> work = queue.get( i );
+ if ( work != null ) {
+ if ( layer.isRightLayer( work.getType() ) ) {
+ queue.set( i, null ); // help GC and avoid 2 loaded queues in memory
+ addWorkToBuilderQueue( luceneQueue, work );
+ }
+ }
+ }
+ }
+
+ private <T> void addWorkToBuilderQueue(List<LuceneWork> luceneQueue, Work<T> work) {
+ @SuppressWarnings("unchecked")
+ Class<T> entityClass = work.getEntityClass() != null ?
+ work.getEntityClass() :
+ Hibernate.getClass( work.getEntity() );
+ DocumentBuilderIndexedEntity<T> entityBuilder = searchFactoryImplementor.getDocumentBuilderIndexedEntity( entityClass );
+ if ( entityBuilder != null ) {
+ entityBuilder.addWorkToQueue(
+ entityClass, work.getEntity(), work.getId(), work.getType(), luceneQueue, searchFactoryImplementor
+ );
+ return;
+ }
+
+ //might be a entity contained in
+ DocumentBuilderContainedEntity<T> containedInBuilder = searchFactoryImplementor.getDocumentBuilderContainedEntity( entityClass );
+ if ( containedInBuilder != null ) {
+ containedInBuilder.addWorkToQueue(
+ entityClass, work.getEntity(), work.getId(), work.getType(), luceneQueue, searchFactoryImplementor
+ );
+ }
+ }
+
+ public void performWorks(WorkQueue workQueue) {
+ Runnable processor = backendQueueProcessorFactory.getProcessor( workQueue.getSealedQueue() );
+ if ( sync ) {
+ processor.run();
+ }
+ else {
+ executorService.execute( processor );
+ }
+ }
+
+ public void cancelWorks(WorkQueue workQueue) {
+ workQueue.clear();
+ }
+
+ public void close() {
+ //gracefully stop
+ if ( executorService != null && !executorService.isShutdown() ) {
+ executorService.shutdown();
+ try {
+ executorService.awaitTermination( Long.MAX_VALUE, TimeUnit.SECONDS );
+ }
+ catch ( InterruptedException e ) {
+ log.error( "Unable to properly shut down asynchronous indexing work", e );
+ }
+ }
+ //and stop the backend
+ backendQueueProcessorFactory.close();
+ }
+
+ private static enum Layer {
+ FIRST,
+ SECOND;
+
+ public boolean isRightLayer(WorkType type) {
+ if ( this == FIRST && type != WorkType.COLLECTION ) {
+ return true;
+ }
+ return this == SECOND && type == WorkType.COLLECTION;
+ }
+ }
+
+ /**
+ * @param properties the configuration to parse
+ * @return true if the configuration uses sync indexing
+ */
+ public static boolean isConfiguredAsSync(Properties properties){
+ //default to sync if none defined
+ return !"async".equalsIgnoreCase( properties.getProperty( Environment.WORKER_EXECUTION ) );
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/EventSourceTransactionContext.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/EventSourceTransactionContext.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/EventSourceTransactionContext.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/PostTransactionWorkQueueSynchronization.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/PostTransactionWorkQueueSynchronization.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/PostTransactionWorkQueueSynchronization.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,72 +1,95 @@
-//$Id$
-package org.hibernate.search.backend.impl;
-
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-
-import org.hibernate.search.backend.QueueingProcessor;
-import org.hibernate.search.backend.Work;
-import org.hibernate.search.backend.WorkQueue;
-import org.hibernate.search.util.WeakIdentityHashMap;
-
-/**
- * Execute some work inside a transaction synchronization
- *
- * @author Emmanuel Bernard
- */
-public class PostTransactionWorkQueueSynchronization implements Synchronization {
-
- /**
- * FullTextIndexEventListener is using a WeakIdentityHashMap<Session,Synchronization>
- * So make sure all Synchronization implementations don't have any
- * (direct or indirect) reference to the Session.
- */
-
- private final QueueingProcessor queueingProcessor;
- private boolean consumed;
- private final WeakIdentityHashMap queuePerTransaction;
- private WorkQueue queue = new WorkQueue();
-
- /**
- * in transaction work
- */
- public PostTransactionWorkQueueSynchronization(QueueingProcessor queueingProcessor, WeakIdentityHashMap queuePerTransaction) {
- this.queueingProcessor = queueingProcessor;
- this.queuePerTransaction = queuePerTransaction;
- }
-
- public void add(Work work) {
- queueingProcessor.add( work, queue );
- }
-
- public boolean isConsumed() {
- return consumed;
- }
-
- public void beforeCompletion() {
- queueingProcessor.prepareWorks(queue);
- }
-
- public void afterCompletion(int i) {
- try {
- if ( Status.STATUS_COMMITTED == i ) {
- queueingProcessor.performWorks(queue);
- }
- else {
- queueingProcessor.cancelWorks(queue);
- }
- }
- finally {
- consumed = true;
- //clean the Synchronization per Transaction
- //not needed stricto sensus but a cleaner approach and faster than the GC
- if (queuePerTransaction != null) queuePerTransaction.removeValue( this );
- }
- }
-
- public void flushWorks() {
- WorkQueue subQueue = queue.splitQueue();
- queueingProcessor.prepareWorks( subQueue );
- queueingProcessor.performWorks( subQueue );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend.impl;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+
+import org.hibernate.search.backend.QueueingProcessor;
+import org.hibernate.search.backend.Work;
+import org.hibernate.search.backend.WorkQueue;
+import org.hibernate.search.util.WeakIdentityHashMap;
+
+/**
+ * Execute some work inside a transaction synchronization
+ *
+ * @author Emmanuel Bernard
+ */
+public class PostTransactionWorkQueueSynchronization implements Synchronization {
+
+ /**
+ * FullTextIndexEventListener is using a WeakIdentityHashMap<Session,Synchronization>
+ * So make sure all Synchronization implementations don't have any
+ * (direct or indirect) reference to the Session.
+ */
+
+ private final QueueingProcessor queueingProcessor;
+ private boolean consumed;
+ private final WeakIdentityHashMap queuePerTransaction;
+ private WorkQueue queue = new WorkQueue();
+
+ /**
+ * in transaction work
+ */
+ public PostTransactionWorkQueueSynchronization(QueueingProcessor queueingProcessor, WeakIdentityHashMap queuePerTransaction) {
+ this.queueingProcessor = queueingProcessor;
+ this.queuePerTransaction = queuePerTransaction;
+ }
+
+ public void add(Work work) {
+ queueingProcessor.add( work, queue );
+ }
+
+ public boolean isConsumed() {
+ return consumed;
+ }
+
+ public void beforeCompletion() {
+ queueingProcessor.prepareWorks(queue);
+ }
+
+ public void afterCompletion(int i) {
+ try {
+ if ( Status.STATUS_COMMITTED == i ) {
+ queueingProcessor.performWorks(queue);
+ }
+ else {
+ queueingProcessor.cancelWorks(queue);
+ }
+ }
+ finally {
+ consumed = true;
+ //clean the Synchronization per Transaction
+ //not needed stricto sensus but a cleaner approach and faster than the GC
+ if (queuePerTransaction != null) queuePerTransaction.removeValue( this );
+ }
+ }
+
+ public void flushWorks() {
+ WorkQueue subQueue = queue.splitQueue();
+ queueingProcessor.prepareWorks( subQueue );
+ queueingProcessor.performWorks( subQueue );
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/TransactionalWorker.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/TransactionalWorker.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/TransactionalWorker.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl;
import java.util.Properties;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/BatchBackend.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/BatchBackend.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/BatchBackend.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.batchlucene;
import java.util.Properties;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/DirectoryProviderWorkspace.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/DirectoryProviderWorkspace.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/DirectoryProviderWorkspace.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.batchlucene;
import java.util.concurrent.ExecutorService;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/LuceneBatchBackend.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/LuceneBatchBackend.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/LuceneBatchBackend.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.batchlucene;
import java.util.HashMap;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/blackhole/BlackHoleBackendQueueProcessorFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/blackhole/BlackHoleBackendQueueProcessorFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/blackhole/BlackHoleBackendQueueProcessorFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.blackhole;
import java.util.List;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JGroupsBackendQueueProcessor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JGroupsBackendQueueProcessor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JGroupsBackendQueueProcessor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,78 +1,101 @@
-// $Id$
-package org.hibernate.search.backend.impl.jgroups;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jgroups.ChannelClosedException;
-import org.jgroups.ChannelNotConnectedException;
-import org.jgroups.Message;
-import org.slf4j.Logger;
-
-import org.hibernate.search.SearchException;
-import org.hibernate.search.backend.LuceneWork;
-import org.hibernate.search.backend.OptimizeLuceneWork;
-import org.hibernate.search.util.LoggerFactory;
-
-/**
- * Responsible for sending Lucene works from slave nodes to master node
- *
- * @author Lukasz Moren
- */
-public class JGroupsBackendQueueProcessor implements Runnable {
-
- protected static final Logger log = LoggerFactory.make();
-
- private final JGroupsBackendQueueProcessorFactory factory;
- private final List<LuceneWork> queue;
-
- public JGroupsBackendQueueProcessor(List<LuceneWork> queue, JGroupsBackendQueueProcessorFactory factory) {
- this.factory = factory;
- this.queue = queue;
- }
-
- @SuppressWarnings("unchecked")
- public void run() {
- List<LuceneWork> filteredQueue = new ArrayList<LuceneWork>( queue );
- log.trace( "Preparing {} Lucene works to be sent to master node.", filteredQueue.size() );
-
- for ( LuceneWork work : queue ) {
- if ( work instanceof OptimizeLuceneWork ) {
- //we don't want optimization to be propagated
- filteredQueue.remove( work );
- }
- }
- log.trace(
- "Filtering: optimized Lucene works are not going to be sent to master node. There is {} Lucene works after filtering.",
- filteredQueue.size()
- );
- if ( filteredQueue.size() == 0 ) {
- log.trace(
- "Nothing to send. Propagating works to a cluster has been skipped."
- );
- return;
- }
-
- /* Creates and send message with lucene works to master.
- * As long as message destination address is null, Lucene works will be received by all listeners that implements
- * org.jgroups.MessageListener interface, multiple master nodes in cluster are allowed. */
- try {
- Message message = new Message( null, factory.getAddress(), ( Serializable ) filteredQueue );
- factory.getChannel().send( message );
- log.trace(
- "Lucene works have been sent from slave {} to master node.", factory.getAddress()
- );
- }
- catch ( ChannelNotConnectedException e ) {
- throw new SearchException(
- "Unable to send Lucene work. Channel is not connected to: "
- + factory.getClusterName()
- );
- }
- catch ( ChannelClosedException e ) {
- throw new SearchException( "Unable to send Lucene work. Attempt to send message on closed JGroups channel" );
- }
-
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend.impl.jgroups;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jgroups.ChannelClosedException;
+import org.jgroups.ChannelNotConnectedException;
+import org.jgroups.Message;
+import org.slf4j.Logger;
+
+import org.hibernate.search.SearchException;
+import org.hibernate.search.backend.LuceneWork;
+import org.hibernate.search.backend.OptimizeLuceneWork;
+import org.hibernate.search.util.LoggerFactory;
+
+/**
+ * Responsible for sending Lucene works from slave nodes to master node
+ *
+ * @author Lukasz Moren
+ */
+public class JGroupsBackendQueueProcessor implements Runnable {
+
+ protected static final Logger log = LoggerFactory.make();
+
+ private final JGroupsBackendQueueProcessorFactory factory;
+ private final List<LuceneWork> queue;
+
+ public JGroupsBackendQueueProcessor(List<LuceneWork> queue, JGroupsBackendQueueProcessorFactory factory) {
+ this.factory = factory;
+ this.queue = queue;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void run() {
+ List<LuceneWork> filteredQueue = new ArrayList<LuceneWork>( queue );
+ log.trace( "Preparing {} Lucene works to be sent to master node.", filteredQueue.size() );
+
+ for ( LuceneWork work : queue ) {
+ if ( work instanceof OptimizeLuceneWork ) {
+ //we don't want optimization to be propagated
+ filteredQueue.remove( work );
+ }
+ }
+ log.trace(
+ "Filtering: optimized Lucene works are not going to be sent to master node. There is {} Lucene works after filtering.",
+ filteredQueue.size()
+ );
+ if ( filteredQueue.size() == 0 ) {
+ log.trace(
+ "Nothing to send. Propagating works to a cluster has been skipped."
+ );
+ return;
+ }
+
+ /* Creates and send message with lucene works to master.
+ * As long as message destination address is null, Lucene works will be received by all listeners that implements
+ * org.jgroups.MessageListener interface, multiple master nodes in cluster are allowed. */
+ try {
+ Message message = new Message( null, factory.getAddress(), ( Serializable ) filteredQueue );
+ factory.getChannel().send( message );
+ log.trace(
+ "Lucene works have been sent from slave {} to master node.", factory.getAddress()
+ );
+ }
+ catch ( ChannelNotConnectedException e ) {
+ throw new SearchException(
+ "Unable to send Lucene work. Channel is not connected to: "
+ + factory.getClusterName()
+ );
+ }
+ catch ( ChannelClosedException e ) {
+ throw new SearchException( "Unable to send Lucene work. Attempt to send message on closed JGroups channel" );
+ }
+
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JGroupsBackendQueueProcessorFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JGroupsBackendQueueProcessorFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JGroupsBackendQueueProcessorFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,182 +1,205 @@
-// $Id$
-package org.hibernate.search.backend.impl.jgroups;
-
-import java.net.URL;
-import java.util.List;
-import java.util.Properties;
-
-import org.jgroups.Address;
-import org.jgroups.Channel;
-import org.jgroups.ChannelException;
-import org.jgroups.JChannel;
-import org.slf4j.Logger;
-
-import org.hibernate.search.Environment;
-import org.hibernate.search.SearchException;
-import org.hibernate.search.backend.BackendQueueProcessorFactory;
-import org.hibernate.search.backend.LuceneWork;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.util.LoggerFactory;
-import org.hibernate.search.util.XMLHelper;
-import org.hibernate.util.ConfigHelper;
-
-
-/**
- * Common base class for Master and Slave BackendQueueProcessorFactories
- *
- * @author Lukasz Moren
- */
-public abstract class JGroupsBackendQueueProcessorFactory implements BackendQueueProcessorFactory {
-
- protected static final Logger log = LoggerFactory.make();
-
- public static final String JGROUPS_PREFIX = Environment.WORKER_BACKEND + ".jgroups.";
-
- public static final String CONFIGURATION_STRING = JGROUPS_PREFIX + "configurationString";
- public static final String CONFIGURATION_XML = JGROUPS_PREFIX + "configurationXml";
- public static final String CONFIGURATION_FILE = JGROUPS_PREFIX + "configurationFile";
- private static final String DEFAULT_JGROUPS_CONFIGURATION_FILE = "flush-udp.xml";
-
- public static final String JG_CLUSTER_NAME = JGROUPS_PREFIX + "clusterName";
-
- protected String clusterName = "HSearchCluster";
- protected SearchFactoryImplementor searchFactory;
- protected Channel channel = null;
- protected Address address;
-
- public void initialize(Properties props, SearchFactoryImplementor searchFactory) {
- this.searchFactory = searchFactory;
-
- if ( props.containsKey( JG_CLUSTER_NAME ) ) {
- setClusterName( props.getProperty( JG_CLUSTER_NAME ) );
- }
-
- prepareJGroupsChannel( props );
- }
-
- private void prepareJGroupsChannel(Properties props) {
- log.info( "Starting JGroups Channel" );
- try {
- buildChannel( props );
- channel.setOpt( Channel.AUTO_RECONNECT, Boolean.TRUE );
- channel.connect( clusterName );
- }
- catch ( ChannelException e ) {
- throw new SearchException( "Unable to connect to: [" + clusterName + "] JGroups channel" );
- }
- log.info( "Connected to cluster [ {} ]. The node address is {}", clusterName, getAddress() );
-
- if ( !channel.flushSupported() ) {
- log.warn(
- "FLUSH is not present in your JGroups stack! FLUSH is needed to ensure messages are not dropped while new nodes join the cluster. Will proceed, but inconsistencies may arise!"
- );
- }
- }
-
- /**
- * Reads congiguration and builds channnel with its base.
- * In order of preference - we first look for an external JGroups file, then a set of XML properties, and
- * finally the legacy JGroups String properties.
- *
- * @param props configuratuion file
- */
- private void buildChannel(Properties props) {
- String cfg;
- if ( props != null ) {
- if ( props.containsKey( CONFIGURATION_FILE ) ) {
- cfg = props.getProperty( CONFIGURATION_FILE );
- try {
- channel = new JChannel( ConfigHelper.locateConfig( cfg ) );
- }
- catch ( Exception e ) {
- log.error( "Error while trying to create a channel using config files: {}", cfg );
- throw new SearchException( e );
- }
- }
-
- if ( props.containsKey( CONFIGURATION_XML ) ) {
- cfg = props.getProperty( CONFIGURATION_XML );
- try {
- channel = new JChannel( XMLHelper.elementFromString( cfg ) );
- }
- catch ( Exception e ) {
- log.error( "Error while trying to create a channel using config XML: {}", cfg );
- throw new SearchException( e );
- }
- }
-
- if ( props.containsKey( CONFIGURATION_STRING ) ) {
- cfg = props.getProperty( CONFIGURATION_STRING );
- try {
- channel = new JChannel( cfg );
- }
- catch ( Exception e ) {
- log.error( "Error while trying to create a channel using config string: {}", cfg );
- throw new SearchException( e );
- }
- }
- }
-
- if ( channel == null ) {
- log.info(
- "Unable to use any JGroups configuration mechanisms provided in properties {}. Using default JGroups configuration file!",
- props
- );
- try {
- URL fileUrl = ConfigHelper.locateConfig( DEFAULT_JGROUPS_CONFIGURATION_FILE );
- if ( fileUrl != null ) {
- channel = new JChannel( fileUrl );
- }
- else {
- log.warn(
- "Default JGroups configuration file was not found. Attempt to start JGroups channel with default configuration!"
- );
- channel = new JChannel();
- }
- }
- catch ( ChannelException e ) {
- throw new SearchException( "Unable to start JGroups channel", e );
- }
- }
- }
-
- public abstract Runnable getProcessor(List<LuceneWork> queue);
-
- public void close() {
- try {
- if ( channel != null && channel.isOpen() ) {
- log.info( "Disconnecting and closing JGroups Channel" );
- channel.disconnect();
- channel.close();
- }
- }
- catch ( Exception toLog ) {
- log.error( "Problem closing channel; setting it to null", toLog );
- channel = null;
- }
- }
-
- public Channel getChannel() {
- return channel;
- }
-
- public void setClusterName(String clusterName) {
- this.clusterName = clusterName;
- }
-
- public String getClusterName() {
- return clusterName;
- }
-
- /**
- * Cluster's node address
- *
- * @return Address
- */
- public Address getAddress() {
- if ( address == null && channel != null ) {
- address = channel.getLocalAddress();
- }
- return address;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend.impl.jgroups;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+
+import org.jgroups.Address;
+import org.jgroups.Channel;
+import org.jgroups.ChannelException;
+import org.jgroups.JChannel;
+import org.slf4j.Logger;
+
+import org.hibernate.search.Environment;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.backend.BackendQueueProcessorFactory;
+import org.hibernate.search.backend.LuceneWork;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.util.LoggerFactory;
+import org.hibernate.search.util.XMLHelper;
+import org.hibernate.util.ConfigHelper;
+
+
+/**
+ * Common base class for Master and Slave BackendQueueProcessorFactories
+ *
+ * @author Lukasz Moren
+ */
+public abstract class JGroupsBackendQueueProcessorFactory implements BackendQueueProcessorFactory {
+
+ protected static final Logger log = LoggerFactory.make();
+
+ public static final String JGROUPS_PREFIX = Environment.WORKER_BACKEND + ".jgroups.";
+
+ public static final String CONFIGURATION_STRING = JGROUPS_PREFIX + "configurationString";
+ public static final String CONFIGURATION_XML = JGROUPS_PREFIX + "configurationXml";
+ public static final String CONFIGURATION_FILE = JGROUPS_PREFIX + "configurationFile";
+ private static final String DEFAULT_JGROUPS_CONFIGURATION_FILE = "flush-udp.xml";
+
+ public static final String JG_CLUSTER_NAME = JGROUPS_PREFIX + "clusterName";
+
+ protected String clusterName = "HSearchCluster";
+ protected SearchFactoryImplementor searchFactory;
+ protected Channel channel = null;
+ protected Address address;
+
+ public void initialize(Properties props, SearchFactoryImplementor searchFactory) {
+ this.searchFactory = searchFactory;
+
+ if ( props.containsKey( JG_CLUSTER_NAME ) ) {
+ setClusterName( props.getProperty( JG_CLUSTER_NAME ) );
+ }
+
+ prepareJGroupsChannel( props );
+ }
+
+ private void prepareJGroupsChannel(Properties props) {
+ log.info( "Starting JGroups Channel" );
+ try {
+ buildChannel( props );
+ channel.setOpt( Channel.AUTO_RECONNECT, Boolean.TRUE );
+ channel.connect( clusterName );
+ }
+ catch ( ChannelException e ) {
+ throw new SearchException( "Unable to connect to: [" + clusterName + "] JGroups channel" );
+ }
+ log.info( "Connected to cluster [ {} ]. The node address is {}", clusterName, getAddress() );
+
+ if ( !channel.flushSupported() ) {
+ log.warn(
+ "FLUSH is not present in your JGroups stack! FLUSH is needed to ensure messages are not dropped while new nodes join the cluster. Will proceed, but inconsistencies may arise!"
+ );
+ }
+ }
+
+ /**
+ * Reads congiguration and builds channnel with its base.
+ * In order of preference - we first look for an external JGroups file, then a set of XML properties, and
+ * finally the legacy JGroups String properties.
+ *
+ * @param props configuratuion file
+ */
+ private void buildChannel(Properties props) {
+ String cfg;
+ if ( props != null ) {
+ if ( props.containsKey( CONFIGURATION_FILE ) ) {
+ cfg = props.getProperty( CONFIGURATION_FILE );
+ try {
+ channel = new JChannel( ConfigHelper.locateConfig( cfg ) );
+ }
+ catch ( Exception e ) {
+ log.error( "Error while trying to create a channel using config files: {}", cfg );
+ throw new SearchException( e );
+ }
+ }
+
+ if ( props.containsKey( CONFIGURATION_XML ) ) {
+ cfg = props.getProperty( CONFIGURATION_XML );
+ try {
+ channel = new JChannel( XMLHelper.elementFromString( cfg ) );
+ }
+ catch ( Exception e ) {
+ log.error( "Error while trying to create a channel using config XML: {}", cfg );
+ throw new SearchException( e );
+ }
+ }
+
+ if ( props.containsKey( CONFIGURATION_STRING ) ) {
+ cfg = props.getProperty( CONFIGURATION_STRING );
+ try {
+ channel = new JChannel( cfg );
+ }
+ catch ( Exception e ) {
+ log.error( "Error while trying to create a channel using config string: {}", cfg );
+ throw new SearchException( e );
+ }
+ }
+ }
+
+ if ( channel == null ) {
+ log.info(
+ "Unable to use any JGroups configuration mechanisms provided in properties {}. Using default JGroups configuration file!",
+ props
+ );
+ try {
+ URL fileUrl = ConfigHelper.locateConfig( DEFAULT_JGROUPS_CONFIGURATION_FILE );
+ if ( fileUrl != null ) {
+ channel = new JChannel( fileUrl );
+ }
+ else {
+ log.warn(
+ "Default JGroups configuration file was not found. Attempt to start JGroups channel with default configuration!"
+ );
+ channel = new JChannel();
+ }
+ }
+ catch ( ChannelException e ) {
+ throw new SearchException( "Unable to start JGroups channel", e );
+ }
+ }
+ }
+
+ public abstract Runnable getProcessor(List<LuceneWork> queue);
+
+ public void close() {
+ try {
+ if ( channel != null && channel.isOpen() ) {
+ log.info( "Disconnecting and closing JGroups Channel" );
+ channel.disconnect();
+ channel.close();
+ }
+ }
+ catch ( Exception toLog ) {
+ log.error( "Problem closing channel; setting it to null", toLog );
+ channel = null;
+ }
+ }
+
+ public Channel getChannel() {
+ return channel;
+ }
+
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
+ }
+
+ public String getClusterName() {
+ return clusterName;
+ }
+
+ /**
+ * Cluster's node address
+ *
+ * @return Address
+ */
+ public Address getAddress() {
+ if ( address == null && channel != null ) {
+ address = channel.getLocalAddress();
+ }
+ return address;
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JGroupsMasterMessageListener.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JGroupsMasterMessageListener.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JGroupsMasterMessageListener.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,88 +1,111 @@
-// $Id$
-package org.hibernate.search.backend.impl.jgroups;
-
-import java.util.List;
-
-import org.jgroups.Address;
-import org.jgroups.Message;
-import org.jgroups.Receiver;
-import org.jgroups.View;
-import org.slf4j.Logger;
-
-import org.hibernate.search.backend.LuceneWork;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.util.LoggerFactory;
-
-/**
- * Listen for messages from slave nodes and apply them into <code>LuceneBackendQueueProcessor</code>
- *
- * @author Lukasz Moren
- * @see org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessorFactory
- * @see org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessor
- * @see org.jgroups.Receiver
- */
-public class JGroupsMasterMessageListener implements Receiver {
-
- private static final Logger log = LoggerFactory.make();
-
- private SearchFactoryImplementor searchFactory;
-
- public JGroupsMasterMessageListener(SearchFactoryImplementor searchFactory) {
- this.searchFactory = searchFactory;
- }
-
- @SuppressWarnings("unchecked")
- public void receive(Message message) {
- List<LuceneWork> queue;
- try {
- queue = ( List<LuceneWork> ) message.getObject();
- }
- catch ( ClassCastException e ) {
- log.error( "Illegal object retrieved from message.", e );
- return;
- }
-
- if ( queue != null && !queue.isEmpty() ) {
- log.debug(
- "There are {} Lucene docs received from slave node {} to be processed by master",
- queue.size(),
- message.getSrc()
- );
- Runnable worker = getWorker( queue );
- worker.run();
- }
- else {
- log.warn( "Received null or empty Lucene works list in message." );
- }
- }
-
- private Runnable getWorker(List<LuceneWork> queue) {
- Runnable processor;
- processor = searchFactory.getBackendQueueProcessorFactory().getProcessor( queue );
- return processor;
- }
-
- // ------------------------------------------------------------------------------------------------------------------
- // Implementations of JGroups interfaces
- // ------------------------------------------------------------------------------------------------------------------
-
- public byte[] getState() {
- return null;
- }
-
- public void setState(byte[] state) {
- //no-op
- }
-
- public void viewAccepted(View view) {
- log.info( "Received new cluster view: {}", view );
- }
-
- public void suspect(Address suspected_mbr) {
- //no-op
- }
-
- public void block() {
- //no-op
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend.impl.jgroups;
+
+import java.util.List;
+
+import org.jgroups.Address;
+import org.jgroups.Message;
+import org.jgroups.Receiver;
+import org.jgroups.View;
+import org.slf4j.Logger;
+
+import org.hibernate.search.backend.LuceneWork;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.util.LoggerFactory;
+
+/**
+ * Listen for messages from slave nodes and apply them into <code>LuceneBackendQueueProcessor</code>
+ *
+ * @author Lukasz Moren
+ * @see org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessorFactory
+ * @see org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessor
+ * @see org.jgroups.Receiver
+ */
+public class JGroupsMasterMessageListener implements Receiver {
+
+ private static final Logger log = LoggerFactory.make();
+
+ private SearchFactoryImplementor searchFactory;
+
+ public JGroupsMasterMessageListener(SearchFactoryImplementor searchFactory) {
+ this.searchFactory = searchFactory;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void receive(Message message) {
+ List<LuceneWork> queue;
+ try {
+ queue = ( List<LuceneWork> ) message.getObject();
+ }
+ catch ( ClassCastException e ) {
+ log.error( "Illegal object retrieved from message.", e );
+ return;
+ }
+
+ if ( queue != null && !queue.isEmpty() ) {
+ log.debug(
+ "There are {} Lucene docs received from slave node {} to be processed by master",
+ queue.size(),
+ message.getSrc()
+ );
+ Runnable worker = getWorker( queue );
+ worker.run();
+ }
+ else {
+ log.warn( "Received null or empty Lucene works list in message." );
+ }
+ }
+
+ private Runnable getWorker(List<LuceneWork> queue) {
+ Runnable processor;
+ processor = searchFactory.getBackendQueueProcessorFactory().getProcessor( queue );
+ return processor;
+ }
+
+ // ------------------------------------------------------------------------------------------------------------------
+ // Implementations of JGroups interfaces
+ // ------------------------------------------------------------------------------------------------------------------
+
+ public byte[] getState() {
+ return null;
+ }
+
+ public void setState(byte[] state) {
+ //no-op
+ }
+
+ public void viewAccepted(View view) {
+ log.info( "Received new cluster view: {}", view );
+ }
+
+ public void suspect(Address suspected_mbr) {
+ //no-op
+ }
+
+ public void block() {
+ //no-op
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/MasterJGroupsBackendQueueProcessorFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/MasterJGroupsBackendQueueProcessorFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/MasterJGroupsBackendQueueProcessorFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,59 +1,82 @@
-// $Id$
-package org.hibernate.search.backend.impl.jgroups;
-
-import java.util.List;
-import java.util.Properties;
-
-import org.jgroups.Receiver;
-
-import org.hibernate.search.backend.LuceneWork;
-import org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessorFactory;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-
-/**
- * Backend factory used in JGroups clustering mode in master node.
- * Wraps {@link LuceneBackendQueueProcessorFactory} with providing extra
- * functionality to receive Lucene works from slave nodes.
- *
- * @author Lukasz Moren
- * @see org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessorFactory
- * @see org.hibernate.search.backend.impl.jgroups.SlaveJGroupsBackendQueueProcessorFactory
- */
-public class MasterJGroupsBackendQueueProcessorFactory extends JGroupsBackendQueueProcessorFactory {
-
- private LuceneBackendQueueProcessorFactory luceneBackendQueueProcessorFactory;
- private Receiver masterListener;
-
- @Override
- public void initialize(Properties props, SearchFactoryImplementor searchFactory) {
- super.initialize( props, searchFactory );
- initLuceneBackendQueueProcessorFactory( props, searchFactory );
-
- registerMasterListener();
- }
-
- public Runnable getProcessor(List<LuceneWork> queue) {
- return luceneBackendQueueProcessorFactory.getProcessor( queue );
- }
-
- private void registerMasterListener() {
- //register JGroups receiver in master node to get Lucene docs from slave nodes
- masterListener = new JGroupsMasterMessageListener( searchFactory );
- channel.setReceiver( masterListener );
- }
-
- private void initLuceneBackendQueueProcessorFactory(Properties props, SearchFactoryImplementor searchFactory) {
- luceneBackendQueueProcessorFactory = new LuceneBackendQueueProcessorFactory();
- luceneBackendQueueProcessorFactory.initialize( props, searchFactory );
- }
-
- public Receiver getMasterListener() {
- return masterListener;
- }
-
- @Override
- public void close() {
- super.close();
- luceneBackendQueueProcessorFactory.close();
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend.impl.jgroups;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.jgroups.Receiver;
+
+import org.hibernate.search.backend.LuceneWork;
+import org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessorFactory;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+
+/**
+ * Backend factory used in JGroups clustering mode in master node.
+ * Wraps {@link LuceneBackendQueueProcessorFactory} with providing extra
+ * functionality to receive Lucene works from slave nodes.
+ *
+ * @author Lukasz Moren
+ * @see org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessorFactory
+ * @see org.hibernate.search.backend.impl.jgroups.SlaveJGroupsBackendQueueProcessorFactory
+ */
+public class MasterJGroupsBackendQueueProcessorFactory extends JGroupsBackendQueueProcessorFactory {
+
+ private LuceneBackendQueueProcessorFactory luceneBackendQueueProcessorFactory;
+ private Receiver masterListener;
+
+ @Override
+ public void initialize(Properties props, SearchFactoryImplementor searchFactory) {
+ super.initialize( props, searchFactory );
+ initLuceneBackendQueueProcessorFactory( props, searchFactory );
+
+ registerMasterListener();
+ }
+
+ public Runnable getProcessor(List<LuceneWork> queue) {
+ return luceneBackendQueueProcessorFactory.getProcessor( queue );
+ }
+
+ private void registerMasterListener() {
+ //register JGroups receiver in master node to get Lucene docs from slave nodes
+ masterListener = new JGroupsMasterMessageListener( searchFactory );
+ channel.setReceiver( masterListener );
+ }
+
+ private void initLuceneBackendQueueProcessorFactory(Properties props, SearchFactoryImplementor searchFactory) {
+ luceneBackendQueueProcessorFactory = new LuceneBackendQueueProcessorFactory();
+ luceneBackendQueueProcessorFactory.initialize( props, searchFactory );
+ }
+
+ public Receiver getMasterListener() {
+ return masterListener;
+ }
+
+ @Override
+ public void close() {
+ super.close();
+ luceneBackendQueueProcessorFactory.close();
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/SlaveJGroupsBackendQueueProcessorFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/SlaveJGroupsBackendQueueProcessorFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/SlaveJGroupsBackendQueueProcessorFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,16 +1,39 @@
-// $Id$
-package org.hibernate.search.backend.impl.jgroups;
-
-import java.util.List;
-
-import org.hibernate.search.backend.LuceneWork;
-
-/**
- * @author Lukasz Moren
- */
-public class SlaveJGroupsBackendQueueProcessorFactory extends JGroupsBackendQueueProcessorFactory {
-
- public Runnable getProcessor(List<LuceneWork> queue) {
- return new JGroupsBackendQueueProcessor( queue, this );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend.impl.jgroups;
+
+import java.util.List;
+
+import org.hibernate.search.backend.LuceneWork;
+
+/**
+ * @author Lukasz Moren
+ */
+public class SlaveJGroupsBackendQueueProcessorFactory extends JGroupsBackendQueueProcessorFactory {
+
+ public Runnable getProcessor(List<LuceneWork> queue) {
+ return new JGroupsBackendQueueProcessor( queue, this );
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/jms/AbstractJMSHibernateSearchController.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/jms/AbstractJMSHibernateSearchController.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/jms/AbstractJMSHibernateSearchController.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,112 +1,135 @@
-//$Id$
-package org.hibernate.search.backend.impl.jms;
-
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.ObjectMessage;
-
-import org.slf4j.Logger;
-
-import org.hibernate.Session;
-import org.hibernate.search.backend.LuceneWork;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.util.ContextHelper;
-import org.hibernate.search.util.LoggerFactory;
-
-/**
- * Implement the Hibernate Search controller responsible for processing the
- * work send through JMS by the slave nodes.
- *
- * @author Emmanuel Bernard
- */
-public abstract class AbstractJMSHibernateSearchController implements MessageListener {
- private static final Logger log = LoggerFactory.make();
-
- /**
- * Return the current or give a new session
- * This session is not used per se, but is the link to access the Search configuration.
- * <p>
- * A typical EJB 3.0 usecase would be to get the session from the container (injected)
- * eg in JBoss EJB 3.0
- * <p>
- * <code>
- * @PersistenceContext private Session session;<br>
- * <br>
- * protected Session getSession() {<br>
- * return session<br>
- * }<br>
- * </code>
- * <p>
- * eg in any container<br>
- * <code>
- * @PersistenceContext private EntityManager entityManager;<br>
- * <br>
- * protected Session getSession() {<br>
- * return (Session) entityManager.getdelegate();<br>
- * }<br>
- * </code>
- */
- protected abstract Session getSession();
-
- /**
- * Ensure to clean the resources after use.
- * If the session has been directly or indirectly injected, this method is empty
- */
- protected abstract void cleanSessionIfNeeded(Session session);
-
- /**
- * Process the Hibernate Search work queues received
- */
- public void onMessage(Message message) {
- if ( !( message instanceof ObjectMessage ) ) {
- log.error( "Incorrect message type: {}", message.getClass() );
- return;
- }
- ObjectMessage objectMessage = (ObjectMessage) message;
- List<LuceneWork> queue;
- try {
- queue = (List<LuceneWork>) objectMessage.getObject();
- }
- catch (JMSException e) {
- log.error( "Unable to retrieve object from message: " + message.getClass(), e );
- return;
- }
- catch (ClassCastException e) {
- log.error( "Illegal object retrieved from message", e );
- return;
- }
- Runnable worker = getWorker( queue );
- worker.run();
- }
-
- private Runnable getWorker(List<LuceneWork> queue) {
- //FIXME casting sucks because we do not control what get session from
- Session session = getSession();
- Runnable processor = null;
-
- try {
- SearchFactoryImplementor factory = ContextHelper.getSearchFactory( session );
- processor = factory.getBackendQueueProcessorFactory().getProcessor( queue );
- }
- finally {
- cleanSessionIfNeeded(session);
- }
- return processor;
- }
-
- @PostConstruct
- public void initialize() {
- //init the source copy process
- //TODO actually this is probably wrong since this is now part of the DP
- }
-
- @PreDestroy
- public void shutdown() {
- //stop the source copy process
- //TODO actually this is probably wrong since this is now part of the DP
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend.impl.jms;
+
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.ObjectMessage;
+
+import org.slf4j.Logger;
+
+import org.hibernate.Session;
+import org.hibernate.search.backend.LuceneWork;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.util.ContextHelper;
+import org.hibernate.search.util.LoggerFactory;
+
+/**
+ * Implement the Hibernate Search controller responsible for processing the
+ * work send through JMS by the slave nodes.
+ *
+ * @author Emmanuel Bernard
+ */
+public abstract class AbstractJMSHibernateSearchController implements MessageListener {
+ private static final Logger log = LoggerFactory.make();
+
+ /**
+ * Return the current or give a new session
+ * This session is not used per se, but is the link to access the Search configuration.
+ * <p>
+ * A typical EJB 3.0 usecase would be to get the session from the container (injected)
+ * eg in JBoss EJB 3.0
+ * <p>
+ * <code>
+ * @PersistenceContext private Session session;<br>
+ * <br>
+ * protected Session getSession() {<br>
+ * return session<br>
+ * }<br>
+ * </code>
+ * <p>
+ * eg in any container<br>
+ * <code>
+ * @PersistenceContext private EntityManager entityManager;<br>
+ * <br>
+ * protected Session getSession() {<br>
+ * return (Session) entityManager.getdelegate();<br>
+ * }<br>
+ * </code>
+ */
+ protected abstract Session getSession();
+
+ /**
+ * Ensure to clean the resources after use.
+ * If the session has been directly or indirectly injected, this method is empty
+ */
+ protected abstract void cleanSessionIfNeeded(Session session);
+
+ /**
+ * Process the Hibernate Search work queues received
+ */
+ public void onMessage(Message message) {
+ if ( !( message instanceof ObjectMessage ) ) {
+ log.error( "Incorrect message type: {}", message.getClass() );
+ return;
+ }
+ ObjectMessage objectMessage = (ObjectMessage) message;
+ List<LuceneWork> queue;
+ try {
+ queue = (List<LuceneWork>) objectMessage.getObject();
+ }
+ catch (JMSException e) {
+ log.error( "Unable to retrieve object from message: " + message.getClass(), e );
+ return;
+ }
+ catch (ClassCastException e) {
+ log.error( "Illegal object retrieved from message", e );
+ return;
+ }
+ Runnable worker = getWorker( queue );
+ worker.run();
+ }
+
+ private Runnable getWorker(List<LuceneWork> queue) {
+ //FIXME casting sucks because we do not control what get session from
+ Session session = getSession();
+ Runnable processor = null;
+
+ try {
+ SearchFactoryImplementor factory = ContextHelper.getSearchFactory( session );
+ processor = factory.getBackendQueueProcessorFactory().getProcessor( queue );
+ }
+ finally {
+ cleanSessionIfNeeded(session);
+ }
+ return processor;
+ }
+
+ @PostConstruct
+ public void initialize() {
+ //init the source copy process
+ //TODO actually this is probably wrong since this is now part of the DP
+ }
+
+ @PreDestroy
+ public void shutdown() {
+ //stop the source copy process
+ //TODO actually this is probably wrong since this is now part of the DP
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/jms/JMSBackendQueueProcessor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/jms/JMSBackendQueueProcessor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/jms/JMSBackendQueueProcessor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,74 +1,97 @@
-//$Id$
-package org.hibernate.search.backend.impl.jms;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import javax.jms.JMSException;
-import javax.jms.ObjectMessage;
-import javax.jms.QueueConnection;
-import javax.jms.QueueSender;
-import javax.jms.QueueSession;
-
-import org.slf4j.Logger;
-
-import org.hibernate.HibernateException;
-import org.hibernate.search.backend.LuceneWork;
-import org.hibernate.search.backend.OptimizeLuceneWork;
-import org.hibernate.search.util.LoggerFactory;
-
-/**
- * @author Emmanuel Bernard
- */
-public class JMSBackendQueueProcessor implements Runnable {
- private static final Logger log = LoggerFactory.make();
-
- private List<LuceneWork> queue;
- private JMSBackendQueueProcessorFactory factory;
-
- public JMSBackendQueueProcessor(List<LuceneWork> queue,
- JMSBackendQueueProcessorFactory jmsBackendQueueProcessorFactory) {
- this.queue = queue;
- this.factory = jmsBackendQueueProcessorFactory;
- }
-
- public void run() {
- List<LuceneWork> filteredQueue = new ArrayList<LuceneWork>(queue);
- for (LuceneWork work : queue) {
- if ( work instanceof OptimizeLuceneWork ) {
- //we don't want optimization to be propagated
- filteredQueue.remove( work );
- }
- }
- if ( filteredQueue.size() == 0) return;
- factory.prepareJMSTools();
- QueueConnection cnn = null;
- QueueSender sender;
- QueueSession session;
- try {
- cnn = factory.getJMSFactory().createQueueConnection();
- //TODO make transacted parameterized
- session = cnn.createQueueSession( false, QueueSession.AUTO_ACKNOWLEDGE );
-
- ObjectMessage message = session.createObjectMessage();
- message.setObject( (Serializable) filteredQueue );
-
- sender = session.createSender( factory.getJmsQueue() );
- sender.send( message );
-
- session.close();
- }
- catch (JMSException e) {
- throw new HibernateException( "Unable to send Search work to JMS queue: " + factory.getJmsQueueName(), e );
- }
- finally {
- try {
- if (cnn != null)
- cnn.close();
- }
- catch ( JMSException e ) {
- log.warn( "Unable to close JMS connection for " + factory.getJmsQueueName(), e );
- }
- }
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend.impl.jms;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+import javax.jms.QueueConnection;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+
+import org.slf4j.Logger;
+
+import org.hibernate.HibernateException;
+import org.hibernate.search.backend.LuceneWork;
+import org.hibernate.search.backend.OptimizeLuceneWork;
+import org.hibernate.search.util.LoggerFactory;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class JMSBackendQueueProcessor implements Runnable {
+ private static final Logger log = LoggerFactory.make();
+
+ private List<LuceneWork> queue;
+ private JMSBackendQueueProcessorFactory factory;
+
+ public JMSBackendQueueProcessor(List<LuceneWork> queue,
+ JMSBackendQueueProcessorFactory jmsBackendQueueProcessorFactory) {
+ this.queue = queue;
+ this.factory = jmsBackendQueueProcessorFactory;
+ }
+
+ public void run() {
+ List<LuceneWork> filteredQueue = new ArrayList<LuceneWork>(queue);
+ for (LuceneWork work : queue) {
+ if ( work instanceof OptimizeLuceneWork ) {
+ //we don't want optimization to be propagated
+ filteredQueue.remove( work );
+ }
+ }
+ if ( filteredQueue.size() == 0) return;
+ factory.prepareJMSTools();
+ QueueConnection cnn = null;
+ QueueSender sender;
+ QueueSession session;
+ try {
+ cnn = factory.getJMSFactory().createQueueConnection();
+ //TODO make transacted parameterized
+ session = cnn.createQueueSession( false, QueueSession.AUTO_ACKNOWLEDGE );
+
+ ObjectMessage message = session.createObjectMessage();
+ message.setObject( (Serializable) filteredQueue );
+
+ sender = session.createSender( factory.getJmsQueue() );
+ sender.send( message );
+
+ session.close();
+ }
+ catch (JMSException e) {
+ throw new HibernateException( "Unable to send Search work to JMS queue: " + factory.getJmsQueueName(), e );
+ }
+ finally {
+ try {
+ if (cnn != null)
+ cnn.close();
+ }
+ catch ( JMSException e ) {
+ log.warn( "Unable to close JMS connection for " + factory.getJmsQueueName(), e );
+ }
+ }
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/jms/JMSBackendQueueProcessorFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/jms/JMSBackendQueueProcessorFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/jms/JMSBackendQueueProcessorFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.jms;
import java.util.HashSet;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/DpSelectionDelegate.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/DpSelectionDelegate.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/DpSelectionDelegate.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.lucene;
import org.hibernate.search.backend.LuceneWork;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/DpSelectionVisitor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/DpSelectionVisitor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/DpSelectionVisitor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.lucene;
import org.hibernate.search.backend.AddLuceneWork;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,60 +1,83 @@
-//$Id$
-package org.hibernate.search.backend.impl.lucene;
-
-import java.util.List;
-import java.util.Map;
-
-import org.hibernate.search.backend.LuceneWork;
-import org.hibernate.search.engine.DocumentBuilderIndexedEntity;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.store.DirectoryProvider;
-import org.hibernate.search.store.IndexShardingStrategy;
-import org.hibernate.search.util.LoggerFactory;
-import org.slf4j.Logger;
-
-/**
- * Apply the operations to Lucene directories.
- *
- * @author Emmanuel Bernard
- * @author Hardy Ferentschik
- * @author John Griffin
- * @author Sanne Grinovero
- */
-class LuceneBackendQueueProcessor implements Runnable {
-
- private final List<LuceneWork> queue;
- private final SearchFactoryImplementor searchFactoryImplementor;
- private final Map<DirectoryProvider,PerDPResources> resourcesMap;
- private final boolean sync;
-
- private static final DpSelectionVisitor providerSelectionVisitor = new DpSelectionVisitor();
- private static final Logger log = LoggerFactory.make();
-
- LuceneBackendQueueProcessor(List<LuceneWork> queue,
- SearchFactoryImplementor searchFactoryImplementor,
- Map<DirectoryProvider,PerDPResources> resourcesMap,
- boolean syncMode) {
- this.sync = syncMode;
- this.queue = queue;
- this.searchFactoryImplementor = searchFactoryImplementor;
- this.resourcesMap = resourcesMap;
- }
-
- public void run() {
- QueueProcessors processors = new QueueProcessors( resourcesMap );
- // divide the queue in tasks, adding to QueueProcessors by affected Directory.
- try {
- for ( LuceneWork work : queue ) {
- final Class<?> entityType = work.getEntityClass();
- DocumentBuilderIndexedEntity<?> documentBuilder = searchFactoryImplementor.getDocumentBuilderIndexedEntity( entityType );
- IndexShardingStrategy shardingStrategy = documentBuilder.getDirectoryProviderSelectionStrategy();
- work.getWorkDelegate( providerSelectionVisitor ).addAsPayLoadsToQueue( work, shardingStrategy, processors );
- }
- //this Runnable splits tasks in more runnables and then runs them:
- processors.runAll( sync );
- } catch (InterruptedException e) {
- log.error( "Index update task has been interrupted", e );
- }
- }
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.backend.impl.lucene;
+
+import java.util.List;
+import java.util.Map;
+
+import org.hibernate.search.backend.LuceneWork;
+import org.hibernate.search.engine.DocumentBuilderIndexedEntity;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.store.IndexShardingStrategy;
+import org.hibernate.search.util.LoggerFactory;
+import org.slf4j.Logger;
+
+/**
+ * Apply the operations to Lucene directories.
+ *
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ * @author John Griffin
+ * @author Sanne Grinovero
+ */
+class LuceneBackendQueueProcessor implements Runnable {
+
+ private final List<LuceneWork> queue;
+ private final SearchFactoryImplementor searchFactoryImplementor;
+ private final Map<DirectoryProvider,PerDPResources> resourcesMap;
+ private final boolean sync;
+
+ private static final DpSelectionVisitor providerSelectionVisitor = new DpSelectionVisitor();
+ private static final Logger log = LoggerFactory.make();
+
+ LuceneBackendQueueProcessor(List<LuceneWork> queue,
+ SearchFactoryImplementor searchFactoryImplementor,
+ Map<DirectoryProvider,PerDPResources> resourcesMap,
+ boolean syncMode) {
+ this.sync = syncMode;
+ this.queue = queue;
+ this.searchFactoryImplementor = searchFactoryImplementor;
+ this.resourcesMap = resourcesMap;
+ }
+
+ public void run() {
+ QueueProcessors processors = new QueueProcessors( resourcesMap );
+ // divide the queue in tasks, adding to QueueProcessors by affected Directory.
+ try {
+ for ( LuceneWork work : queue ) {
+ final Class<?> entityType = work.getEntityClass();
+ DocumentBuilderIndexedEntity<?> documentBuilder = searchFactoryImplementor.getDocumentBuilderIndexedEntity( entityType );
+ IndexShardingStrategy shardingStrategy = documentBuilder.getDirectoryProviderSelectionStrategy();
+ work.getWorkDelegate( providerSelectionVisitor ).addAsPayLoadsToQueue( work, shardingStrategy, processors );
+ }
+ //this Runnable splits tasks in more runnables and then runs them:
+ processors.runAll( sync );
+ } catch (InterruptedException e) {
+ log.error( "Index update task has been interrupted", e );
+ }
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessorFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessorFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessorFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.lucene;
import java.util.HashMap;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.lucene;
import java.util.ArrayList;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPResources.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPResources.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPResources.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.lucene;
import java.util.concurrent.ExecutorService;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDirectoryWorkProcessor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDirectoryWorkProcessor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDirectoryWorkProcessor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.lucene;
import org.hibernate.search.backend.LuceneWork;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/QueueProcessors.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/QueueProcessors.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/QueueProcessors.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.lucene;
import java.util.ArrayList;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/AddWorkDelegate.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/AddWorkDelegate.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/AddWorkDelegate.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.lucene.works;
import java.io.IOException;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/DeleteExtWorkDelegate.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/DeleteExtWorkDelegate.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/DeleteExtWorkDelegate.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.lucene.works;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/DeleteWorkDelegate.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/DeleteWorkDelegate.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/DeleteWorkDelegate.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.lucene.works;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/LuceneWorkDelegate.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/LuceneWorkDelegate.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/LuceneWorkDelegate.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.lucene.works;
import org.apache.lucene.index.IndexWriter;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/LuceneWorkVisitor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/LuceneWorkVisitor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/LuceneWorkVisitor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.lucene.works;
import org.hibernate.search.backend.AddLuceneWork;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/OptimizeWorkDelegate.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/OptimizeWorkDelegate.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/OptimizeWorkDelegate.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.lucene.works;
import java.io.IOException;
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/PurgeAllWorkDelegate.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/PurgeAllWorkDelegate.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/PurgeAllWorkDelegate.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.backend.impl.lucene.works;
import org.apache.lucene.index.IndexWriter;
Modified: search/trunk/src/main/java/org/hibernate/search/batchindexing/BatchCoordinator.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/batchindexing/BatchCoordinator.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/batchindexing/BatchCoordinator.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.batchindexing;
import java.util.Set;
Modified: search/trunk/src/main/java/org/hibernate/search/batchindexing/BatchIndexingWorkspace.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/batchindexing/BatchIndexingWorkspace.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/batchindexing/BatchIndexingWorkspace.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.batchindexing;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/batchindexing/EntityConsumerLuceneworkProducer.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/batchindexing/EntityConsumerLuceneworkProducer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/batchindexing/EntityConsumerLuceneworkProducer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.batchindexing;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/batchindexing/Executors.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/batchindexing/Executors.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/batchindexing/Executors.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.batchindexing;
import java.util.concurrent.LinkedBlockingQueue;
Modified: search/trunk/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.batchindexing;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/batchindexing/IdentifierProducer.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/batchindexing/IdentifierProducer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/batchindexing/IdentifierProducer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.batchindexing;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/batchindexing/MassIndexerProgressMonitor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/batchindexing/MassIndexerProgressMonitor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/batchindexing/MassIndexerProgressMonitor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.batchindexing;
/**
Modified: search/trunk/src/main/java/org/hibernate/search/batchindexing/ProducerConsumerQueue.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/batchindexing/ProducerConsumerQueue.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/batchindexing/ProducerConsumerQueue.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.batchindexing;
import java.util.concurrent.ArrayBlockingQueue;
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/BridgeFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/BridgeFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/BridgeFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,297 +1,320 @@
-//$Id$
-package org.hibernate.search.bridge;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.URI;
-import java.net.URL;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.annotations.common.reflection.ReflectionManager;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XMember;
-import org.hibernate.search.SearchException;
-import org.hibernate.search.annotations.ClassBridge;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Parameter;
-import org.hibernate.search.annotations.Resolution;
-import org.hibernate.search.bridge.builtin.BigDecimalBridge;
-import org.hibernate.search.bridge.builtin.BigIntegerBridge;
-import org.hibernate.search.bridge.builtin.BooleanBridge;
-import org.hibernate.search.bridge.builtin.CharacterBridge;
-import org.hibernate.search.bridge.builtin.DateBridge;
-import org.hibernate.search.bridge.builtin.DoubleBridge;
-import org.hibernate.search.bridge.builtin.EnumBridge;
-import org.hibernate.search.bridge.builtin.FloatBridge;
-import org.hibernate.search.bridge.builtin.IntegerBridge;
-import org.hibernate.search.bridge.builtin.LongBridge;
-import org.hibernate.search.bridge.builtin.ShortBridge;
-import org.hibernate.search.bridge.builtin.StringBridge;
-import org.hibernate.search.bridge.builtin.UriBridge;
-import org.hibernate.search.bridge.builtin.UrlBridge;
-
-/**
- * This factory is responsible for creating and initializing build-in and custom <i>FieldBridges</i>.
- *
- * @author Emmanuel Bernard
- * @author John Griffin
- */
-public class BridgeFactory {
- private static Map<String, FieldBridge> builtInBridges = new HashMap<String, FieldBridge>();
-
- private BridgeFactory() {
- }
-
- public static final TwoWayFieldBridge CHARACTER = new TwoWayString2FieldBridgeAdaptor( new CharacterBridge() );
-
- public static final TwoWayFieldBridge DOUBLE = new TwoWayString2FieldBridgeAdaptor( new DoubleBridge() );
-
- public static final TwoWayFieldBridge FLOAT = new TwoWayString2FieldBridgeAdaptor( new FloatBridge() );
-
- public static final TwoWayFieldBridge SHORT = new TwoWayString2FieldBridgeAdaptor( new ShortBridge() );
-
- public static final TwoWayFieldBridge INTEGER = new TwoWayString2FieldBridgeAdaptor( new IntegerBridge() );
-
- public static final TwoWayFieldBridge LONG = new TwoWayString2FieldBridgeAdaptor( new LongBridge() );
-
- public static final TwoWayFieldBridge BIG_INTEGER = new TwoWayString2FieldBridgeAdaptor( new BigIntegerBridge() );
-
- public static final TwoWayFieldBridge BIG_DECIMAL = new TwoWayString2FieldBridgeAdaptor( new BigDecimalBridge() );
-
- public static final TwoWayFieldBridge STRING = new TwoWayString2FieldBridgeAdaptor( new StringBridge() );
-
- public static final TwoWayFieldBridge BOOLEAN = new TwoWayString2FieldBridgeAdaptor( new BooleanBridge() );
-
- public static final TwoWayFieldBridge CLAZZ = new TwoWayString2FieldBridgeAdaptor( new org.hibernate.search.bridge.builtin.ClassBridge() );
-
- public static final TwoWayFieldBridge Url = new TwoWayString2FieldBridgeAdaptor( new UrlBridge() );
-
- public static final TwoWayFieldBridge Uri = new TwoWayString2FieldBridgeAdaptor( new UriBridge() );
-
- public static final FieldBridge DATE_YEAR = new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_YEAR );
- public static final FieldBridge DATE_MONTH = new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_MONTH );
- public static final FieldBridge DATE_DAY = new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_DAY );
- public static final FieldBridge DATE_HOUR = new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_HOUR );
- public static final FieldBridge DATE_MINUTE = new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_MINUTE );
- public static final FieldBridge DATE_SECOND = new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_SECOND );
- public static final TwoWayFieldBridge DATE_MILLISECOND =
- new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_MILLISECOND );
-
- static {
- builtInBridges.put( Character.class.getName(), CHARACTER );
- builtInBridges.put( char.class.getName(), CHARACTER );
- builtInBridges.put( Double.class.getName(), DOUBLE );
- builtInBridges.put( double.class.getName(), DOUBLE );
- builtInBridges.put( Float.class.getName(), FLOAT );
- builtInBridges.put( float.class.getName(), FLOAT );
- builtInBridges.put( Short.class.getName(), SHORT );
- builtInBridges.put( short.class.getName(), SHORT );
- builtInBridges.put( Integer.class.getName(), INTEGER );
- builtInBridges.put( int.class.getName(), INTEGER );
- builtInBridges.put( Long.class.getName(), LONG );
- builtInBridges.put( long.class.getName(), LONG );
- builtInBridges.put( BigInteger.class.getName(), BIG_INTEGER );
- builtInBridges.put( BigDecimal.class.getName(), BIG_DECIMAL );
- builtInBridges.put( String.class.getName(), STRING );
- builtInBridges.put( Boolean.class.getName(), BOOLEAN );
- builtInBridges.put( boolean.class.getName(), BOOLEAN );
- builtInBridges.put( Class.class.getName(), CLAZZ );
- builtInBridges.put( URL.class.getName(), Url );
- builtInBridges.put( URI.class.getName(), Uri );
-
- builtInBridges.put( Date.class.getName(), DATE_MILLISECOND );
- }
-
- /**
- * This extracts and instantiates the implementation class from a ClassBridge
- * annotation.
- *
- * @param cb the ClassBridge
- * @return FieldBridge
- */
- public static FieldBridge extractType(ClassBridge cb)
- {
- FieldBridge bridge = null;
-
- if ( cb != null ) {
- Class<?> impl = cb.impl();
- //TODO better error information ( see guessType() )
- if (impl != null) {
- try {
- Object instance = impl.newInstance();
- if ( FieldBridge.class.isAssignableFrom( impl ) ) {
- bridge = (FieldBridge) instance;
- }
- else if ( org.hibernate.search.bridge.TwoWayStringBridge.class.isAssignableFrom( impl ) ) {
- bridge = new TwoWayString2FieldBridgeAdaptor(
- (org.hibernate.search.bridge.TwoWayStringBridge) instance );
- }
- else if ( org.hibernate.search.bridge.StringBridge.class.isAssignableFrom( impl ) ) {
- bridge = new String2FieldBridgeAdaptor( (org.hibernate.search.bridge.StringBridge) instance );
- }
- else {
- throw new SearchException("@ClassBridge implementation implements none of the field bridge interfaces: "
- + impl );
- }
- if ( cb.params().length > 0 && ParameterizedBridge.class.isAssignableFrom( impl ) ) {
- Map<String, String> params = new HashMap<String, String>( cb.params().length );
- for ( Parameter param : cb.params() ) {
- params.put( param.name(), param.value() );
- }
- ( (ParameterizedBridge) instance ).setParameterValues( params );
- }
- }
- catch (Exception e) {
- throw new HibernateException( "Unable to instantiate ClassBridge for " + impl.getName(), e );
- }
- }
- }
- if ( bridge == null ) throw new SearchException( "Unable to guess FieldBridge for " + ClassBridge.class.getName() );
-
- return bridge;
- }
-
- public static FieldBridge guessType(Field field, XMember member, ReflectionManager reflectionManager) {
- FieldBridge bridge;
- org.hibernate.search.annotations.FieldBridge bridgeAnn;
- //@Field bridge has priority over @FieldBridge
- if ( field != null && void.class != field.bridge().impl() ) {
- bridgeAnn = field.bridge();
- }
- else {
- bridgeAnn = member.getAnnotation( org.hibernate.search.annotations.FieldBridge.class );
- }
- final String memberName = member.getName();
- if ( bridgeAnn != null ) {
- bridge = doExtractType( bridgeAnn, memberName );
- }
- else if ( member.isAnnotationPresent( org.hibernate.search.annotations.DateBridge.class ) ) {
- Resolution resolution =
- member.getAnnotation( org.hibernate.search.annotations.DateBridge.class ).resolution();
- bridge = getDateField( resolution );
- }
- else {
- //find in built-ins
- XClass returnType = member.getType();
- bridge = builtInBridges.get( returnType.getName() );
- if ( bridge == null && returnType.isEnum() ) {
- bridge = new TwoWayString2FieldBridgeAdaptor(
- new EnumBridge( reflectionManager.toClass( returnType ) )
- );
- }
- }
- //TODO add classname
- if ( bridge == null ) throw new SearchException( "Unable to guess FieldBridge for " + memberName );
- return bridge;
- }
-
- /** assume not null bridgeAnn */
- private static FieldBridge doExtractType(org.hibernate.search.annotations.FieldBridge bridgeAnn, String memberName) {
- assert bridgeAnn != null : "doExtractType assume bridge instance not null";
- FieldBridge bridge;
- Class impl = bridgeAnn.impl();
- if (impl == void.class)
- throw new SearchException("@FieldBridge with no implementation class defined in: " + memberName );
- try {
- Object instance = impl.newInstance();
- if ( FieldBridge.class.isAssignableFrom( impl ) ) {
- bridge = (FieldBridge) instance;
- }
- else if ( TwoWayStringBridge.class.isAssignableFrom( impl ) ) {
- bridge = new TwoWayString2FieldBridgeAdaptor(
- ( TwoWayStringBridge) instance );
- }
- else if ( org.hibernate.search.bridge.StringBridge.class.isAssignableFrom( impl ) ) {
- bridge = new String2FieldBridgeAdaptor( (org.hibernate.search.bridge.StringBridge) instance );
- }
- else {
- throw new SearchException("@FieldBridge implementation implements none of the field bridge interfaces: "
- + impl + " in " + memberName
- );
- }
- if ( bridgeAnn.params().length > 0 && ParameterizedBridge.class.isAssignableFrom( impl ) ) {
- Map<String, String> params = new HashMap<String, String>( bridgeAnn.params().length );
- for ( Parameter param : bridgeAnn.params() ) {
- params.put( param.name(), param.value() );
- }
- ( (ParameterizedBridge) instance ).setParameterValues( params );
- }
- }
- catch (Exception e) {
- //TODO add classname
- throw new SearchException( "Unable to instanciate FieldBridge for " + memberName, e );
- }
- return bridge;
- }
-
- public static FieldBridge getDateField(Resolution resolution) {
- switch (resolution) {
- case YEAR:
- return DATE_YEAR;
- case MONTH:
- return DATE_MONTH;
- case DAY:
- return DATE_DAY;
- case HOUR:
- return DATE_HOUR;
- case MINUTE:
- return DATE_MINUTE;
- case SECOND:
- return DATE_SECOND;
- case MILLISECOND:
- return DATE_MILLISECOND;
- default:
- throw new AssertionFailure( "Unknown Resolution: " + resolution );
- }
- }
-
- /**
- * Takes in a fieldBridge and will return you a TwoWayFieldBridge instance.
- *
- * @param fieldBridge
- *
- * @return a TwoWayFieldBridge instance if the Field Bridge is an instance of a TwoWayFieldBridge.
- *
- * @throws SearchException if the FieldBridge passed in is not an instance of a TwoWayFieldBridge.
- */
-
- public static TwoWayFieldBridge extractTwoWayType(org.hibernate.search.annotations.FieldBridge fieldBridge) {
- FieldBridge fb = extractType( fieldBridge );
- if ( fb instanceof TwoWayFieldBridge ) {
- return ( TwoWayFieldBridge ) fb;
- }
- else {
- throw new SearchException( "FieldBridge passed in is not an instance of " + TwoWayFieldBridge.class.getSimpleName() );
- }
- }
-
- /**
- * This extracts and instantiates the implementation class from a ClassBridge
- * annotation.
- *
- * @param fieldBridgeAnnotation the FieldBridge annotation
- *
- * @return FieldBridge
- */
- public static FieldBridge extractType(org.hibernate.search.annotations.FieldBridge fieldBridgeAnnotation) {
- FieldBridge bridge = null;
-
- if ( fieldBridgeAnnotation != null ) {
- bridge = doExtractType( fieldBridgeAnnotation, null );
- }
-
- if ( bridge == null ) {
- throw new SearchException(
- "Unable to guess FieldBridge for " + org.hibernate.search.annotations.FieldBridge.class.getName()
- );
- }
-
- return bridge;
- }
-
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.net.URL;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.annotations.common.reflection.ReflectionManager;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XMember;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.annotations.ClassBridge;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Parameter;
+import org.hibernate.search.annotations.Resolution;
+import org.hibernate.search.bridge.builtin.BigDecimalBridge;
+import org.hibernate.search.bridge.builtin.BigIntegerBridge;
+import org.hibernate.search.bridge.builtin.BooleanBridge;
+import org.hibernate.search.bridge.builtin.CharacterBridge;
+import org.hibernate.search.bridge.builtin.DateBridge;
+import org.hibernate.search.bridge.builtin.DoubleBridge;
+import org.hibernate.search.bridge.builtin.EnumBridge;
+import org.hibernate.search.bridge.builtin.FloatBridge;
+import org.hibernate.search.bridge.builtin.IntegerBridge;
+import org.hibernate.search.bridge.builtin.LongBridge;
+import org.hibernate.search.bridge.builtin.ShortBridge;
+import org.hibernate.search.bridge.builtin.StringBridge;
+import org.hibernate.search.bridge.builtin.UriBridge;
+import org.hibernate.search.bridge.builtin.UrlBridge;
+
+/**
+ * This factory is responsible for creating and initializing build-in and custom <i>FieldBridges</i>.
+ *
+ * @author Emmanuel Bernard
+ * @author John Griffin
+ */
+public class BridgeFactory {
+ private static Map<String, FieldBridge> builtInBridges = new HashMap<String, FieldBridge>();
+
+ private BridgeFactory() {
+ }
+
+ public static final TwoWayFieldBridge CHARACTER = new TwoWayString2FieldBridgeAdaptor( new CharacterBridge() );
+
+ public static final TwoWayFieldBridge DOUBLE = new TwoWayString2FieldBridgeAdaptor( new DoubleBridge() );
+
+ public static final TwoWayFieldBridge FLOAT = new TwoWayString2FieldBridgeAdaptor( new FloatBridge() );
+
+ public static final TwoWayFieldBridge SHORT = new TwoWayString2FieldBridgeAdaptor( new ShortBridge() );
+
+ public static final TwoWayFieldBridge INTEGER = new TwoWayString2FieldBridgeAdaptor( new IntegerBridge() );
+
+ public static final TwoWayFieldBridge LONG = new TwoWayString2FieldBridgeAdaptor( new LongBridge() );
+
+ public static final TwoWayFieldBridge BIG_INTEGER = new TwoWayString2FieldBridgeAdaptor( new BigIntegerBridge() );
+
+ public static final TwoWayFieldBridge BIG_DECIMAL = new TwoWayString2FieldBridgeAdaptor( new BigDecimalBridge() );
+
+ public static final TwoWayFieldBridge STRING = new TwoWayString2FieldBridgeAdaptor( new StringBridge() );
+
+ public static final TwoWayFieldBridge BOOLEAN = new TwoWayString2FieldBridgeAdaptor( new BooleanBridge() );
+
+ public static final TwoWayFieldBridge CLAZZ = new TwoWayString2FieldBridgeAdaptor( new org.hibernate.search.bridge.builtin.ClassBridge() );
+
+ public static final TwoWayFieldBridge Url = new TwoWayString2FieldBridgeAdaptor( new UrlBridge() );
+
+ public static final TwoWayFieldBridge Uri = new TwoWayString2FieldBridgeAdaptor( new UriBridge() );
+
+ public static final FieldBridge DATE_YEAR = new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_YEAR );
+ public static final FieldBridge DATE_MONTH = new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_MONTH );
+ public static final FieldBridge DATE_DAY = new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_DAY );
+ public static final FieldBridge DATE_HOUR = new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_HOUR );
+ public static final FieldBridge DATE_MINUTE = new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_MINUTE );
+ public static final FieldBridge DATE_SECOND = new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_SECOND );
+ public static final TwoWayFieldBridge DATE_MILLISECOND =
+ new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_MILLISECOND );
+
+ static {
+ builtInBridges.put( Character.class.getName(), CHARACTER );
+ builtInBridges.put( char.class.getName(), CHARACTER );
+ builtInBridges.put( Double.class.getName(), DOUBLE );
+ builtInBridges.put( double.class.getName(), DOUBLE );
+ builtInBridges.put( Float.class.getName(), FLOAT );
+ builtInBridges.put( float.class.getName(), FLOAT );
+ builtInBridges.put( Short.class.getName(), SHORT );
+ builtInBridges.put( short.class.getName(), SHORT );
+ builtInBridges.put( Integer.class.getName(), INTEGER );
+ builtInBridges.put( int.class.getName(), INTEGER );
+ builtInBridges.put( Long.class.getName(), LONG );
+ builtInBridges.put( long.class.getName(), LONG );
+ builtInBridges.put( BigInteger.class.getName(), BIG_INTEGER );
+ builtInBridges.put( BigDecimal.class.getName(), BIG_DECIMAL );
+ builtInBridges.put( String.class.getName(), STRING );
+ builtInBridges.put( Boolean.class.getName(), BOOLEAN );
+ builtInBridges.put( boolean.class.getName(), BOOLEAN );
+ builtInBridges.put( Class.class.getName(), CLAZZ );
+ builtInBridges.put( URL.class.getName(), Url );
+ builtInBridges.put( URI.class.getName(), Uri );
+
+ builtInBridges.put( Date.class.getName(), DATE_MILLISECOND );
+ }
+
+ /**
+ * This extracts and instantiates the implementation class from a ClassBridge
+ * annotation.
+ *
+ * @param cb the ClassBridge
+ * @return FieldBridge
+ */
+ public static FieldBridge extractType(ClassBridge cb)
+ {
+ FieldBridge bridge = null;
+
+ if ( cb != null ) {
+ Class<?> impl = cb.impl();
+ //TODO better error information ( see guessType() )
+ if (impl != null) {
+ try {
+ Object instance = impl.newInstance();
+ if ( FieldBridge.class.isAssignableFrom( impl ) ) {
+ bridge = (FieldBridge) instance;
+ }
+ else if ( org.hibernate.search.bridge.TwoWayStringBridge.class.isAssignableFrom( impl ) ) {
+ bridge = new TwoWayString2FieldBridgeAdaptor(
+ (org.hibernate.search.bridge.TwoWayStringBridge) instance );
+ }
+ else if ( org.hibernate.search.bridge.StringBridge.class.isAssignableFrom( impl ) ) {
+ bridge = new String2FieldBridgeAdaptor( (org.hibernate.search.bridge.StringBridge) instance );
+ }
+ else {
+ throw new SearchException("@ClassBridge implementation implements none of the field bridge interfaces: "
+ + impl );
+ }
+ if ( cb.params().length > 0 && ParameterizedBridge.class.isAssignableFrom( impl ) ) {
+ Map<String, String> params = new HashMap<String, String>( cb.params().length );
+ for ( Parameter param : cb.params() ) {
+ params.put( param.name(), param.value() );
+ }
+ ( (ParameterizedBridge) instance ).setParameterValues( params );
+ }
+ }
+ catch (Exception e) {
+ throw new HibernateException( "Unable to instantiate ClassBridge for " + impl.getName(), e );
+ }
+ }
+ }
+ if ( bridge == null ) throw new SearchException( "Unable to guess FieldBridge for " + ClassBridge.class.getName() );
+
+ return bridge;
+ }
+
+ public static FieldBridge guessType(Field field, XMember member, ReflectionManager reflectionManager) {
+ FieldBridge bridge;
+ org.hibernate.search.annotations.FieldBridge bridgeAnn;
+ //@Field bridge has priority over @FieldBridge
+ if ( field != null && void.class != field.bridge().impl() ) {
+ bridgeAnn = field.bridge();
+ }
+ else {
+ bridgeAnn = member.getAnnotation( org.hibernate.search.annotations.FieldBridge.class );
+ }
+ final String memberName = member.getName();
+ if ( bridgeAnn != null ) {
+ bridge = doExtractType( bridgeAnn, memberName );
+ }
+ else if ( member.isAnnotationPresent( org.hibernate.search.annotations.DateBridge.class ) ) {
+ Resolution resolution =
+ member.getAnnotation( org.hibernate.search.annotations.DateBridge.class ).resolution();
+ bridge = getDateField( resolution );
+ }
+ else {
+ //find in built-ins
+ XClass returnType = member.getType();
+ bridge = builtInBridges.get( returnType.getName() );
+ if ( bridge == null && returnType.isEnum() ) {
+ bridge = new TwoWayString2FieldBridgeAdaptor(
+ new EnumBridge( reflectionManager.toClass( returnType ) )
+ );
+ }
+ }
+ //TODO add classname
+ if ( bridge == null ) throw new SearchException( "Unable to guess FieldBridge for " + memberName );
+ return bridge;
+ }
+
+ /** assume not null bridgeAnn */
+ private static FieldBridge doExtractType(org.hibernate.search.annotations.FieldBridge bridgeAnn, String memberName) {
+ assert bridgeAnn != null : "doExtractType assume bridge instance not null";
+ FieldBridge bridge;
+ Class impl = bridgeAnn.impl();
+ if (impl == void.class)
+ throw new SearchException("@FieldBridge with no implementation class defined in: " + memberName );
+ try {
+ Object instance = impl.newInstance();
+ if ( FieldBridge.class.isAssignableFrom( impl ) ) {
+ bridge = (FieldBridge) instance;
+ }
+ else if ( TwoWayStringBridge.class.isAssignableFrom( impl ) ) {
+ bridge = new TwoWayString2FieldBridgeAdaptor(
+ ( TwoWayStringBridge) instance );
+ }
+ else if ( org.hibernate.search.bridge.StringBridge.class.isAssignableFrom( impl ) ) {
+ bridge = new String2FieldBridgeAdaptor( (org.hibernate.search.bridge.StringBridge) instance );
+ }
+ else {
+ throw new SearchException("@FieldBridge implementation implements none of the field bridge interfaces: "
+ + impl + " in " + memberName
+ );
+ }
+ if ( bridgeAnn.params().length > 0 && ParameterizedBridge.class.isAssignableFrom( impl ) ) {
+ Map<String, String> params = new HashMap<String, String>( bridgeAnn.params().length );
+ for ( Parameter param : bridgeAnn.params() ) {
+ params.put( param.name(), param.value() );
+ }
+ ( (ParameterizedBridge) instance ).setParameterValues( params );
+ }
+ }
+ catch (Exception e) {
+ //TODO add classname
+ throw new SearchException( "Unable to instanciate FieldBridge for " + memberName, e );
+ }
+ return bridge;
+ }
+
+ public static FieldBridge getDateField(Resolution resolution) {
+ switch (resolution) {
+ case YEAR:
+ return DATE_YEAR;
+ case MONTH:
+ return DATE_MONTH;
+ case DAY:
+ return DATE_DAY;
+ case HOUR:
+ return DATE_HOUR;
+ case MINUTE:
+ return DATE_MINUTE;
+ case SECOND:
+ return DATE_SECOND;
+ case MILLISECOND:
+ return DATE_MILLISECOND;
+ default:
+ throw new AssertionFailure( "Unknown Resolution: " + resolution );
+ }
+ }
+
+ /**
+ * Takes in a fieldBridge and will return you a TwoWayFieldBridge instance.
+ *
+ * @param fieldBridge
+ *
+ * @return a TwoWayFieldBridge instance if the Field Bridge is an instance of a TwoWayFieldBridge.
+ *
+ * @throws SearchException if the FieldBridge passed in is not an instance of a TwoWayFieldBridge.
+ */
+
+ public static TwoWayFieldBridge extractTwoWayType(org.hibernate.search.annotations.FieldBridge fieldBridge) {
+ FieldBridge fb = extractType( fieldBridge );
+ if ( fb instanceof TwoWayFieldBridge ) {
+ return ( TwoWayFieldBridge ) fb;
+ }
+ else {
+ throw new SearchException( "FieldBridge passed in is not an instance of " + TwoWayFieldBridge.class.getSimpleName() );
+ }
+ }
+
+ /**
+ * This extracts and instantiates the implementation class from a ClassBridge
+ * annotation.
+ *
+ * @param fieldBridgeAnnotation the FieldBridge annotation
+ *
+ * @return FieldBridge
+ */
+ public static FieldBridge extractType(org.hibernate.search.annotations.FieldBridge fieldBridgeAnnotation) {
+ FieldBridge bridge = null;
+
+ if ( fieldBridgeAnnotation != null ) {
+ bridge = doExtractType( fieldBridgeAnnotation, null );
+ }
+
+ if ( bridge == null ) {
+ throw new SearchException(
+ "Unable to guess FieldBridge for " + org.hibernate.search.annotations.FieldBridge.class.getName()
+ );
+ }
+
+ return bridge;
+ }
+
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/FieldBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/FieldBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/FieldBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,29 +1,52 @@
-//$Id$
-package org.hibernate.search.bridge;
-
-import org.apache.lucene.document.Document;
-
-/**
- * Link between a java property and a Lucene Document
- * Usually a Java property will be linked to a Document Field.
- * <p/>
- * All implementations need to be threadsafe.
- *
- * @author Emmanuel Bernard
- */
-public interface FieldBridge {
-
- /**
- * Manipulate the document to index the given value.
- * <p/>
- * A common implementation is to add a Field with the given {@code name} to {@code document} following
- * the parameters {@code luceneOptions} if the {@code value} is not {@code null}.
- *
- * @param name The field to add to the Lucene document
- * @param value The actual value to index
- * @param document The Lucene document into which we want to index the value.
- * @param luceneOptions Contains the parameters used for adding {@code value} to
- * the Lucene document.
- */
- void set(String name, Object value, Document document, LuceneOptions luceneOptions);
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge;
+
+import org.apache.lucene.document.Document;
+
+/**
+ * Link between a java property and a Lucene Document
+ * Usually a Java property will be linked to a Document Field.
+ * <p/>
+ * All implementations need to be threadsafe.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface FieldBridge {
+
+ /**
+ * Manipulate the document to index the given value.
+ * <p/>
+ * A common implementation is to add a Field with the given {@code name} to {@code document} following
+ * the parameters {@code luceneOptions} if the {@code value} is not {@code null}.
+ *
+ * @param name The field to add to the Lucene document
+ * @param value The actual value to index
+ * @param document The Lucene document into which we want to index the value.
+ * @param luceneOptions Contains the parameters used for adding {@code value} to
+ * the Lucene document.
+ */
+ void set(String name, Object value, Document document, LuceneOptions luceneOptions);
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/LuceneOptions.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/LuceneOptions.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/LuceneOptions.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.bridge;
import org.apache.lucene.document.Field;
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/ParameterizedBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/ParameterizedBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/ParameterizedBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,18 +1,41 @@
-//$Id$
-package org.hibernate.search.bridge;
-
-import java.util.Map;
-
-/**
- * Allow parameter injection to a given bridge.
- *
- * Implementors need to be threadsafe, but the
- * setParameterValues method doesn't need any
- * guard as initialization is always safe.
- *
- * @author Emmanuel Bernard
- */
-public interface ParameterizedBridge {
- //TODO inject Properties? since the annotations cannot support Object attribute?
- void setParameterValues(Map parameters);
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge;
+
+import java.util.Map;
+
+/**
+ * Allow parameter injection to a given bridge.
+ *
+ * Implementors need to be threadsafe, but the
+ * setParameterValues method doesn't need any
+ * guard as initialization is always safe.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface ParameterizedBridge {
+ //TODO inject Properties? since the annotations cannot support Object attribute?
+ void setParameterValues(Map parameters);
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/String2FieldBridgeAdaptor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/String2FieldBridgeAdaptor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/String2FieldBridgeAdaptor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,31 +1,54 @@
-//$Id$
-package org.hibernate.search.bridge;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.hibernate.util.StringHelper;
-
-/**
- * Bridge to use a StringBridge as a FieldBridge.
- *
- * @author Emmanuel Bernard
- */
-public class String2FieldBridgeAdaptor implements FieldBridge {
- private final StringBridge stringBridge;
-
- public String2FieldBridgeAdaptor(StringBridge stringBridge) {
- this.stringBridge = stringBridge;
- }
-
- public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
- String indexedString = stringBridge.objectToString( value );
- //Do not add fields on empty strings, seems a sensible default in most situations
- //TODO if Store, probably also save empty ones
- if ( StringHelper.isNotEmpty( indexedString ) ) {
- Field field = new Field( name, indexedString, luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector() );
- field.setBoost( luceneOptions.getBoost() );
- document.add( field );
- }
- }
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Bridge to use a StringBridge as a FieldBridge.
+ *
+ * @author Emmanuel Bernard
+ */
+public class String2FieldBridgeAdaptor implements FieldBridge {
+ private final StringBridge stringBridge;
+
+ public String2FieldBridgeAdaptor(StringBridge stringBridge) {
+ this.stringBridge = stringBridge;
+ }
+
+ public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
+ String indexedString = stringBridge.objectToString( value );
+ //Do not add fields on empty strings, seems a sensible default in most situations
+ //TODO if Store, probably also save empty ones
+ if ( StringHelper.isNotEmpty( indexedString ) ) {
+ Field field = new Field( name, indexedString, luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector() );
+ field.setBoost( luceneOptions.getBoost() );
+ document.add( field );
+ }
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/StringBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/StringBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/StringBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,24 +1,47 @@
-//$Id$
-package org.hibernate.search.bridge;
-
-/**
- * Transform an object into a string representation.
- *
- * All implementations are required to be threadsafe.
- * Usually this is easily achieved avoiding the usage
- * of class fields, unless they are either immutable
- * or needed to store parameters.
- *
- * @author Emmanuel Bernard
- */
-public interface StringBridge {
-
- /**
- * Converts the object representation to a string.
- *
- * @param object The object to transform into a string representation.
- * @return String representation of the given object to be stored in Lucene index. The return string must not be
- * <code>null</code>. It can be empty though.
- */
- String objectToString(Object object);
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge;
+
+/**
+ * Transform an object into a string representation.
+ *
+ * All implementations are required to be threadsafe.
+ * Usually this is easily achieved avoiding the usage
+ * of class fields, unless they are either immutable
+ * or needed to store parameters.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface StringBridge {
+
+ /**
+ * Converts the object representation to a string.
+ *
+ * @param object The object to transform into a string representation.
+ * @return String representation of the given object to be stored in Lucene index. The return string must not be
+ * <code>null</code>. It can be empty though.
+ */
+ String objectToString(Object object);
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/TwoWayFieldBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/TwoWayFieldBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/TwoWayFieldBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,32 +1,55 @@
-//$Id$
-package org.hibernate.search.bridge;
-
-import org.apache.lucene.document.Document;
-
-/**
- * A <code>FieldBridge</code> able to convert the index representation back into an object without losing information.
- * Any bridge expected to process a document id should implement this interface.
- *
- * @author Emmanuel Bernard
- */
-// FIXME rework the interface inheritance there are some common concepts with StringBridge
-public interface TwoWayFieldBridge extends FieldBridge {
- /**
- * Build the element object from the <code>Document</code>
- *
- * @param name field name
- * @param document document
- *
- * @return The return value is the entity property value.
- */
- Object get(String name, Document document);
-
- /**
- * Convert the object representation to a string.
- *
- * @param object The object to index.
- * @return string (index) representationT of the specified object. Must not be <code>null</code>, but
- * can be empty.
- */
- String objectToString(Object object);
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge;
+
+import org.apache.lucene.document.Document;
+
+/**
+ * A <code>FieldBridge</code> able to convert the index representation back into an object without losing information.
+ * Any bridge expected to process a document id should implement this interface.
+ *
+ * @author Emmanuel Bernard
+ */
+// FIXME rework the interface inheritance there are some common concepts with StringBridge
+public interface TwoWayFieldBridge extends FieldBridge {
+ /**
+ * Build the element object from the <code>Document</code>
+ *
+ * @param name field name
+ * @param document document
+ *
+ * @return The return value is the entity property value.
+ */
+ Object get(String name, Document document);
+
+ /**
+ * Convert the object representation to a string.
+ *
+ * @param object The object to index.
+ * @return string (index) representationT of the specified object. Must not be <code>null</code>, but
+ * can be empty.
+ */
+ String objectToString(Object object);
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/TwoWayString2FieldBridgeAdaptor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/TwoWayString2FieldBridgeAdaptor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/TwoWayString2FieldBridgeAdaptor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,35 +1,58 @@
-//$Id$
-package org.hibernate.search.bridge;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-
-/**
- * Bridge to use a TwoWayStringBridge as a TwoWayFieldBridge
- *
- * @author Emmanuel Bernard
- */
-//TODO use Generics to avoid double declaration of stringBridge
-public class TwoWayString2FieldBridgeAdaptor extends String2FieldBridgeAdaptor implements TwoWayFieldBridge {
-
- private final TwoWayStringBridge stringBridge;
-
- public TwoWayString2FieldBridgeAdaptor(TwoWayStringBridge stringBridge) {
- super( stringBridge );
- this.stringBridge = stringBridge;
- }
-
- public String objectToString(Object object) {
- return stringBridge.objectToString( object );
- }
-
- public Object get(String name, Document document) {
- Field field = document.getField( name );
- if (field == null) {
- return stringBridge.stringToObject( null );
- }
- else {
- return stringBridge.stringToObject( field.stringValue() );
- }
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+
+/**
+ * Bridge to use a TwoWayStringBridge as a TwoWayFieldBridge
+ *
+ * @author Emmanuel Bernard
+ */
+//TODO use Generics to avoid double declaration of stringBridge
+public class TwoWayString2FieldBridgeAdaptor extends String2FieldBridgeAdaptor implements TwoWayFieldBridge {
+
+ private final TwoWayStringBridge stringBridge;
+
+ public TwoWayString2FieldBridgeAdaptor(TwoWayStringBridge stringBridge) {
+ super( stringBridge );
+ this.stringBridge = stringBridge;
+ }
+
+ public String objectToString(Object object) {
+ return stringBridge.objectToString( object );
+ }
+
+ public Object get(String name, Document document) {
+ Field field = document.getField( name );
+ if (field == null) {
+ return stringBridge.stringToObject( null );
+ }
+ else {
+ return stringBridge.stringToObject( field.stringValue() );
+ }
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/TwoWayStringBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/TwoWayStringBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/TwoWayStringBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,27 +1,50 @@
-//$Id$
-package org.hibernate.search.bridge;
-
-/**
- * <code>StringBridge<code> allowing a translation from the string representation back to the <code>Object</code>.
- * <code>objectToString( stringToObject( string ) )</code> and <code>stringToObject( objectToString( object ) )</code>
- * should be "idempotent". More precisely:
- * <ul>
- * <li><code>objectToString( stringToObject( string ) ).equals(string)</code>, for non <code>null</code> string.</li>
- * <li><code>stringToObject( objectToString( object ) ).equals(object)</code>, for non <code>null</code> object. </li>
- * </ul>
- *
- * As for all Bridges implementations must be threasafe.
- *
- * @author Emmanuel Bernard
- */
-public interface TwoWayStringBridge extends StringBridge {
-
- /**
- * Convert the index string representation to an object.
- *
- * @param stringValue The index value.
- * @return Takes the string representation from the Lucene index and transforms it back into the original
- * <code>Object</code>.
- */
- Object stringToObject(String stringValue);
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge;
+
+/**
+ * <code>StringBridge<code> allowing a translation from the string representation back to the <code>Object</code>.
+ * <code>objectToString( stringToObject( string ) )</code> and <code>stringToObject( objectToString( object ) )</code>
+ * should be "idempotent". More precisely:
+ * <ul>
+ * <li><code>objectToString( stringToObject( string ) ).equals(string)</code>, for non <code>null</code> string.</li>
+ * <li><code>stringToObject( objectToString( object ) ).equals(object)</code>, for non <code>null</code> object. </li>
+ * </ul>
+ *
+ * As for all Bridges implementations must be threasafe.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface TwoWayStringBridge extends StringBridge {
+
+ /**
+ * Convert the index string representation to an object.
+ *
+ * @param stringValue The index value.
+ * @return Takes the string representation from the Lucene index and transforms it back into the original
+ * <code>Object</code>.
+ */
+ Object stringToObject(String stringValue);
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/BigDecimalBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/BigDecimalBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/BigDecimalBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,18 +1,41 @@
-//$Id$
-package org.hibernate.search.bridge.builtin;
-
-import java.math.BigDecimal;
-
-import org.hibernate.util.StringHelper;
-
-/**
- * Map a BigDecimal element
- *
- * @author Emmanuel Bernard
- */
-public class BigDecimalBridge extends NumberBridge {
- public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty( stringValue ) ) return null;
- return new BigDecimal( stringValue );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge.builtin;
+
+import java.math.BigDecimal;
+
+import org.hibernate.util.StringHelper;
+
+/**
+ * Map a BigDecimal element
+ *
+ * @author Emmanuel Bernard
+ */
+public class BigDecimalBridge extends NumberBridge {
+ public Object stringToObject(String stringValue) {
+ if ( StringHelper.isEmpty( stringValue ) ) return null;
+ return new BigDecimal( stringValue );
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/BigIntegerBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/BigIntegerBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/BigIntegerBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,43 @@
-//$Id$
-package org.hibernate.search.bridge.builtin;
-
-import java.math.BigInteger;
-
-import org.hibernate.util.StringHelper;
-
-/**
- * Map a <code>BigInteger</code> element.
- *
- * @author Emmanuel Bernard
- */
-public class BigIntegerBridge extends NumberBridge {
- public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty( stringValue ) ) {
- return null;
- }
- return new BigInteger( stringValue );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge.builtin;
+
+import java.math.BigInteger;
+
+import org.hibernate.util.StringHelper;
+
+/**
+ * Map a <code>BigInteger</code> element.
+ *
+ * @author Emmanuel Bernard
+ */
+public class BigIntegerBridge extends NumberBridge {
+ public Object stringToObject(String stringValue) {
+ if ( StringHelper.isEmpty( stringValue ) ) {
+ return null;
+ }
+ return new BigInteger( stringValue );
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/BooleanBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/BooleanBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/BooleanBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.bridge.builtin;
import org.hibernate.search.bridge.TwoWayStringBridge;
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/CharacterBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/CharacterBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/CharacterBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,28 +1,51 @@
-// $Id:$
-package org.hibernate.search.bridge.builtin;
-
-import org.hibernate.util.StringHelper;
-
-/**
- * Map a character element
- *
- * @author Davide D'Alto
- */
-public class CharacterBridge implements org.hibernate.search.bridge.TwoWayStringBridge {
-
- public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty( stringValue ) ) {
- return null;
- }
- if ( stringValue.length() > 1 ) {
- throw new IllegalArgumentException( "<" + stringValue + "> is not a char" );
- }
- return stringValue.charAt( 0 );
- }
-
- public String objectToString(Object object) {
- return object == null
- ? null
- : object.toString();
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge.builtin;
+
+import org.hibernate.util.StringHelper;
+
+/**
+ * Map a character element
+ *
+ * @author Davide D'Alto
+ */
+public class CharacterBridge implements org.hibernate.search.bridge.TwoWayStringBridge {
+
+ public Object stringToObject(String stringValue) {
+ if ( StringHelper.isEmpty( stringValue ) ) {
+ return null;
+ }
+ if ( stringValue.length() > 1 ) {
+ throw new IllegalArgumentException( "<" + stringValue + "> is not a char" );
+ }
+ return stringValue.charAt( 0 );
+ }
+
+ public String objectToString(Object object) {
+ return object == null
+ ? null
+ : object.toString();
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/ClassBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/ClassBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/ClassBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.bridge.builtin;
import org.hibernate.search.bridge.TwoWayStringBridge;
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DateBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DateBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DateBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,108 +1,131 @@
-//$Id$
-package org.hibernate.search.bridge.builtin;
-
-import java.text.ParseException;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Map;
-
-import org.apache.lucene.document.DateTools;
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.search.bridge.ParameterizedBridge;
-import org.hibernate.search.annotations.Resolution;
-import org.hibernate.search.bridge.TwoWayStringBridge;
-import org.hibernate.util.StringHelper;
-
-/**
- * Bridge a java.util.Date to a String, truncated to the resolution
- * Date are stored GMT based
- * <p/>
- * ie
- * Resolution.YEAR: yyyy
- * Resolution.MONTH: yyyyMM
- * Resolution.DAY: yyyyMMdd
- * Resolution.HOUR: yyyyMMddHH
- * Resolution.MINUTE: yyyyMMddHHmm
- * Resolution.SECOND: yyyyMMddHHmmss
- * Resolution.MILLISECOND: yyyyMMddHHmmssSSS
- *
- * @author Emmanuel Bernard
- */
-//TODO split into StringBridge and TwoWayStringBridge?
-public class DateBridge implements TwoWayStringBridge, ParameterizedBridge {
-
- public static final TwoWayStringBridge DATE_YEAR = new DateBridge( Resolution.YEAR );
- public static final TwoWayStringBridge DATE_MONTH = new DateBridge( Resolution.MONTH );
- public static final TwoWayStringBridge DATE_DAY = new DateBridge( Resolution.DAY );
- public static final TwoWayStringBridge DATE_HOUR = new DateBridge( Resolution.HOUR );
- public static final TwoWayStringBridge DATE_MINUTE = new DateBridge( Resolution.MINUTE );
- public static final TwoWayStringBridge DATE_SECOND = new DateBridge( Resolution.SECOND );
- public static final TwoWayStringBridge DATE_MILLISECOND = new DateBridge( Resolution.MILLISECOND );
-
- private DateTools.Resolution resolution;
-
- public DateBridge() {
- }
-
- public DateBridge(Resolution resolution) {
- setResolution( resolution );
- }
-
- public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty( stringValue ) ) return null;
- try {
- return DateTools.stringToDate( stringValue );
- }
- catch (ParseException e) {
- throw new HibernateException( "Unable to parse into date: " + stringValue, e );
- }
- }
-
- public String objectToString(Object object) {
- return object != null ?
- DateTools.dateToString( (Date) object, resolution ) :
- null;
- }
-
- public void setParameterValues(Map parameters) {
- Object resolution = parameters.get( "resolution" );
- Resolution hibResolution;
- if ( resolution instanceof String ) {
- hibResolution = Resolution.valueOf( ( (String) resolution ).toUpperCase( Locale.ENGLISH ) );
- }
- else {
- hibResolution = (Resolution) resolution;
- }
- setResolution( hibResolution );
- }
-
- private void setResolution(Resolution hibResolution) {
- switch (hibResolution) {
- case YEAR:
- this.resolution = DateTools.Resolution.YEAR;
- break;
- case MONTH:
- this.resolution = DateTools.Resolution.MONTH;
- break;
- case DAY:
- this.resolution = DateTools.Resolution.DAY;
- break;
- case HOUR:
- this.resolution = DateTools.Resolution.HOUR;
- break;
- case MINUTE:
- this.resolution = DateTools.Resolution.MINUTE;
- break;
- case SECOND:
- this.resolution = DateTools.Resolution.SECOND;
- break;
- case MILLISECOND:
- this.resolution = DateTools.Resolution.MILLISECOND;
- break;
- default:
- throw new AssertionFailure( "Unknown Resolution: " + hibResolution );
-
- }
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge.builtin;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.lucene.document.DateTools;
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.search.bridge.ParameterizedBridge;
+import org.hibernate.search.annotations.Resolution;
+import org.hibernate.search.bridge.TwoWayStringBridge;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Bridge a java.util.Date to a String, truncated to the resolution
+ * Date are stored GMT based
+ * <p/>
+ * ie
+ * Resolution.YEAR: yyyy
+ * Resolution.MONTH: yyyyMM
+ * Resolution.DAY: yyyyMMdd
+ * Resolution.HOUR: yyyyMMddHH
+ * Resolution.MINUTE: yyyyMMddHHmm
+ * Resolution.SECOND: yyyyMMddHHmmss
+ * Resolution.MILLISECOND: yyyyMMddHHmmssSSS
+ *
+ * @author Emmanuel Bernard
+ */
+//TODO split into StringBridge and TwoWayStringBridge?
+public class DateBridge implements TwoWayStringBridge, ParameterizedBridge {
+
+ public static final TwoWayStringBridge DATE_YEAR = new DateBridge( Resolution.YEAR );
+ public static final TwoWayStringBridge DATE_MONTH = new DateBridge( Resolution.MONTH );
+ public static final TwoWayStringBridge DATE_DAY = new DateBridge( Resolution.DAY );
+ public static final TwoWayStringBridge DATE_HOUR = new DateBridge( Resolution.HOUR );
+ public static final TwoWayStringBridge DATE_MINUTE = new DateBridge( Resolution.MINUTE );
+ public static final TwoWayStringBridge DATE_SECOND = new DateBridge( Resolution.SECOND );
+ public static final TwoWayStringBridge DATE_MILLISECOND = new DateBridge( Resolution.MILLISECOND );
+
+ private DateTools.Resolution resolution;
+
+ public DateBridge() {
+ }
+
+ public DateBridge(Resolution resolution) {
+ setResolution( resolution );
+ }
+
+ public Object stringToObject(String stringValue) {
+ if ( StringHelper.isEmpty( stringValue ) ) return null;
+ try {
+ return DateTools.stringToDate( stringValue );
+ }
+ catch (ParseException e) {
+ throw new HibernateException( "Unable to parse into date: " + stringValue, e );
+ }
+ }
+
+ public String objectToString(Object object) {
+ return object != null ?
+ DateTools.dateToString( (Date) object, resolution ) :
+ null;
+ }
+
+ public void setParameterValues(Map parameters) {
+ Object resolution = parameters.get( "resolution" );
+ Resolution hibResolution;
+ if ( resolution instanceof String ) {
+ hibResolution = Resolution.valueOf( ( (String) resolution ).toUpperCase( Locale.ENGLISH ) );
+ }
+ else {
+ hibResolution = (Resolution) resolution;
+ }
+ setResolution( hibResolution );
+ }
+
+ private void setResolution(Resolution hibResolution) {
+ switch (hibResolution) {
+ case YEAR:
+ this.resolution = DateTools.Resolution.YEAR;
+ break;
+ case MONTH:
+ this.resolution = DateTools.Resolution.MONTH;
+ break;
+ case DAY:
+ this.resolution = DateTools.Resolution.DAY;
+ break;
+ case HOUR:
+ this.resolution = DateTools.Resolution.HOUR;
+ break;
+ case MINUTE:
+ this.resolution = DateTools.Resolution.MINUTE;
+ break;
+ case SECOND:
+ this.resolution = DateTools.Resolution.SECOND;
+ break;
+ case MILLISECOND:
+ this.resolution = DateTools.Resolution.MILLISECOND;
+ break;
+ default:
+ throw new AssertionFailure( "Unknown Resolution: " + hibResolution );
+
+ }
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DoubleBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DoubleBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DoubleBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,16 +1,39 @@
-//$Id$
-package org.hibernate.search.bridge.builtin;
-
-import org.hibernate.util.StringHelper;
-
-/**
- * Map a double element
- *
- * @author Emmanuel Bernard
- */
-public class DoubleBridge extends NumberBridge {
- public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty( stringValue ) ) return null;
- return new Double( stringValue );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge.builtin;
+
+import org.hibernate.util.StringHelper;
+
+/**
+ * Map a double element
+ *
+ * @author Emmanuel Bernard
+ */
+public class DoubleBridge extends NumberBridge {
+ public Object stringToObject(String stringValue) {
+ if ( StringHelper.isEmpty( stringValue ) ) return null;
+ return new Double( stringValue );
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/EnumBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/EnumBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/EnumBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.bridge.builtin;
import org.hibernate.search.bridge.TwoWayStringBridge;
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/FloatBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/FloatBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/FloatBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,16 +1,39 @@
-//$Id$
-package org.hibernate.search.bridge.builtin;
-
-import org.hibernate.util.StringHelper;
-
-/**
- * Map a float element
- *
- * @author Emmanuel Bernard
- */
-public class FloatBridge extends NumberBridge {
- public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty( stringValue ) ) return null;
- return new Float( stringValue );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge.builtin;
+
+import org.hibernate.util.StringHelper;
+
+/**
+ * Map a float element
+ *
+ * @author Emmanuel Bernard
+ */
+public class FloatBridge extends NumberBridge {
+ public Object stringToObject(String stringValue) {
+ if ( StringHelper.isEmpty( stringValue ) ) return null;
+ return new Float( stringValue );
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/IntegerBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/IntegerBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/IntegerBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,16 +1,39 @@
-//$Id$
-package org.hibernate.search.bridge.builtin;
-
-import org.hibernate.util.StringHelper;
-
-/**
- * Map an integer element
- *
- * @author Emmanuel Bernard
- */
-public class IntegerBridge extends NumberBridge {
- public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty( stringValue ) ) return null;
- return new Integer( stringValue );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge.builtin;
+
+import org.hibernate.util.StringHelper;
+
+/**
+ * Map an integer element
+ *
+ * @author Emmanuel Bernard
+ */
+public class IntegerBridge extends NumberBridge {
+ public Object stringToObject(String stringValue) {
+ if ( StringHelper.isEmpty( stringValue ) ) return null;
+ return new Integer( stringValue );
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/LongBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/LongBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/LongBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,16 +1,39 @@
-//$Id$
-package org.hibernate.search.bridge.builtin;
-
-import org.hibernate.util.StringHelper;
-
-/**
- * Map a long element
- *
- * @author Emmanuel Bernard
- */
-public class LongBridge extends NumberBridge {
- public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty( stringValue ) ) return null;
- return new Long( stringValue );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge.builtin;
+
+import org.hibernate.util.StringHelper;
+
+/**
+ * Map a long element
+ *
+ * @author Emmanuel Bernard
+ */
+public class LongBridge extends NumberBridge {
+ public Object stringToObject(String stringValue) {
+ if ( StringHelper.isEmpty( stringValue ) ) return null;
+ return new Long( stringValue );
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/NumberBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/NumberBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/NumberBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,17 +1,40 @@
-//$Id$
-package org.hibernate.search.bridge.builtin;
-
-import org.hibernate.search.bridge.TwoWayStringBridge;
-
-/**
- * Base class for numbers - integer, double, etc.
- *
- * @author Emmanuel Bernard
- */
-public abstract class NumberBridge implements TwoWayStringBridge {
- public String objectToString(Object object) {
- return object != null ?
- object.toString() :
- null;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge.builtin;
+
+import org.hibernate.search.bridge.TwoWayStringBridge;
+
+/**
+ * Base class for numbers - integer, double, etc.
+ *
+ * @author Emmanuel Bernard
+ */
+public abstract class NumberBridge implements TwoWayStringBridge {
+ public String objectToString(Object object) {
+ return object != null ?
+ object.toString() :
+ null;
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/ShortBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/ShortBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/ShortBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,16 +1,39 @@
-//$Id$
-package org.hibernate.search.bridge.builtin;
-
-import org.hibernate.util.StringHelper;
-
-/**
- * Map a short element
- *
- * @author Emmanuel Bernard
- */
-public class ShortBridge extends NumberBridge {
- public Object stringToObject(String stringValue) {
- if ( StringHelper.isEmpty( stringValue ) ) return null;
- return new Short( stringValue );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge.builtin;
+
+import org.hibernate.util.StringHelper;
+
+/**
+ * Map a short element
+ *
+ * @author Emmanuel Bernard
+ */
+public class ShortBridge extends NumberBridge {
+ public Object stringToObject(String stringValue) {
+ if ( StringHelper.isEmpty( stringValue ) ) return null;
+ return new Short( stringValue );
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/StringBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/StringBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/StringBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,17 +1,40 @@
-//$Id$
-package org.hibernate.search.bridge.builtin;
-
-/**
- * Map a string element
- *
- * @author Emmanuel Bernard
- */
-public class StringBridge implements org.hibernate.search.bridge.TwoWayStringBridge {
- public Object stringToObject(String stringValue) {
- return stringValue;
- }
-
- public String objectToString(Object object) {
- return (String) object;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.bridge.builtin;
+
+/**
+ * Map a string element
+ *
+ * @author Emmanuel Bernard
+ */
+public class StringBridge implements org.hibernate.search.bridge.TwoWayStringBridge {
+ public Object stringToObject(String stringValue) {
+ return stringValue;
+ }
+
+ public String objectToString(Object object) {
+ return (String) object;
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/UriBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/UriBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/UriBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.bridge.builtin;
import java.net.URI;
@@ -33,4 +56,4 @@
null :
object.toString();
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/UrlBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/UrlBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/UrlBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.bridge.builtin;
import java.net.URL;
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/AnalyzerDefMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/AnalyzerDefMapping.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/AnalyzerDefMapping.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.cfg;
import java.util.HashMap;
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/ConcatStringBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/ConcatStringBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/ConcatStringBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.cfg;
import java.util.Map;
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/DocumentIdMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/DocumentIdMapping.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/DocumentIdMapping.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.cfg;
import java.lang.annotation.ElementType;
@@ -47,4 +71,4 @@
return new EntityMapping(entityType, indexName, mapping);
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/EntityDescriptor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/EntityDescriptor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/EntityDescriptor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.cfg;
import java.lang.annotation.ElementType;
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/EntityMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/EntityMapping.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/EntityMapping.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.cfg;
import java.lang.annotation.ElementType;
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/FieldBridgeMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/FieldBridgeMapping.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/FieldBridgeMapping.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.cfg;
import java.util.Map;
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.cfg;
import java.lang.annotation.ElementType;
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/PropertyDescriptor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/PropertyDescriptor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/PropertyDescriptor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.cfg;
import java.lang.annotation.ElementType;
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/PropertyMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/PropertyMapping.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/PropertyMapping.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.cfg;
import java.lang.annotation.ElementType;
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/SearchConfiguration.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/SearchConfiguration.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/SearchConfiguration.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.cfg;
import java.util.Iterator;
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/SearchConfigurationFromHibernateCore.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/SearchConfigurationFromHibernateCore.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/SearchConfigurationFromHibernateCore.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.cfg;
import java.util.Iterator;
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.cfg;
import java.util.ArrayList;
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/TokenFilterDefMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/TokenFilterDefMapping.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/TokenFilterDefMapping.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.cfg;
import java.util.Map;
Modified: search/trunk/src/main/java/org/hibernate/search/engine/BoostStrategy.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/BoostStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/BoostStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
/**
Modified: search/trunk/src/main/java/org/hibernate/search/engine/DefaultBoostStrategy.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/DefaultBoostStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/DefaultBoostStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
/**
Modified: search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilder.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilder.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilder.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
import org.hibernate.search.ProjectionConstants;
Modified: search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,805 +1,828 @@
-//$Id$
-package org.hibernate.search.engine;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.search.Similarity;
-import org.slf4j.Logger;
-
-import org.hibernate.Hibernate;
-import org.hibernate.annotations.common.AssertionFailure;
-import org.hibernate.annotations.common.reflection.ReflectionManager;
-import org.hibernate.annotations.common.reflection.XAnnotatedElement;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XMember;
-import org.hibernate.annotations.common.reflection.XProperty;
-import org.hibernate.search.SearchException;
-import org.hibernate.search.analyzer.Discriminator;
-import org.hibernate.search.annotations.AnalyzerDef;
-import org.hibernate.search.annotations.AnalyzerDefs;
-import org.hibernate.search.annotations.AnalyzerDiscriminator;
-import org.hibernate.search.annotations.Boost;
-import org.hibernate.search.annotations.ClassBridge;
-import org.hibernate.search.annotations.ClassBridges;
-import org.hibernate.search.annotations.ContainedIn;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.DynamicBoost;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.IndexedEmbedded;
-import org.hibernate.search.annotations.Store;
-import org.hibernate.search.annotations.TermVector;
-import org.hibernate.search.backend.LuceneWork;
-import org.hibernate.search.backend.WorkType;
-import org.hibernate.search.bridge.BridgeFactory;
-import org.hibernate.search.bridge.FieldBridge;
-import org.hibernate.search.bridge.LuceneOptions;
-import org.hibernate.search.impl.InitContext;
-import org.hibernate.search.util.LoggerFactory;
-import org.hibernate.search.util.ReflectionHelper;
-import org.hibernate.search.util.ScopedAnalyzer;
-import org.hibernate.util.StringHelper;
-
-/**
- * Set up and provide a manager for classes which are indexed via <code>@IndexedEmbedded</code>, but themselves do not
- * contain the <code>@Indexed</code> annotation.
- *
- * @author Gavin King
- * @author Emmanuel Bernard
- * @author Sylvain Vieujot
- * @author Richard Hallier
- * @author Hardy Ferentschik
- */
-public class DocumentBuilderContainedEntity<T> implements DocumentBuilder {
- private static final Logger log = LoggerFactory.make();
-
- protected final PropertiesMetadata metadata = new PropertiesMetadata();
- protected final XClass beanClass;
- protected Set<Class<?>> mappedSubclasses = new HashSet<Class<?>>();
- protected ReflectionManager reflectionManager; //available only during initialization and post-initialization
- protected int level = 0;
- protected int maxLevel = Integer.MAX_VALUE;
- protected final ScopedAnalyzer analyzer = new ScopedAnalyzer();
- protected Similarity similarity;
- protected boolean isRoot;
- protected EntityState entityState;
-
- /**
- * Constructor used on contained entities not annotated with <code>@Indexed</code> themselves.
- *
- * @param clazz The class for which to build a <code>DocumentBuilderContainedEntity</code>.
- * @param context Handle to default configuration settings.
- * @param reflectionManager Reflection manager to use for processing the annotations.
- */
- public DocumentBuilderContainedEntity(XClass clazz, InitContext context, ReflectionManager reflectionManager) {
-
- if ( clazz == null ) {
- throw new AssertionFailure( "Unable to build a DocumentBuilderContainedEntity with a null class" );
- }
-
- this.entityState = EntityState.CONTAINED_IN_ONLY;
- this.beanClass = clazz;
- this.reflectionManager = reflectionManager;
-
- init( clazz, context );
-
- if ( metadata.containedInGetters.size() == 0 ) {
- this.entityState = EntityState.NON_INDEXABLE;
- }
- }
-
- protected void init(XClass clazz, InitContext context) {
- metadata.boost = getBoost( clazz );
- metadata.classBoostStrategy = getDynamicBoost( clazz );
- metadata.analyzer = context.getDefaultAnalyzer();
-
- Set<XClass> processedClasses = new HashSet<XClass>();
- processedClasses.add( clazz );
- initializeClass( clazz, metadata, true, "", processedClasses, context );
-
- this.analyzer.setGlobalAnalyzer( metadata.analyzer );
-
- // set the default similarity in case that after processing all classes there is still no similarity set
- if ( this.similarity == null ) {
- this.similarity = context.getDefaultSimilarity();
- }
- }
-
- public boolean isRoot() {
- return isRoot;
- }
-
- private void initializeClass(XClass clazz, PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix,
- Set<XClass> processedClasses, InitContext context) {
- List<XClass> hierarchy = new ArrayList<XClass>();
- for ( XClass currentClass = clazz; currentClass != null; currentClass = currentClass.getSuperclass() ) {
- hierarchy.add( currentClass );
- }
-
- /*
- * Iterate the class hierarchy top down. This allows to override the default analyzer for the properties if the class holds one
- */
- for ( int index = hierarchy.size() - 1; index >= 0; index-- ) {
- XClass currentClass = hierarchy.get( index );
-
- initializeClassLevelAnnotations( currentClass, propertiesMetadata, isRoot, prefix, context );
-
- // rejecting non properties (ie regular methods) because the object is loaded from Hibernate,
- // so indexing a non property does not make sense
- List<XProperty> methods = currentClass.getDeclaredProperties( XClass.ACCESS_PROPERTY );
- for ( XProperty method : methods ) {
- initializeMemberLevelAnnotations(
- method, propertiesMetadata, isRoot, prefix, processedClasses, context
- );
- }
-
- List<XProperty> fields = currentClass.getDeclaredProperties( XClass.ACCESS_FIELD );
- for ( XProperty field : fields ) {
- initializeMemberLevelAnnotations(
- field, propertiesMetadata, isRoot, prefix, processedClasses, context
- );
- }
- }
- }
-
- /**
- * Check and initialize class level annotations.
- *
- * @param clazz The class to process.
- * @param propertiesMetadata The meta data holder.
- * @param isRoot Flag indicating if the specified class is a root entity, meaning the start of a chain of indexed
- * entities.
- * @param prefix The current prefix used for the <code>Document</code> field names.
- * @param context Handle to default configuration settings.
- */
- private void initializeClassLevelAnnotations(XClass clazz, PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix, InitContext context) {
-
- // check for a class level specified analyzer
- Analyzer analyzer = getAnalyzer( clazz, context );
- if ( analyzer != null ) {
- propertiesMetadata.analyzer = analyzer;
- }
-
- // check for AnalyzerDefs annotations
- checkForAnalyzerDefs( clazz, context );
-
- // Check for any ClassBridges annotation.
- ClassBridges classBridgesAnn = clazz.getAnnotation( ClassBridges.class );
- if ( classBridgesAnn != null ) {
- ClassBridge[] classBridges = classBridgesAnn.value();
- for ( ClassBridge cb : classBridges ) {
- bindClassBridgeAnnotation( prefix, propertiesMetadata, cb, context );
- }
- }
-
- // Check for any ClassBridge style of annotations.
- ClassBridge classBridgeAnn = clazz.getAnnotation( ClassBridge.class );
- if ( classBridgeAnn != null ) {
- bindClassBridgeAnnotation( prefix, propertiesMetadata, classBridgeAnn, context );
- }
-
- checkForAnalyzerDiscriminator( clazz, propertiesMetadata );
-
- // Get similarity
- //TODO: similarity form @IndexedEmbedded are not taken care of. Exception??
- if ( isRoot ) {
- checkForSimilarity( clazz );
- }
- }
-
- protected void initializeMemberLevelAnnotations(XProperty member, PropertiesMetadata propertiesMetadata, boolean isRoot,
- String prefix, Set<XClass> processedClasses, InitContext context) {
- checkDocumentId( member, propertiesMetadata, isRoot, prefix, context );
- checkForField( member, propertiesMetadata, prefix, context );
- checkForFields( member, propertiesMetadata, prefix, context );
- checkForAnalyzerDefs( member, context );
- checkForAnalyzerDiscriminator( member, propertiesMetadata );
- checkForIndexedEmbedded( member, propertiesMetadata, prefix, processedClasses, context );
- checkForContainedIn( member, propertiesMetadata );
- }
-
- protected Analyzer getAnalyzer(XAnnotatedElement annotatedElement, InitContext context) {
- org.hibernate.search.annotations.Analyzer analyzerAnn =
- annotatedElement.getAnnotation( org.hibernate.search.annotations.Analyzer.class );
- return getAnalyzer( analyzerAnn, context );
- }
-
- protected Analyzer getAnalyzer(org.hibernate.search.annotations.Analyzer analyzerAnn, InitContext context) {
- Class analyzerClass = analyzerAnn == null ? void.class : analyzerAnn.impl();
- if ( analyzerClass == void.class ) {
- String definition = analyzerAnn == null ? "" : analyzerAnn.definition();
- if ( StringHelper.isEmpty( definition ) ) {
- return null;
- }
- else {
-
- return context.buildLazyAnalyzer( definition );
- }
- }
- else {
- try {
- return ( Analyzer ) analyzerClass.newInstance();
- }
- catch ( ClassCastException e ) {
- throw new SearchException(
- "Lucene analyzer does not implement " + Analyzer.class.getName() + ": " + analyzerClass.getName(),
- e
- );
- }
- catch ( Exception e ) {
- throw new SearchException(
- "Failed to instantiate lucene analyzer with type " + analyzerClass.getName(), e
- );
- }
- }
- }
-
- private void checkForAnalyzerDefs(XAnnotatedElement annotatedElement, InitContext context) {
- AnalyzerDefs defs = annotatedElement.getAnnotation( AnalyzerDefs.class );
- if ( defs != null ) {
- for ( AnalyzerDef def : defs.value() ) {
- context.addAnalyzerDef( def );
- }
- }
- AnalyzerDef def = annotatedElement.getAnnotation( AnalyzerDef.class );
- context.addAnalyzerDef( def );
- }
-
- private void checkForAnalyzerDiscriminator(XAnnotatedElement annotatedElement, PropertiesMetadata propertiesMetadata) {
- AnalyzerDiscriminator discriminatorAnn = annotatedElement.getAnnotation( AnalyzerDiscriminator.class );
- if ( discriminatorAnn != null ) {
- if ( propertiesMetadata.discriminator != null ) {
- throw new SearchException(
- "Multiple AnalyzerDiscriminator defined in the same class hierarchy: " + beanClass.getName()
- );
- }
-
- Class<? extends Discriminator> discriminatorClass = discriminatorAnn.impl();
- try {
- propertiesMetadata.discriminator = discriminatorClass.newInstance();
- }
- catch ( Exception e ) {
- throw new SearchException(
- "Unable to instantiate analyzer discriminator implementation: " + discriminatorClass.getName()
- );
- }
-
- if ( annotatedElement instanceof XMember ) {
- propertiesMetadata.discriminatorGetter = ( XMember ) annotatedElement;
- }
- }
- }
-
- public Similarity getSimilarity() {
- return similarity;
- }
-
- private void checkForFields(XProperty member, PropertiesMetadata propertiesMetadata, String prefix, InitContext context) {
- org.hibernate.search.annotations.Fields fieldsAnn =
- member.getAnnotation( org.hibernate.search.annotations.Fields.class );
- if ( fieldsAnn != null ) {
- for ( org.hibernate.search.annotations.Field fieldAnn : fieldsAnn.value() ) {
- bindFieldAnnotation( member, propertiesMetadata, prefix, fieldAnn, context );
- }
- }
- }
-
- private void checkForSimilarity(XClass currClass) {
- org.hibernate.search.annotations.Similarity similarityAnn = currClass.getAnnotation( org.hibernate.search.annotations.Similarity.class );
- if ( similarityAnn != null ) {
- if ( similarity != null ) {
- throw new SearchException(
- "Multiple Similarities defined in the same class hierarchy: " + beanClass.getName()
- );
- }
- Class similarityClass = similarityAnn.impl();
- try {
- similarity = ( Similarity ) similarityClass.newInstance();
- }
- catch ( Exception e ) {
- log.error(
- "Exception attempting to instantiate Similarity '{}' set for {}",
- similarityClass.getName(), beanClass.getName()
- );
- }
- }
- }
-
- private void checkForField(XProperty member, PropertiesMetadata propertiesMetadata, String prefix, InitContext context) {
- org.hibernate.search.annotations.Field fieldAnn =
- member.getAnnotation( org.hibernate.search.annotations.Field.class );
- if ( fieldAnn != null ) {
- bindFieldAnnotation( member, propertiesMetadata, prefix, fieldAnn, context );
- }
- }
-
- private void checkForContainedIn(XProperty member, PropertiesMetadata propertiesMetadata) {
- ContainedIn containedAnn = member.getAnnotation( ContainedIn.class );
- if ( containedAnn != null ) {
- ReflectionHelper.setAccessible( member );
- propertiesMetadata.containedInGetters.add( member );
- }
- }
-
- private void checkForIndexedEmbedded(XProperty member, PropertiesMetadata propertiesMetadata, String prefix, Set<XClass> processedClasses, InitContext context) {
- IndexedEmbedded embeddedAnn = member.getAnnotation( IndexedEmbedded.class );
- if ( embeddedAnn != null ) {
- int oldMaxLevel = maxLevel;
- int potentialLevel = embeddedAnn.depth() + level;
- if ( potentialLevel < 0 ) {
- potentialLevel = Integer.MAX_VALUE;
- }
- maxLevel = potentialLevel > maxLevel ? maxLevel : potentialLevel;
- level++;
-
- XClass elementClass;
- if ( void.class == embeddedAnn.targetElement() ) {
- elementClass = member.getElementClass();
- }
- else {
- elementClass = reflectionManager.toXClass( embeddedAnn.targetElement() );
- }
- if ( maxLevel == Integer.MAX_VALUE //infinite
- && processedClasses.contains( elementClass ) ) {
- throw new SearchException(
- "Circular reference. Duplicate use of "
- + elementClass.getName()
- + " in root entity " + beanClass.getName()
- + "#" + buildEmbeddedPrefix( prefix, embeddedAnn, member )
- );
- }
- if ( level <= maxLevel ) {
- processedClasses.add( elementClass ); //push
-
- ReflectionHelper.setAccessible( member );
- propertiesMetadata.embeddedGetters.add( member );
- PropertiesMetadata metadata = new PropertiesMetadata();
- propertiesMetadata.embeddedPropertiesMetadata.add( metadata );
- metadata.boost = getBoost( member, null );
- //property > entity analyzer
- Analyzer analyzer = getAnalyzer( member, context );
- metadata.analyzer = analyzer != null ? analyzer : propertiesMetadata.analyzer;
- String localPrefix = buildEmbeddedPrefix( prefix, embeddedAnn, member );
- initializeClass( elementClass, metadata, false, localPrefix, processedClasses, context );
- /**
- * We will only index the "expected" type but that's OK, HQL cannot do down-casting either
- */
- if ( member.isArray() ) {
- propertiesMetadata.embeddedContainers.add( PropertiesMetadata.Container.ARRAY );
- }
- else if ( member.isCollection() ) {
- if ( Map.class.equals( member.getCollectionClass() ) ) {
- //hum subclasses etc etc??
- propertiesMetadata.embeddedContainers.add( PropertiesMetadata.Container.MAP );
- }
- else {
- propertiesMetadata.embeddedContainers.add( PropertiesMetadata.Container.COLLECTION );
- }
- }
- else {
- propertiesMetadata.embeddedContainers.add( PropertiesMetadata.Container.OBJECT );
- }
-
- processedClasses.remove( elementClass ); //pop
- }
- else if ( log.isTraceEnabled() ) {
- String localPrefix = buildEmbeddedPrefix( prefix, embeddedAnn, member );
- log.trace( "depth reached, ignoring {}", localPrefix );
- }
-
- level--;
- maxLevel = oldMaxLevel; //set back the the old max level
- }
- }
-
- protected void checkDocumentId(XProperty member, PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix, InitContext context) {
- Annotation documentIdAnn = member.getAnnotation( DocumentId.class );
- if ( documentIdAnn != null ) {
- log.warn(
- "@DocumentId specified on an entity which is not indexed by itself. Annotation gets ignored. Use @Field instead."
- );
- }
- }
-
- /**
- * Determines the property name for the document id. It is either the name of the property itself or the
- * value of the name attribute of the <code>idAnnotation</code>.
- *
- * @param member the property used as id property.
- * @param idAnnotation the id annotation
- *
- * @return property name to be used as document id.
- */
- protected String getIdAttributeName(XProperty member, Annotation idAnnotation) {
- String name = null;
- try {
- Method m = idAnnotation.getClass().getMethod( "name" );
- name = ( String ) m.invoke( idAnnotation );
- }
- catch ( Exception e ) {
- // ignore
- }
-
- return ReflectionHelper.getAttributeName( member, name );
- }
-
- private void bindClassBridgeAnnotation(String prefix, PropertiesMetadata propertiesMetadata, ClassBridge ann, InitContext context) {
- String fieldName = prefix + ann.name();
- propertiesMetadata.classNames.add( fieldName );
- propertiesMetadata.classStores.add( getStore( ann.store() ) );
- propertiesMetadata.classIndexes.add( getIndex( ann.index() ) );
- propertiesMetadata.classTermVectors.add( getTermVector( ann.termVector() ) );
- propertiesMetadata.classBridges.add( BridgeFactory.extractType( ann ) );
- propertiesMetadata.classBoosts.add( ann.boost().value() );
-
- Analyzer analyzer = getAnalyzer( ann.analyzer(), context );
- if ( analyzer == null ) {
- analyzer = propertiesMetadata.analyzer;
- }
- if ( analyzer == null ) {
- throw new AssertionFailure( "Analyzer should not be undefined" );
- }
- this.analyzer.addScopedAnalyzer( fieldName, analyzer );
- }
-
- private void bindFieldAnnotation(XProperty member, PropertiesMetadata propertiesMetadata, String prefix, org.hibernate.search.annotations.Field fieldAnn, InitContext context) {
- ReflectionHelper.setAccessible( member );
- propertiesMetadata.fieldGetters.add( member );
- String fieldName = prefix + ReflectionHelper.getAttributeName( member, fieldAnn.name() );
- propertiesMetadata.fieldNames.add( fieldName );
- propertiesMetadata.fieldStore.add( getStore( fieldAnn.store() ) );
- propertiesMetadata.fieldIndex.add( getIndex( fieldAnn.index() ) );
- propertiesMetadata.fieldBoosts.add( getBoost( member, fieldAnn ) );
- propertiesMetadata.dynamicFieldBoosts.add( getDynamicBoost( member ) );
- propertiesMetadata.fieldTermVectors.add( getTermVector( fieldAnn.termVector() ) );
- propertiesMetadata.fieldBridges.add( BridgeFactory.guessType( fieldAnn, member, reflectionManager ) );
-
- // Field > property > entity analyzer
- Analyzer analyzer = getAnalyzer( fieldAnn.analyzer(), context );
- if ( analyzer == null ) {
- analyzer = getAnalyzer( member, context );
- }
- if ( analyzer != null ) {
- this.analyzer.addScopedAnalyzer( fieldName, analyzer );
- }
- }
-
- protected Float getBoost(XProperty member, org.hibernate.search.annotations.Field fieldAnn) {
- float computedBoost = 1.0f;
- Boost boostAnn = member.getAnnotation( Boost.class );
- if ( boostAnn != null ) {
- computedBoost = boostAnn.value();
- }
- if ( fieldAnn != null ) {
- computedBoost *= fieldAnn.boost().value();
- }
- return computedBoost;
- }
-
- protected BoostStrategy getDynamicBoost(XProperty member) {
- DynamicBoost boostAnnotation = member.getAnnotation( DynamicBoost.class );
- if ( boostAnnotation == null ) {
- return new DefaultBoostStrategy();
- }
-
- Class<? extends BoostStrategy> boostStrategyClass = boostAnnotation.impl();
- BoostStrategy strategy;
- try {
- strategy = boostStrategyClass.newInstance();
- }
- catch ( Exception e ) {
- throw new SearchException(
- "Unable to instantiate boost strategy implementation: " + boostStrategyClass.getName()
- );
- }
- return strategy;
- }
-
- private String buildEmbeddedPrefix(String prefix, IndexedEmbedded embeddedAnn, XProperty member) {
- String localPrefix = prefix;
- if ( ".".equals( embeddedAnn.prefix() ) ) {
- //default to property name
- localPrefix += member.getName() + '.';
- }
- else {
- localPrefix += embeddedAnn.prefix();
- }
- return localPrefix;
- }
-
- protected 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 );
- }
- }
-
- protected Field.TermVector getTermVector(TermVector vector) {
- switch ( vector ) {
- case NO:
- return Field.TermVector.NO;
- case YES:
- return Field.TermVector.YES;
- case WITH_OFFSETS:
- return Field.TermVector.WITH_OFFSETS;
- case WITH_POSITIONS:
- return Field.TermVector.WITH_POSITIONS;
- case WITH_POSITION_OFFSETS:
- return Field.TermVector.WITH_POSITIONS_OFFSETS;
- default:
- throw new AssertionFailure( "Unexpected TermVector: " + vector );
- }
- }
-
- protected Field.Index getIndex(Index index) {
- switch ( index ) {
- case NO:
- return Field.Index.NO;
- case NO_NORMS:
- return Field.Index.NOT_ANALYZED_NO_NORMS;
- case TOKENIZED:
- return Field.Index.ANALYZED;
- case UN_TOKENIZED:
- return Field.Index.NOT_ANALYZED;
- default:
- throw new AssertionFailure( "Unexpected Index: " + index );
- }
- }
-
- protected Float getBoost(XClass element) {
- float boost = 1.0f;
- if ( element == null ) {
- return boost;
- }
- Boost boostAnnotation = element.getAnnotation( Boost.class );
- if ( boostAnnotation != null ) {
- boost = boostAnnotation.value();
- }
- return boost;
- }
-
- protected BoostStrategy getDynamicBoost(XClass element) {
- if ( element == null ) {
- return null;
- }
- DynamicBoost boostAnnotation = element.getAnnotation( DynamicBoost.class );
- if ( boostAnnotation == null ) {
- return new DefaultBoostStrategy();
- }
-
- Class<? extends BoostStrategy> boostStrategyClass = boostAnnotation.impl();
- BoostStrategy strategy;
- try {
- strategy = boostStrategyClass.newInstance();
- }
- catch ( Exception e ) {
- throw new SearchException(
- "Unable to instantiate boost strategy implementation: " + boostStrategyClass.getName()
- );
- }
- return strategy;
- }
-
- public void addWorkToQueue(Class<T> entityClass, T entity, Serializable id, WorkType workType, List<LuceneWork> queue, SearchFactoryImplementor searchFactoryImplementor) {
- /**
- * When references are changed, either null or another one, we expect dirty checking to be triggered (both sides
- * have to be updated)
- * When the internal object is changed, we apply the {Add|Update}Work on containedIns
- */
- if ( workType.searchForContainers() ) {
- processContainedInInstances( entity, queue, metadata, searchFactoryImplementor );
- }
- }
-
- /**
- * If we have a work instance we have to check whether the intance to be indexed is contained in any other indexed entities.
- *
- * @param instance The instance to be indexed
- * @param queue the current work queue
- * @param metadata metadata
- * @param searchFactoryImplementor the current session
- */
- private <T> void processContainedInInstances(Object instance, List<LuceneWork> queue, PropertiesMetadata metadata, SearchFactoryImplementor searchFactoryImplementor) {
- for ( int i = 0; i < metadata.containedInGetters.size(); i++ ) {
- XMember member = metadata.containedInGetters.get( i );
- Object value = ReflectionHelper.getMemberValue( instance, member );
-
- if ( value == null ) {
- continue;
- }
-
- if ( member.isArray() ) {
- @SuppressWarnings("unchecked")
- T[] array = ( T[] ) value;
- for ( T arrayValue : array ) {
- processSingleContainedInInstance( queue, searchFactoryImplementor, arrayValue );
- }
- }
- else if ( member.isCollection() ) {
- Collection<T> collection = getActualCollection( member, value );
- for ( T collectionValue : collection ) {
- processSingleContainedInInstance( queue, searchFactoryImplementor, collectionValue );
- }
- }
- else {
- processSingleContainedInInstance( queue, searchFactoryImplementor, value );
- }
- }
- }
-
- /**
- * A {@code XMember } instance treats a map as a collection as well in which case the map values are returned as
- * collection.
- *
- * @param member The member instance
- * @param value The value
- *
- * @return The {@code value} casted to collection or in case of {@code value} being a map the map values as collection.
- */
- private <T> Collection<T> getActualCollection(XMember member, Object value) {
- Collection<T> collection;
- if ( Map.class.equals( member.getCollectionClass() ) ) {
- //hum
- @SuppressWarnings("unchecked")
- Collection<T> tmpCollection = ( ( Map<?, T> ) value ).values();
- collection = tmpCollection;
- }
- else {
- @SuppressWarnings("unchecked")
- Collection<T> tmpCollection = ( Collection<T> ) value;
- collection = tmpCollection;
- }
- return collection;
- }
-
- private <T> void processSingleContainedInInstance(List<LuceneWork> queue, SearchFactoryImplementor searchFactoryImplementor, T value) {
- @SuppressWarnings("unchecked")
- Class<T> valueClass = Hibernate.getClass( value );
- DocumentBuilderIndexedEntity<T> builderIndexedEntity =
- searchFactoryImplementor.getDocumentBuilderIndexedEntity( valueClass );
-
- // it could be we have a nested @IndexedEmbedded chain in which case we have to find the top level @Indexed entities
- if ( builderIndexedEntity == null ) {
- DocumentBuilderContainedEntity<T> builderContainedEntity =
- searchFactoryImplementor.getDocumentBuilderContainedEntity( valueClass );
- if ( builderContainedEntity != null ) {
- processContainedInInstances( value, queue, builderContainedEntity.metadata, searchFactoryImplementor );
- }
- }
- else {
- addWorkForEmbeddedValue( value, queue, valueClass, builderIndexedEntity, searchFactoryImplementor );
- }
- }
-
- /**
- * Create a {@code LuceneWork} instance of the entity which needs updating due to the embedded instance change.
- *
- * @param value The value to index
- * @param queue The current (Lucene) work queue
- * @param valueClass The class of the value
- * @param builderIndexedEntity the document builder for the entity which needs updating due to a update event of the embedded instance
- * @param searchFactoryImplementor the search factory.
- */
- private <T> void addWorkForEmbeddedValue(T value, List<LuceneWork> queue, Class<T> valueClass,
- DocumentBuilderIndexedEntity<T> builderIndexedEntity, SearchFactoryImplementor searchFactoryImplementor) {
- Serializable id = ( Serializable ) ReflectionHelper.getMemberValue( value, builderIndexedEntity.idGetter );
- builderIndexedEntity.addWorkToQueue( valueClass, value, id, WorkType.UPDATE, queue, searchFactoryImplementor );
- }
-
- public Analyzer getAnalyzer() {
- return analyzer;
- }
-
- public void postInitialize(Set<Class<?>> indexedClasses) {
- if ( entityState == EntityState.NON_INDEXABLE ) {
- throw new AssertionFailure( "A non indexed entity is post processed" );
- }
- //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 != currentClass && plainClass.isAssignableFrom( currentClass ) ) {
- tempMappedSubclasses.add( currentClass );
- }
- }
- this.mappedSubclasses = Collections.unmodifiableSet( tempMappedSubclasses );
- Class superClass = plainClass.getSuperclass();
- this.isRoot = true;
- while ( superClass != null ) {
- if ( indexedClasses.contains( superClass ) ) {
- this.isRoot = false;
- break;
- }
- superClass = superClass.getSuperclass();
- }
- this.reflectionManager = null;
- }
-
- public EntityState getEntityState() {
- return entityState;
- }
-
- public Set<Class<?>> getMappedSubclasses() {
- return mappedSubclasses;
- }
-
- /**
- * Wrapper class containing all the meta data extracted out of a single entity.
- * All field/property related properties are kept in lists. Retrieving all metadata for a given
- * property/field means accessing all the lists with the same index.
- */
- protected static class PropertiesMetadata {
- public float boost;
- public Analyzer analyzer;
- public Discriminator discriminator;
- public XMember discriminatorGetter;
- public BoostStrategy classBoostStrategy;
-
- public final List<String> fieldNames = new ArrayList<String>();
- public final List<XMember> fieldGetters = new ArrayList<XMember>();
- public final List<FieldBridge> fieldBridges = new ArrayList<FieldBridge>();
- public final List<Field.Store> fieldStore = new ArrayList<Field.Store>();
- public final List<Field.Index> fieldIndex = new ArrayList<Field.Index>();
- public final List<Float> fieldBoosts = new ArrayList<Float>();
- public final List<BoostStrategy> dynamicFieldBoosts = new ArrayList<BoostStrategy>();
-
- public final List<Field.TermVector> fieldTermVectors = new ArrayList<Field.TermVector>();
- public final List<XMember> embeddedGetters = new ArrayList<XMember>();
- public final List<PropertiesMetadata> embeddedPropertiesMetadata = new ArrayList<PropertiesMetadata>();
- public final List<Container> embeddedContainers = new ArrayList<Container>();
- public final List<XMember> containedInGetters = new ArrayList<XMember>();
-
- public final List<String> classNames = new ArrayList<String>();
- public final List<Field.Store> classStores = new ArrayList<Field.Store>();
- public final List<Field.Index> classIndexes = new ArrayList<Field.Index>();
- public final List<FieldBridge> classBridges = new ArrayList<FieldBridge>();
- public final List<Field.TermVector> classTermVectors = new ArrayList<Field.TermVector>();
- public final List<Float> classBoosts = new ArrayList<Float>();
-
- public enum Container {
- OBJECT,
- COLLECTION,
- MAP,
- ARRAY
- }
-
- protected LuceneOptions getClassLuceneOptions(int i) {
- return new LuceneOptionsImpl(
- classStores.get( i ),
- classIndexes.get( i ), classTermVectors.get( i ), classBoosts.get( i )
- );
- }
-
- protected LuceneOptions getFieldLuceneOptions(int i, Object value) {
- LuceneOptions options;
- options = new LuceneOptionsImpl(
- fieldStore.get( i ),
- fieldIndex.get( i ),
- fieldTermVectors.get( i ),
- fieldBoosts.get( i ) * dynamicFieldBoosts.get( i ).defineBoost( value )
- );
- return options;
- }
-
- protected float getClassBoost(Object value) {
- return boost * classBoostStrategy.defineBoost( value );
- }
- }
-}
\ No newline at end of file
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.engine;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.search.Similarity;
+import org.slf4j.Logger;
+
+import org.hibernate.Hibernate;
+import org.hibernate.annotations.common.AssertionFailure;
+import org.hibernate.annotations.common.reflection.ReflectionManager;
+import org.hibernate.annotations.common.reflection.XAnnotatedElement;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XMember;
+import org.hibernate.annotations.common.reflection.XProperty;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.analyzer.Discriminator;
+import org.hibernate.search.annotations.AnalyzerDef;
+import org.hibernate.search.annotations.AnalyzerDefs;
+import org.hibernate.search.annotations.AnalyzerDiscriminator;
+import org.hibernate.search.annotations.Boost;
+import org.hibernate.search.annotations.ClassBridge;
+import org.hibernate.search.annotations.ClassBridges;
+import org.hibernate.search.annotations.ContainedIn;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.DynamicBoost;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.search.annotations.Store;
+import org.hibernate.search.annotations.TermVector;
+import org.hibernate.search.backend.LuceneWork;
+import org.hibernate.search.backend.WorkType;
+import org.hibernate.search.bridge.BridgeFactory;
+import org.hibernate.search.bridge.FieldBridge;
+import org.hibernate.search.bridge.LuceneOptions;
+import org.hibernate.search.impl.InitContext;
+import org.hibernate.search.util.LoggerFactory;
+import org.hibernate.search.util.ReflectionHelper;
+import org.hibernate.search.util.ScopedAnalyzer;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Set up and provide a manager for classes which are indexed via <code>@IndexedEmbedded</code>, but themselves do not
+ * contain the <code>@Indexed</code> annotation.
+ *
+ * @author Gavin King
+ * @author Emmanuel Bernard
+ * @author Sylvain Vieujot
+ * @author Richard Hallier
+ * @author Hardy Ferentschik
+ */
+public class DocumentBuilderContainedEntity<T> implements DocumentBuilder {
+ private static final Logger log = LoggerFactory.make();
+
+ protected final PropertiesMetadata metadata = new PropertiesMetadata();
+ protected final XClass beanClass;
+ protected Set<Class<?>> mappedSubclasses = new HashSet<Class<?>>();
+ protected ReflectionManager reflectionManager; //available only during initialization and post-initialization
+ protected int level = 0;
+ protected int maxLevel = Integer.MAX_VALUE;
+ protected final ScopedAnalyzer analyzer = new ScopedAnalyzer();
+ protected Similarity similarity;
+ protected boolean isRoot;
+ protected EntityState entityState;
+
+ /**
+ * Constructor used on contained entities not annotated with <code>@Indexed</code> themselves.
+ *
+ * @param clazz The class for which to build a <code>DocumentBuilderContainedEntity</code>.
+ * @param context Handle to default configuration settings.
+ * @param reflectionManager Reflection manager to use for processing the annotations.
+ */
+ public DocumentBuilderContainedEntity(XClass clazz, InitContext context, ReflectionManager reflectionManager) {
+
+ if ( clazz == null ) {
+ throw new AssertionFailure( "Unable to build a DocumentBuilderContainedEntity with a null class" );
+ }
+
+ this.entityState = EntityState.CONTAINED_IN_ONLY;
+ this.beanClass = clazz;
+ this.reflectionManager = reflectionManager;
+
+ init( clazz, context );
+
+ if ( metadata.containedInGetters.size() == 0 ) {
+ this.entityState = EntityState.NON_INDEXABLE;
+ }
+ }
+
+ protected void init(XClass clazz, InitContext context) {
+ metadata.boost = getBoost( clazz );
+ metadata.classBoostStrategy = getDynamicBoost( clazz );
+ metadata.analyzer = context.getDefaultAnalyzer();
+
+ Set<XClass> processedClasses = new HashSet<XClass>();
+ processedClasses.add( clazz );
+ initializeClass( clazz, metadata, true, "", processedClasses, context );
+
+ this.analyzer.setGlobalAnalyzer( metadata.analyzer );
+
+ // set the default similarity in case that after processing all classes there is still no similarity set
+ if ( this.similarity == null ) {
+ this.similarity = context.getDefaultSimilarity();
+ }
+ }
+
+ public boolean isRoot() {
+ return isRoot;
+ }
+
+ private void initializeClass(XClass clazz, PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix,
+ Set<XClass> processedClasses, InitContext context) {
+ List<XClass> hierarchy = new ArrayList<XClass>();
+ for ( XClass currentClass = clazz; currentClass != null; currentClass = currentClass.getSuperclass() ) {
+ hierarchy.add( currentClass );
+ }
+
+ /*
+ * Iterate the class hierarchy top down. This allows to override the default analyzer for the properties if the class holds one
+ */
+ for ( int index = hierarchy.size() - 1; index >= 0; index-- ) {
+ XClass currentClass = hierarchy.get( index );
+
+ initializeClassLevelAnnotations( currentClass, propertiesMetadata, isRoot, prefix, context );
+
+ // rejecting non properties (ie regular methods) because the object is loaded from Hibernate,
+ // so indexing a non property does not make sense
+ List<XProperty> methods = currentClass.getDeclaredProperties( XClass.ACCESS_PROPERTY );
+ for ( XProperty method : methods ) {
+ initializeMemberLevelAnnotations(
+ method, propertiesMetadata, isRoot, prefix, processedClasses, context
+ );
+ }
+
+ List<XProperty> fields = currentClass.getDeclaredProperties( XClass.ACCESS_FIELD );
+ for ( XProperty field : fields ) {
+ initializeMemberLevelAnnotations(
+ field, propertiesMetadata, isRoot, prefix, processedClasses, context
+ );
+ }
+ }
+ }
+
+ /**
+ * Check and initialize class level annotations.
+ *
+ * @param clazz The class to process.
+ * @param propertiesMetadata The meta data holder.
+ * @param isRoot Flag indicating if the specified class is a root entity, meaning the start of a chain of indexed
+ * entities.
+ * @param prefix The current prefix used for the <code>Document</code> field names.
+ * @param context Handle to default configuration settings.
+ */
+ private void initializeClassLevelAnnotations(XClass clazz, PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix, InitContext context) {
+
+ // check for a class level specified analyzer
+ Analyzer analyzer = getAnalyzer( clazz, context );
+ if ( analyzer != null ) {
+ propertiesMetadata.analyzer = analyzer;
+ }
+
+ // check for AnalyzerDefs annotations
+ checkForAnalyzerDefs( clazz, context );
+
+ // Check for any ClassBridges annotation.
+ ClassBridges classBridgesAnn = clazz.getAnnotation( ClassBridges.class );
+ if ( classBridgesAnn != null ) {
+ ClassBridge[] classBridges = classBridgesAnn.value();
+ for ( ClassBridge cb : classBridges ) {
+ bindClassBridgeAnnotation( prefix, propertiesMetadata, cb, context );
+ }
+ }
+
+ // Check for any ClassBridge style of annotations.
+ ClassBridge classBridgeAnn = clazz.getAnnotation( ClassBridge.class );
+ if ( classBridgeAnn != null ) {
+ bindClassBridgeAnnotation( prefix, propertiesMetadata, classBridgeAnn, context );
+ }
+
+ checkForAnalyzerDiscriminator( clazz, propertiesMetadata );
+
+ // Get similarity
+ //TODO: similarity form @IndexedEmbedded are not taken care of. Exception??
+ if ( isRoot ) {
+ checkForSimilarity( clazz );
+ }
+ }
+
+ protected void initializeMemberLevelAnnotations(XProperty member, PropertiesMetadata propertiesMetadata, boolean isRoot,
+ String prefix, Set<XClass> processedClasses, InitContext context) {
+ checkDocumentId( member, propertiesMetadata, isRoot, prefix, context );
+ checkForField( member, propertiesMetadata, prefix, context );
+ checkForFields( member, propertiesMetadata, prefix, context );
+ checkForAnalyzerDefs( member, context );
+ checkForAnalyzerDiscriminator( member, propertiesMetadata );
+ checkForIndexedEmbedded( member, propertiesMetadata, prefix, processedClasses, context );
+ checkForContainedIn( member, propertiesMetadata );
+ }
+
+ protected Analyzer getAnalyzer(XAnnotatedElement annotatedElement, InitContext context) {
+ org.hibernate.search.annotations.Analyzer analyzerAnn =
+ annotatedElement.getAnnotation( org.hibernate.search.annotations.Analyzer.class );
+ return getAnalyzer( analyzerAnn, context );
+ }
+
+ protected Analyzer getAnalyzer(org.hibernate.search.annotations.Analyzer analyzerAnn, InitContext context) {
+ Class analyzerClass = analyzerAnn == null ? void.class : analyzerAnn.impl();
+ if ( analyzerClass == void.class ) {
+ String definition = analyzerAnn == null ? "" : analyzerAnn.definition();
+ if ( StringHelper.isEmpty( definition ) ) {
+ return null;
+ }
+ else {
+
+ return context.buildLazyAnalyzer( definition );
+ }
+ }
+ else {
+ try {
+ return ( Analyzer ) analyzerClass.newInstance();
+ }
+ catch ( ClassCastException e ) {
+ throw new SearchException(
+ "Lucene analyzer does not implement " + Analyzer.class.getName() + ": " + analyzerClass.getName(),
+ e
+ );
+ }
+ catch ( Exception e ) {
+ throw new SearchException(
+ "Failed to instantiate lucene analyzer with type " + analyzerClass.getName(), e
+ );
+ }
+ }
+ }
+
+ private void checkForAnalyzerDefs(XAnnotatedElement annotatedElement, InitContext context) {
+ AnalyzerDefs defs = annotatedElement.getAnnotation( AnalyzerDefs.class );
+ if ( defs != null ) {
+ for ( AnalyzerDef def : defs.value() ) {
+ context.addAnalyzerDef( def );
+ }
+ }
+ AnalyzerDef def = annotatedElement.getAnnotation( AnalyzerDef.class );
+ context.addAnalyzerDef( def );
+ }
+
+ private void checkForAnalyzerDiscriminator(XAnnotatedElement annotatedElement, PropertiesMetadata propertiesMetadata) {
+ AnalyzerDiscriminator discriminatorAnn = annotatedElement.getAnnotation( AnalyzerDiscriminator.class );
+ if ( discriminatorAnn != null ) {
+ if ( propertiesMetadata.discriminator != null ) {
+ throw new SearchException(
+ "Multiple AnalyzerDiscriminator defined in the same class hierarchy: " + beanClass.getName()
+ );
+ }
+
+ Class<? extends Discriminator> discriminatorClass = discriminatorAnn.impl();
+ try {
+ propertiesMetadata.discriminator = discriminatorClass.newInstance();
+ }
+ catch ( Exception e ) {
+ throw new SearchException(
+ "Unable to instantiate analyzer discriminator implementation: " + discriminatorClass.getName()
+ );
+ }
+
+ if ( annotatedElement instanceof XMember ) {
+ propertiesMetadata.discriminatorGetter = ( XMember ) annotatedElement;
+ }
+ }
+ }
+
+ public Similarity getSimilarity() {
+ return similarity;
+ }
+
+ private void checkForFields(XProperty member, PropertiesMetadata propertiesMetadata, String prefix, InitContext context) {
+ org.hibernate.search.annotations.Fields fieldsAnn =
+ member.getAnnotation( org.hibernate.search.annotations.Fields.class );
+ if ( fieldsAnn != null ) {
+ for ( org.hibernate.search.annotations.Field fieldAnn : fieldsAnn.value() ) {
+ bindFieldAnnotation( member, propertiesMetadata, prefix, fieldAnn, context );
+ }
+ }
+ }
+
+ private void checkForSimilarity(XClass currClass) {
+ org.hibernate.search.annotations.Similarity similarityAnn = currClass.getAnnotation( org.hibernate.search.annotations.Similarity.class );
+ if ( similarityAnn != null ) {
+ if ( similarity != null ) {
+ throw new SearchException(
+ "Multiple Similarities defined in the same class hierarchy: " + beanClass.getName()
+ );
+ }
+ Class similarityClass = similarityAnn.impl();
+ try {
+ similarity = ( Similarity ) similarityClass.newInstance();
+ }
+ catch ( Exception e ) {
+ log.error(
+ "Exception attempting to instantiate Similarity '{}' set for {}",
+ similarityClass.getName(), beanClass.getName()
+ );
+ }
+ }
+ }
+
+ private void checkForField(XProperty member, PropertiesMetadata propertiesMetadata, String prefix, InitContext context) {
+ org.hibernate.search.annotations.Field fieldAnn =
+ member.getAnnotation( org.hibernate.search.annotations.Field.class );
+ if ( fieldAnn != null ) {
+ bindFieldAnnotation( member, propertiesMetadata, prefix, fieldAnn, context );
+ }
+ }
+
+ private void checkForContainedIn(XProperty member, PropertiesMetadata propertiesMetadata) {
+ ContainedIn containedAnn = member.getAnnotation( ContainedIn.class );
+ if ( containedAnn != null ) {
+ ReflectionHelper.setAccessible( member );
+ propertiesMetadata.containedInGetters.add( member );
+ }
+ }
+
+ private void checkForIndexedEmbedded(XProperty member, PropertiesMetadata propertiesMetadata, String prefix, Set<XClass> processedClasses, InitContext context) {
+ IndexedEmbedded embeddedAnn = member.getAnnotation( IndexedEmbedded.class );
+ if ( embeddedAnn != null ) {
+ int oldMaxLevel = maxLevel;
+ int potentialLevel = embeddedAnn.depth() + level;
+ if ( potentialLevel < 0 ) {
+ potentialLevel = Integer.MAX_VALUE;
+ }
+ maxLevel = potentialLevel > maxLevel ? maxLevel : potentialLevel;
+ level++;
+
+ XClass elementClass;
+ if ( void.class == embeddedAnn.targetElement() ) {
+ elementClass = member.getElementClass();
+ }
+ else {
+ elementClass = reflectionManager.toXClass( embeddedAnn.targetElement() );
+ }
+ if ( maxLevel == Integer.MAX_VALUE //infinite
+ && processedClasses.contains( elementClass ) ) {
+ throw new SearchException(
+ "Circular reference. Duplicate use of "
+ + elementClass.getName()
+ + " in root entity " + beanClass.getName()
+ + "#" + buildEmbeddedPrefix( prefix, embeddedAnn, member )
+ );
+ }
+ if ( level <= maxLevel ) {
+ processedClasses.add( elementClass ); //push
+
+ ReflectionHelper.setAccessible( member );
+ propertiesMetadata.embeddedGetters.add( member );
+ PropertiesMetadata metadata = new PropertiesMetadata();
+ propertiesMetadata.embeddedPropertiesMetadata.add( metadata );
+ metadata.boost = getBoost( member, null );
+ //property > entity analyzer
+ Analyzer analyzer = getAnalyzer( member, context );
+ metadata.analyzer = analyzer != null ? analyzer : propertiesMetadata.analyzer;
+ String localPrefix = buildEmbeddedPrefix( prefix, embeddedAnn, member );
+ initializeClass( elementClass, metadata, false, localPrefix, processedClasses, context );
+ /**
+ * We will only index the "expected" type but that's OK, HQL cannot do down-casting either
+ */
+ if ( member.isArray() ) {
+ propertiesMetadata.embeddedContainers.add( PropertiesMetadata.Container.ARRAY );
+ }
+ else if ( member.isCollection() ) {
+ if ( Map.class.equals( member.getCollectionClass() ) ) {
+ //hum subclasses etc etc??
+ propertiesMetadata.embeddedContainers.add( PropertiesMetadata.Container.MAP );
+ }
+ else {
+ propertiesMetadata.embeddedContainers.add( PropertiesMetadata.Container.COLLECTION );
+ }
+ }
+ else {
+ propertiesMetadata.embeddedContainers.add( PropertiesMetadata.Container.OBJECT );
+ }
+
+ processedClasses.remove( elementClass ); //pop
+ }
+ else if ( log.isTraceEnabled() ) {
+ String localPrefix = buildEmbeddedPrefix( prefix, embeddedAnn, member );
+ log.trace( "depth reached, ignoring {}", localPrefix );
+ }
+
+ level--;
+ maxLevel = oldMaxLevel; //set back the the old max level
+ }
+ }
+
+ protected void checkDocumentId(XProperty member, PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix, InitContext context) {
+ Annotation documentIdAnn = member.getAnnotation( DocumentId.class );
+ if ( documentIdAnn != null ) {
+ log.warn(
+ "@DocumentId specified on an entity which is not indexed by itself. Annotation gets ignored. Use @Field instead."
+ );
+ }
+ }
+
+ /**
+ * Determines the property name for the document id. It is either the name of the property itself or the
+ * value of the name attribute of the <code>idAnnotation</code>.
+ *
+ * @param member the property used as id property.
+ * @param idAnnotation the id annotation
+ *
+ * @return property name to be used as document id.
+ */
+ protected String getIdAttributeName(XProperty member, Annotation idAnnotation) {
+ String name = null;
+ try {
+ Method m = idAnnotation.getClass().getMethod( "name" );
+ name = ( String ) m.invoke( idAnnotation );
+ }
+ catch ( Exception e ) {
+ // ignore
+ }
+
+ return ReflectionHelper.getAttributeName( member, name );
+ }
+
+ private void bindClassBridgeAnnotation(String prefix, PropertiesMetadata propertiesMetadata, ClassBridge ann, InitContext context) {
+ String fieldName = prefix + ann.name();
+ propertiesMetadata.classNames.add( fieldName );
+ propertiesMetadata.classStores.add( getStore( ann.store() ) );
+ propertiesMetadata.classIndexes.add( getIndex( ann.index() ) );
+ propertiesMetadata.classTermVectors.add( getTermVector( ann.termVector() ) );
+ propertiesMetadata.classBridges.add( BridgeFactory.extractType( ann ) );
+ propertiesMetadata.classBoosts.add( ann.boost().value() );
+
+ Analyzer analyzer = getAnalyzer( ann.analyzer(), context );
+ if ( analyzer == null ) {
+ analyzer = propertiesMetadata.analyzer;
+ }
+ if ( analyzer == null ) {
+ throw new AssertionFailure( "Analyzer should not be undefined" );
+ }
+ this.analyzer.addScopedAnalyzer( fieldName, analyzer );
+ }
+
+ private void bindFieldAnnotation(XProperty member, PropertiesMetadata propertiesMetadata, String prefix, org.hibernate.search.annotations.Field fieldAnn, InitContext context) {
+ ReflectionHelper.setAccessible( member );
+ propertiesMetadata.fieldGetters.add( member );
+ String fieldName = prefix + ReflectionHelper.getAttributeName( member, fieldAnn.name() );
+ propertiesMetadata.fieldNames.add( fieldName );
+ propertiesMetadata.fieldStore.add( getStore( fieldAnn.store() ) );
+ propertiesMetadata.fieldIndex.add( getIndex( fieldAnn.index() ) );
+ propertiesMetadata.fieldBoosts.add( getBoost( member, fieldAnn ) );
+ propertiesMetadata.dynamicFieldBoosts.add( getDynamicBoost( member ) );
+ propertiesMetadata.fieldTermVectors.add( getTermVector( fieldAnn.termVector() ) );
+ propertiesMetadata.fieldBridges.add( BridgeFactory.guessType( fieldAnn, member, reflectionManager ) );
+
+ // Field > property > entity analyzer
+ Analyzer analyzer = getAnalyzer( fieldAnn.analyzer(), context );
+ if ( analyzer == null ) {
+ analyzer = getAnalyzer( member, context );
+ }
+ if ( analyzer != null ) {
+ this.analyzer.addScopedAnalyzer( fieldName, analyzer );
+ }
+ }
+
+ protected Float getBoost(XProperty member, org.hibernate.search.annotations.Field fieldAnn) {
+ float computedBoost = 1.0f;
+ Boost boostAnn = member.getAnnotation( Boost.class );
+ if ( boostAnn != null ) {
+ computedBoost = boostAnn.value();
+ }
+ if ( fieldAnn != null ) {
+ computedBoost *= fieldAnn.boost().value();
+ }
+ return computedBoost;
+ }
+
+ protected BoostStrategy getDynamicBoost(XProperty member) {
+ DynamicBoost boostAnnotation = member.getAnnotation( DynamicBoost.class );
+ if ( boostAnnotation == null ) {
+ return new DefaultBoostStrategy();
+ }
+
+ Class<? extends BoostStrategy> boostStrategyClass = boostAnnotation.impl();
+ BoostStrategy strategy;
+ try {
+ strategy = boostStrategyClass.newInstance();
+ }
+ catch ( Exception e ) {
+ throw new SearchException(
+ "Unable to instantiate boost strategy implementation: " + boostStrategyClass.getName()
+ );
+ }
+ return strategy;
+ }
+
+ private String buildEmbeddedPrefix(String prefix, IndexedEmbedded embeddedAnn, XProperty member) {
+ String localPrefix = prefix;
+ if ( ".".equals( embeddedAnn.prefix() ) ) {
+ //default to property name
+ localPrefix += member.getName() + '.';
+ }
+ else {
+ localPrefix += embeddedAnn.prefix();
+ }
+ return localPrefix;
+ }
+
+ protected 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 );
+ }
+ }
+
+ protected Field.TermVector getTermVector(TermVector vector) {
+ switch ( vector ) {
+ case NO:
+ return Field.TermVector.NO;
+ case YES:
+ return Field.TermVector.YES;
+ case WITH_OFFSETS:
+ return Field.TermVector.WITH_OFFSETS;
+ case WITH_POSITIONS:
+ return Field.TermVector.WITH_POSITIONS;
+ case WITH_POSITION_OFFSETS:
+ return Field.TermVector.WITH_POSITIONS_OFFSETS;
+ default:
+ throw new AssertionFailure( "Unexpected TermVector: " + vector );
+ }
+ }
+
+ protected Field.Index getIndex(Index index) {
+ switch ( index ) {
+ case NO:
+ return Field.Index.NO;
+ case NO_NORMS:
+ return Field.Index.NOT_ANALYZED_NO_NORMS;
+ case TOKENIZED:
+ return Field.Index.ANALYZED;
+ case UN_TOKENIZED:
+ return Field.Index.NOT_ANALYZED;
+ default:
+ throw new AssertionFailure( "Unexpected Index: " + index );
+ }
+ }
+
+ protected Float getBoost(XClass element) {
+ float boost = 1.0f;
+ if ( element == null ) {
+ return boost;
+ }
+ Boost boostAnnotation = element.getAnnotation( Boost.class );
+ if ( boostAnnotation != null ) {
+ boost = boostAnnotation.value();
+ }
+ return boost;
+ }
+
+ protected BoostStrategy getDynamicBoost(XClass element) {
+ if ( element == null ) {
+ return null;
+ }
+ DynamicBoost boostAnnotation = element.getAnnotation( DynamicBoost.class );
+ if ( boostAnnotation == null ) {
+ return new DefaultBoostStrategy();
+ }
+
+ Class<? extends BoostStrategy> boostStrategyClass = boostAnnotation.impl();
+ BoostStrategy strategy;
+ try {
+ strategy = boostStrategyClass.newInstance();
+ }
+ catch ( Exception e ) {
+ throw new SearchException(
+ "Unable to instantiate boost strategy implementation: " + boostStrategyClass.getName()
+ );
+ }
+ return strategy;
+ }
+
+ public void addWorkToQueue(Class<T> entityClass, T entity, Serializable id, WorkType workType, List<LuceneWork> queue, SearchFactoryImplementor searchFactoryImplementor) {
+ /**
+ * When references are changed, either null or another one, we expect dirty checking to be triggered (both sides
+ * have to be updated)
+ * When the internal object is changed, we apply the {Add|Update}Work on containedIns
+ */
+ if ( workType.searchForContainers() ) {
+ processContainedInInstances( entity, queue, metadata, searchFactoryImplementor );
+ }
+ }
+
+ /**
+ * If we have a work instance we have to check whether the intance to be indexed is contained in any other indexed entities.
+ *
+ * @param instance The instance to be indexed
+ * @param queue the current work queue
+ * @param metadata metadata
+ * @param searchFactoryImplementor the current session
+ */
+ private <T> void processContainedInInstances(Object instance, List<LuceneWork> queue, PropertiesMetadata metadata, SearchFactoryImplementor searchFactoryImplementor) {
+ for ( int i = 0; i < metadata.containedInGetters.size(); i++ ) {
+ XMember member = metadata.containedInGetters.get( i );
+ Object value = ReflectionHelper.getMemberValue( instance, member );
+
+ if ( value == null ) {
+ continue;
+ }
+
+ if ( member.isArray() ) {
+ @SuppressWarnings("unchecked")
+ T[] array = ( T[] ) value;
+ for ( T arrayValue : array ) {
+ processSingleContainedInInstance( queue, searchFactoryImplementor, arrayValue );
+ }
+ }
+ else if ( member.isCollection() ) {
+ Collection<T> collection = getActualCollection( member, value );
+ for ( T collectionValue : collection ) {
+ processSingleContainedInInstance( queue, searchFactoryImplementor, collectionValue );
+ }
+ }
+ else {
+ processSingleContainedInInstance( queue, searchFactoryImplementor, value );
+ }
+ }
+ }
+
+ /**
+ * A {@code XMember } instance treats a map as a collection as well in which case the map values are returned as
+ * collection.
+ *
+ * @param member The member instance
+ * @param value The value
+ *
+ * @return The {@code value} casted to collection or in case of {@code value} being a map the map values as collection.
+ */
+ private <T> Collection<T> getActualCollection(XMember member, Object value) {
+ Collection<T> collection;
+ if ( Map.class.equals( member.getCollectionClass() ) ) {
+ //hum
+ @SuppressWarnings("unchecked")
+ Collection<T> tmpCollection = ( ( Map<?, T> ) value ).values();
+ collection = tmpCollection;
+ }
+ else {
+ @SuppressWarnings("unchecked")
+ Collection<T> tmpCollection = ( Collection<T> ) value;
+ collection = tmpCollection;
+ }
+ return collection;
+ }
+
+ private <T> void processSingleContainedInInstance(List<LuceneWork> queue, SearchFactoryImplementor searchFactoryImplementor, T value) {
+ @SuppressWarnings("unchecked")
+ Class<T> valueClass = Hibernate.getClass( value );
+ DocumentBuilderIndexedEntity<T> builderIndexedEntity =
+ searchFactoryImplementor.getDocumentBuilderIndexedEntity( valueClass );
+
+ // it could be we have a nested @IndexedEmbedded chain in which case we have to find the top level @Indexed entities
+ if ( builderIndexedEntity == null ) {
+ DocumentBuilderContainedEntity<T> builderContainedEntity =
+ searchFactoryImplementor.getDocumentBuilderContainedEntity( valueClass );
+ if ( builderContainedEntity != null ) {
+ processContainedInInstances( value, queue, builderContainedEntity.metadata, searchFactoryImplementor );
+ }
+ }
+ else {
+ addWorkForEmbeddedValue( value, queue, valueClass, builderIndexedEntity, searchFactoryImplementor );
+ }
+ }
+
+ /**
+ * Create a {@code LuceneWork} instance of the entity which needs updating due to the embedded instance change.
+ *
+ * @param value The value to index
+ * @param queue The current (Lucene) work queue
+ * @param valueClass The class of the value
+ * @param builderIndexedEntity the document builder for the entity which needs updating due to a update event of the embedded instance
+ * @param searchFactoryImplementor the search factory.
+ */
+ private <T> void addWorkForEmbeddedValue(T value, List<LuceneWork> queue, Class<T> valueClass,
+ DocumentBuilderIndexedEntity<T> builderIndexedEntity, SearchFactoryImplementor searchFactoryImplementor) {
+ Serializable id = ( Serializable ) ReflectionHelper.getMemberValue( value, builderIndexedEntity.idGetter );
+ builderIndexedEntity.addWorkToQueue( valueClass, value, id, WorkType.UPDATE, queue, searchFactoryImplementor );
+ }
+
+ public Analyzer getAnalyzer() {
+ return analyzer;
+ }
+
+ public void postInitialize(Set<Class<?>> indexedClasses) {
+ if ( entityState == EntityState.NON_INDEXABLE ) {
+ throw new AssertionFailure( "A non indexed entity is post processed" );
+ }
+ //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 != currentClass && plainClass.isAssignableFrom( currentClass ) ) {
+ tempMappedSubclasses.add( currentClass );
+ }
+ }
+ this.mappedSubclasses = Collections.unmodifiableSet( tempMappedSubclasses );
+ Class superClass = plainClass.getSuperclass();
+ this.isRoot = true;
+ while ( superClass != null ) {
+ if ( indexedClasses.contains( superClass ) ) {
+ this.isRoot = false;
+ break;
+ }
+ superClass = superClass.getSuperclass();
+ }
+ this.reflectionManager = null;
+ }
+
+ public EntityState getEntityState() {
+ return entityState;
+ }
+
+ public Set<Class<?>> getMappedSubclasses() {
+ return mappedSubclasses;
+ }
+
+ /**
+ * Wrapper class containing all the meta data extracted out of a single entity.
+ * All field/property related properties are kept in lists. Retrieving all metadata for a given
+ * property/field means accessing all the lists with the same index.
+ */
+ protected static class PropertiesMetadata {
+ public float boost;
+ public Analyzer analyzer;
+ public Discriminator discriminator;
+ public XMember discriminatorGetter;
+ public BoostStrategy classBoostStrategy;
+
+ public final List<String> fieldNames = new ArrayList<String>();
+ public final List<XMember> fieldGetters = new ArrayList<XMember>();
+ public final List<FieldBridge> fieldBridges = new ArrayList<FieldBridge>();
+ public final List<Field.Store> fieldStore = new ArrayList<Field.Store>();
+ public final List<Field.Index> fieldIndex = new ArrayList<Field.Index>();
+ public final List<Float> fieldBoosts = new ArrayList<Float>();
+ public final List<BoostStrategy> dynamicFieldBoosts = new ArrayList<BoostStrategy>();
+
+ public final List<Field.TermVector> fieldTermVectors = new ArrayList<Field.TermVector>();
+ public final List<XMember> embeddedGetters = new ArrayList<XMember>();
+ public final List<PropertiesMetadata> embeddedPropertiesMetadata = new ArrayList<PropertiesMetadata>();
+ public final List<Container> embeddedContainers = new ArrayList<Container>();
+ public final List<XMember> containedInGetters = new ArrayList<XMember>();
+
+ public final List<String> classNames = new ArrayList<String>();
+ public final List<Field.Store> classStores = new ArrayList<Field.Store>();
+ public final List<Field.Index> classIndexes = new ArrayList<Field.Index>();
+ public final List<FieldBridge> classBridges = new ArrayList<FieldBridge>();
+ public final List<Field.TermVector> classTermVectors = new ArrayList<Field.TermVector>();
+ public final List<Float> classBoosts = new ArrayList<Float>();
+
+ public enum Container {
+ OBJECT,
+ COLLECTION,
+ MAP,
+ ARRAY
+ }
+
+ protected LuceneOptions getClassLuceneOptions(int i) {
+ return new LuceneOptionsImpl(
+ classStores.get( i ),
+ classIndexes.get( i ), classTermVectors.get( i ), classBoosts.get( i )
+ );
+ }
+
+ protected LuceneOptions getFieldLuceneOptions(int i, Object value) {
+ LuceneOptions options;
+ options = new LuceneOptionsImpl(
+ fieldStore.get( i ),
+ fieldIndex.get( i ),
+ fieldTermVectors.get( i ),
+ fieldBoosts.get( i ) * dynamicFieldBoosts.get( i ).defineBoost( value )
+ );
+ return options;
+ }
+
+ protected float getClassBoost(Object value) {
+ return boost * classBoostStrategy.defineBoost( value );
+ }
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,689 +1,712 @@
-//$Id$
-package org.hibernate.search.engine;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-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.slf4j.Logger;
-
-import org.hibernate.Hibernate;
-import org.hibernate.annotations.common.AssertionFailure;
-import org.hibernate.annotations.common.util.ReflectHelper;
-import org.hibernate.annotations.common.reflection.ReflectionManager;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XMember;
-import org.hibernate.annotations.common.reflection.XProperty;
-import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.search.SearchException;
-import org.hibernate.search.analyzer.Discriminator;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.ProvidedId;
-import org.hibernate.search.annotations.Store;
-import org.hibernate.search.annotations.TermVector;
-import org.hibernate.search.backend.AddLuceneWork;
-import org.hibernate.search.backend.DeleteLuceneWork;
-import org.hibernate.search.backend.LuceneWork;
-import org.hibernate.search.backend.PurgeAllLuceneWork;
-import org.hibernate.search.backend.WorkType;
-import org.hibernate.search.bridge.BridgeFactory;
-import org.hibernate.search.bridge.FieldBridge;
-import org.hibernate.search.bridge.LuceneOptions;
-import org.hibernate.search.bridge.TwoWayFieldBridge;
-import org.hibernate.search.bridge.TwoWayString2FieldBridgeAdaptor;
-import org.hibernate.search.bridge.TwoWayStringBridge;
-import org.hibernate.search.impl.InitContext;
-import org.hibernate.search.store.DirectoryProvider;
-import org.hibernate.search.store.IndexShardingStrategy;
-import org.hibernate.search.util.LoggerFactory;
-import org.hibernate.search.util.ReflectionHelper;
-
-/**
- * Set up and provide a manager for classes which are directly annotated with <code>@Indexed</code>.
- *
- * @author Gavin King
- * @author Emmanuel Bernard
- * @author Sylvain Vieujot
- * @author Richard Hallier
- * @author Hardy Ferentschik
- */
-public class DocumentBuilderIndexedEntity<T> extends DocumentBuilderContainedEntity<T> {
- private static final Logger log = LoggerFactory.make();
-
- /**
- * Arrays of directory providers for the underlying Lucene indexes of the indexed entity.
- */
- private final DirectoryProvider[] directoryProviders;
-
- /**
- * The sharding strategy used for the indexed entity.
- */
- private final IndexShardingStrategy shardingStrategy;
-
- /**
- * Flag indicating whether <code>@DocumentId</code> was explicitly specified.
- */
- private boolean explicitDocumentId = false;
-
- /**
- * Flag indicating whether {@link org.apache.lucene.search.Searcher#doc(int, org.apache.lucene.document.FieldSelector)}
- * can be used in order to retrieve documents. This is only safe to do if we know that
- * all involved bridges are implementing <code>TwoWayStringBridge</code>. See HSEARCH-213.
- */
- private boolean allowFieldSelectionInProjection = false;
-
- /**
- * The class member used as document id.
- */
- protected XMember idGetter;
-
- /**
- * Name of the document id field.
- */
- protected String idKeywordName;
-
- /**
- * Boost specified on the document id.
- */
- private Float idBoost;
-
- /**
- * The bridge used for the document id.
- */
- private TwoWayFieldBridge idBridge;
-
- /**
- * Flag indicating whether there is an explicit id (@DocumentId or @Id) or not. When Search is used as make
- * for example using JBoss Cache Searchable the <code>idKeywordName</code> will be provided.
- */
- private boolean idProvided = false;
-
-
- //if composite id, use of (a, b) in ((1,2), (3,4)) fails on most database
- private boolean safeFromTupleId;
-
- /**
- * Creates a document builder for entities annotated with <code>@Indexed</code>.
- *
- * @param clazz The class for which to build a <code>DocumentBuilderContainedEntity</code>.
- * @param context Handle to default configuration settings.
- * @param directoryProviders Arrays of directory providers for the underlying Lucene indexes of the indexed entity.
- * @param shardingStrategy The sharding strategy used for the indexed entity.
- * @param reflectionManager Reflection manager to use for processing the annotations.
- */
- public DocumentBuilderIndexedEntity(XClass clazz, InitContext context, DirectoryProvider[] directoryProviders,
- IndexShardingStrategy shardingStrategy, ReflectionManager reflectionManager) {
-
- super( clazz, context, reflectionManager );
-
- this.entityState = EntityState.INDEXED;
- this.directoryProviders = directoryProviders;
- this.shardingStrategy = shardingStrategy;
- }
-
- protected void init(XClass clazz, InitContext context) {
- super.init( clazz, context );
-
- // special case @ProvidedId
- ProvidedId provided = findProvidedId( clazz, reflectionManager );
- if ( provided != null ) {
- idBridge = BridgeFactory.extractTwoWayType( provided.bridge() );
- idKeywordName = provided.name();
- }
-
- if ( idKeywordName == null ) {
- throw new SearchException( "No document id in: " + clazz.getName() );
- }
-
- //if composite id, use of (a, b) in ((1,2),(3,4)) fails on most database
- //a TwoWayString2FieldBridgeAdaptor is never a composite id
- safeFromTupleId = TwoWayString2FieldBridgeAdaptor.class.isAssignableFrom( idBridge.getClass() );
-
- checkAllowFieldSelection();
- if ( log.isDebugEnabled() ) {
- log.debug(
- "Field selection in projections is set to {} for entity {}.",
- allowFieldSelectionInProjection,
- clazz.getName()
- );
- }
- }
-
- protected void checkDocumentId(XProperty member, PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix, InitContext context) {
- Annotation idAnnotation = getIdAnnotation( member, context );
- if ( idAnnotation != null ) {
- String attributeName = getIdAttributeName( member, idAnnotation );
- if ( isRoot ) {
- if ( idKeywordName != null && explicitDocumentId ) {
- throw new AssertionFailure(
- "Two document id assigned: "
- + idKeywordName + " and " + attributeName
- );
- }
- idKeywordName = prefix + attributeName;
- FieldBridge fieldBridge = BridgeFactory.guessType( null, member, reflectionManager );
- if ( fieldBridge instanceof TwoWayFieldBridge ) {
- idBridge = ( TwoWayFieldBridge ) fieldBridge;
- }
- else {
- throw new SearchException(
- "Bridge for document id does not implement TwoWayFieldBridge: " + member.getName()
- );
- }
- idBoost = getBoost( member, null );
- ReflectionHelper.setAccessible( member );
- idGetter = member;
- }
- else {
- //component should index their document id
- ReflectionHelper.setAccessible( member );
- propertiesMetadata.fieldGetters.add( member );
- String fieldName = prefix + attributeName;
- propertiesMetadata.fieldNames.add( fieldName );
- propertiesMetadata.fieldStore.add( getStore( Store.YES ) );
- propertiesMetadata.fieldIndex.add( getIndex( Index.UN_TOKENIZED ) );
- propertiesMetadata.fieldTermVectors.add( getTermVector( TermVector.NO ) );
- propertiesMetadata.fieldBridges.add( BridgeFactory.guessType( null, member, reflectionManager ) );
- propertiesMetadata.fieldBoosts.add( getBoost( member, null ) );
- propertiesMetadata.dynamicFieldBoosts.add( getDynamicBoost( member ) );
- // property > entity analyzer (no field analyzer)
- Analyzer analyzer = getAnalyzer( member, context );
- if ( analyzer == null ) {
- analyzer = propertiesMetadata.analyzer;
- }
- if ( analyzer == null ) {
- throw new AssertionFailure( "Analizer should not be undefined" );
- }
- this.analyzer.addScopedAnalyzer( fieldName, analyzer );
- }
- }
- }
-
- /**
- * Checks whether the specified property contains an annotation used as document id.
- * This can either be an explicit <code>@DocumentId</code> or if no <code>@DocumentId</code> is specified a
- * JPA <code>@Id</code> annotation. The check for the JPA annotation is indirectly to avoid a hard dependency
- * to Hibernate Annotations.
- *
- * @param member the property to check for the id annotation.
- * @param context Handle to default configuration settings.
- *
- * @return the annotation used as document id or <code>null</code> if id annotation is specified on the property.
- */
- private Annotation getIdAnnotation(XProperty member, InitContext context) {
- Annotation idAnnotation = null;
-
- // check for explicit DocumentId
- DocumentId documentIdAnn = member.getAnnotation( DocumentId.class );
- if ( documentIdAnn != null ) {
- explicitDocumentId = true;
- idAnnotation = documentIdAnn;
- }
- // check for JPA @Id
- else if ( !explicitDocumentId && context.isJpaPresent() ) {
- Annotation jpaId;
- try {
- @SuppressWarnings("unchecked")
- Class<? extends Annotation> jpaIdClass =
- org.hibernate.annotations.common.util.ReflectHelper
- .classForName( "javax.persistence.Id", InitContext.class );
- jpaId = member.getAnnotation( jpaIdClass );
- }
- catch ( ClassNotFoundException e ) {
- throw new SearchException( "Unable to load @Id.class even though it should be present ?!" );
- }
- if ( jpaId != null ) {
- log.debug( "Found JPA id and using it as document id" );
- idAnnotation = jpaId;
- }
- }
- return idAnnotation;
- }
-
- private ProvidedId findProvidedId(XClass clazz, ReflectionManager reflectionManager) {
- ProvidedId id = null;
- XClass currentClass = clazz;
- while ( id == null && ( !reflectionManager.equals( currentClass, Object.class ) ) ) {
- id = currentClass.getAnnotation( ProvidedId.class );
- currentClass = currentClass.getSuperclass();
- }
- return id;
- }
-
- //TODO could we use T instead of EntityClass?
- public void addWorkToQueue(Class<T> entityClass, T entity, Serializable id, WorkType workType, List<LuceneWork> queue, SearchFactoryImplementor searchFactoryImplementor) {
- //TODO with the caller loop we are in a n^2: optimize it using a HashMap for work recognition
-
- boolean sameIdWasSetToBeDeleted = false;
- List<LuceneWork> toDelete = new ArrayList<LuceneWork>();
- boolean duplicateDelete = false;
- for ( LuceneWork luceneWork : queue ) {
- if ( luceneWork.getEntityClass() == entityClass ) {
- Serializable currentId = luceneWork.getId();
- if ( currentId != null && currentId.equals( id ) ) { //find a way to use Type.equals(x,y)
- if ( luceneWork instanceof DeleteLuceneWork ) {
- //flag this work as related to a to-be-deleted entity
- sameIdWasSetToBeDeleted = true;
- }
- else if ( luceneWork instanceof AddLuceneWork ) {
- //if a later work in the queue is adding it back, undo deletion flag:
- sameIdWasSetToBeDeleted = false;
- }
- if ( workType == WorkType.DELETE ) { //TODO add PURGE?
- //DELETE should have precedence over any update before (HSEARCH-257)
- //if an Add work is here, remove it
- //if an other delete is here remember but still search for Add
- if ( luceneWork instanceof AddLuceneWork ) {
- toDelete.add( luceneWork );
- }
- else if ( luceneWork instanceof DeleteLuceneWork ) {
- duplicateDelete = true;
- }
- }
- if ( workType == WorkType.ADD ) {
- if ( luceneWork instanceof AddLuceneWork ) {
- //embedded objects may issue an "UPDATE" right before the "ADD",
- //leading to double insertions in the index
- toDelete.add( luceneWork );
- }
- }
- //TODO do something to avoid multiple PURGE ALL and OPTIMIZE
- }
- }
- }
-
- if ( sameIdWasSetToBeDeleted && workType == WorkType.COLLECTION ) {
- //avoid updating (and thus adding) objects which are going to be deleted
- return;
- }
-
- for ( LuceneWork luceneWork : toDelete ) {
- queue.remove( luceneWork );
- }
- if ( duplicateDelete ) {
- return;
- }
-
- if ( workType == WorkType.ADD ) {
- String idInString = idBridge.objectToString( id );
- queue.add( createAddWork( entityClass, entity, id, idInString, false ) );
- }
- else if ( workType == WorkType.DELETE || workType == WorkType.PURGE ) {
- String idInString = idBridge.objectToString( id );
- queue.add( new DeleteLuceneWork( id, idInString, entityClass ) );
- }
- else if ( workType == WorkType.PURGE_ALL ) {
- queue.add( new PurgeAllLuceneWork( entityClass ) );
- }
- else if ( workType == WorkType.UPDATE || workType == WorkType.COLLECTION ) {
- String idInString = idBridge.objectToString( id );
- queue.add( new DeleteLuceneWork( id, idInString, entityClass ) );
- queue.add( createAddWork( entityClass, entity, id, idInString, false ) );
- }
- else if ( workType == WorkType.INDEX ) {
- String idInString = idBridge.objectToString( id );
- queue.add( new DeleteLuceneWork( id, idInString, entityClass ) );
- queue.add( createAddWork( entityClass, entity, id, idInString, true ) );
- }
- else {
- throw new AssertionFailure( "Unknown WorkType: " + workType );
- }
-
- super.addWorkToQueue( entityClass, entity, id, workType, queue, searchFactoryImplementor );
- }
-
- public AddLuceneWork createAddWork(Class<T> entityClass, T entity, Serializable id, String idInString, boolean isBatch) {
- Map<String, String> fieldToAnalyzerMap = new HashMap<String, String>();
- Document doc = getDocument( entity, id, fieldToAnalyzerMap );
- AddLuceneWork addWork;
- if ( fieldToAnalyzerMap.isEmpty() ) {
- addWork = new AddLuceneWork( id, idInString, entityClass, doc, isBatch );
- }
- else {
- addWork = new AddLuceneWork( id, idInString, entityClass, doc, fieldToAnalyzerMap, isBatch );
- }
- return addWork;
- }
-
- /**
- * Builds the Lucene <code>Document</code> for a given entity <code>instance</code> and its <code>id</code>.
- *
- * @param instance The entity for which to build the matching Lucene <code>Document</code>
- * @param id the entity id.
- * @param fieldToAnalyzerMap this maps gets populated while generating the <code>Document</code>.
- * It allows to specify for any document field a named analyzer to use. This parameter cannot be <code>null</code>.
- *
- * @return The Lucene <code>Document</code> for the specified entity.
- */
- public Document getDocument(T instance, Serializable id, Map<String, String> fieldToAnalyzerMap) {
- if ( fieldToAnalyzerMap == null ) {
- throw new IllegalArgumentException( "fieldToAnalyzerMap cannot be null" );
- }
-
- Document doc = new Document();
- final Class<?> entityType = Hibernate.getClass( instance );
- doc.setBoost( metadata.getClassBoost( instance ) );
-
- // add the class name of the entity to the document
- Field classField =
- new Field(
- CLASS_FIELDNAME,
- entityType.getName(),
- Field.Store.YES,
- Field.Index.NOT_ANALYZED,
- Field.TermVector.NO
- );
- doc.add( classField );
-
- // now add the entity id to the document
- LuceneOptions luceneOptions = new LuceneOptionsImpl(
- Field.Store.YES,
- Field.Index.NOT_ANALYZED, Field.TermVector.NO, idBoost
- );
- idBridge.set( idKeywordName, id, doc, luceneOptions );
-
- // finally add all other document fields
- Set<String> processedFieldNames = new HashSet<String>();
- buildDocumentFields( instance, doc, metadata, fieldToAnalyzerMap, processedFieldNames );
- return doc;
- }
-
- private void buildDocumentFields(Object instance, Document doc, PropertiesMetadata propertiesMetadata, Map<String, String> fieldToAnalyzerMap,
- Set<String> processedFieldNames) {
- if ( instance == null ) {
- return;
- }
-
- // needed for field access: I cannot work in the proxied version
- Object unproxiedInstance = unproxy( instance );
-
- // process the class bridges
- for ( int i = 0; i < propertiesMetadata.classBridges.size(); i++ ) {
- FieldBridge fb = propertiesMetadata.classBridges.get( i );
- fb.set(
- propertiesMetadata.classNames.get( i ), unproxiedInstance,
- doc, propertiesMetadata.getClassLuceneOptions( i )
- );
- }
-
- // process the indexed fields
- for ( int i = 0; i < propertiesMetadata.fieldNames.size(); i++ ) {
- XMember member = propertiesMetadata.fieldGetters.get( i );
- Object value = ReflectionHelper.getMemberValue( unproxiedInstance, member );
- propertiesMetadata.fieldBridges.get( i ).set(
- propertiesMetadata.fieldNames.get( i ), value, doc,
- propertiesMetadata.getFieldLuceneOptions( i, value )
- );
- }
-
- // allow analyzer override for the fields added by the class and field bridges
- allowAnalyzerDiscriminatorOverride(
- doc, propertiesMetadata, fieldToAnalyzerMap, processedFieldNames, unproxiedInstance
- );
-
- // recursively process embedded objects
- for ( int i = 0; i < propertiesMetadata.embeddedGetters.size(); i++ ) {
- XMember member = propertiesMetadata.embeddedGetters.get( i );
- Object value = ReflectionHelper.getMemberValue( unproxiedInstance, member );
- //TODO handle boost at embedded level: already stored in propertiesMedatada.boost
-
- if ( value == null ) {
- continue;
- }
- PropertiesMetadata embeddedMetadata = propertiesMetadata.embeddedPropertiesMetadata.get( i );
- switch ( propertiesMetadata.embeddedContainers.get( i ) ) {
- case ARRAY:
- for ( Object arrayValue : ( Object[] ) value ) {
- buildDocumentFields(
- arrayValue, doc, embeddedMetadata, fieldToAnalyzerMap, processedFieldNames
- );
- }
- break;
- case COLLECTION:
- for ( Object collectionValue : ( Collection ) value ) {
- buildDocumentFields(
- collectionValue, doc, embeddedMetadata, fieldToAnalyzerMap, processedFieldNames
- );
- }
- break;
- case MAP:
- for ( Object collectionValue : ( ( Map ) value ).values() ) {
- buildDocumentFields(
- collectionValue, doc, embeddedMetadata, fieldToAnalyzerMap, processedFieldNames
- );
- }
- break;
- case OBJECT:
- buildDocumentFields( value, doc, embeddedMetadata, fieldToAnalyzerMap, processedFieldNames );
- break;
- default:
- throw new AssertionFailure(
- "Unknown embedded container: "
- + propertiesMetadata.embeddedContainers.get( i )
- );
- }
- }
- }
-
- /**
- * Allows a analyzer discriminator to override the analyzer used for any field in the Lucene document.
- *
- * @param doc The Lucene <code>Document</code> which shall be indexed.
- * @param propertiesMetadata The metadata for the entity we currently add to the document.
- * @param fieldToAnalyzerMap This map contains the actual override data. It is a map between document fields names and
- * analyzer definition names. This map will be added to the <code>Work</code> instance and processed at actual indexing time.
- * @param processedFieldNames A list of field names we have already processed.
- * @param unproxiedInstance The entity we currently "add" to the document.
- */
- private void allowAnalyzerDiscriminatorOverride(Document doc, PropertiesMetadata propertiesMetadata, Map<String, String> fieldToAnalyzerMap, Set<String> processedFieldNames, Object unproxiedInstance) {
- Discriminator discriminator = propertiesMetadata.discriminator;
- if ( discriminator == null ) {
- return;
- }
-
- Object value = null;
- if ( propertiesMetadata.discriminatorGetter != null ) {
- value = ReflectionHelper.getMemberValue( unproxiedInstance, propertiesMetadata.discriminatorGetter );
- }
-
- // now we give the discriminator the opportunity to specify a analyzer per field level
- for ( Object o : doc.getFields() ) {
- Field field = ( Field ) o;
- if ( !processedFieldNames.contains( field.name() ) ) {
- String analyzerName = discriminator.getAnalyzerDefinitionName( value, unproxiedInstance, field.name() );
- if ( analyzerName != null ) {
- fieldToAnalyzerMap.put( field.name(), analyzerName );
- }
- processedFieldNames.add( field.name() );
- }
- }
- }
-
- private Object unproxy(Object value) {
- //FIXME this service should be part of Core?
- if ( value instanceof HibernateProxy ) {
- // .getImplementation() initializes the data by side effect
- value = ( ( HibernateProxy ) value ).getHibernateLazyInitializer()
- .getImplementation();
- }
- return value;
- }
-
- public String getIdentifierName() {
- return idGetter.getName();
- }
-
- public DirectoryProvider[] getDirectoryProviders() {
- if ( entityState != EntityState.INDEXED ) {
- throw new AssertionFailure( "Contained in only entity: getDirectoryProvider should not have been called." );
- }
- return directoryProviders;
- }
-
- public IndexShardingStrategy getDirectoryProviderSelectionStrategy() {
- if ( entityState != EntityState.INDEXED ) {
- throw new AssertionFailure(
- "Contained in only entity: getDirectoryProviderSelectionStrategy should not have been called."
- );
- }
- return shardingStrategy;
- }
-
- public boolean allowFieldSelectionInProjection() {
- return allowFieldSelectionInProjection;
- }
-
- /**
- * @return <code>false</code> if there is a risk of composite id. If composite id, use of (a, b) in ((1,2), (3,4)) fails on most database
- */
- public boolean isSafeFromTupleId() {
- return safeFromTupleId;
- }
-
- public Term getTerm(Serializable id) {
- if ( idProvided ) {
- return new Term( idKeywordName, ( String ) id );
- }
-
- return new Term( idKeywordName, idBridge.objectToString( id ) );
- }
-
- public TwoWayFieldBridge getIdBridge() {
- return idBridge;
- }
-
- public static Class getDocumentClass(Document document) {
- String className = document.get( CLASS_FIELDNAME );
- try {
- return ReflectHelper.classForName( className );
- }
- catch ( ClassNotFoundException e ) {
- throw new SearchException( "Unable to load indexed class: " + className, e );
- }
- }
-
- public String getIdKeywordName() {
- return idKeywordName;
- }
-
- public static Serializable getDocumentId(SearchFactoryImplementor searchFactoryImplementor, Class<?> clazz, Document document) {
- DocumentBuilderIndexedEntity<?> builderIndexedEntity = searchFactoryImplementor.getDocumentBuilderIndexedEntity(
- clazz
- );
- if ( builderIndexedEntity == null ) {
- throw new SearchException( "No Lucene configuration set up for: " + clazz.getName() );
- }
- return ( Serializable ) builderIndexedEntity.getIdBridge()
- .get( builderIndexedEntity.getIdKeywordName(), document );
- }
-
- public static Object[] getDocumentFields(SearchFactoryImplementor searchFactoryImplementor, Class<?> clazz, Document document, String[] fields) {
- DocumentBuilderIndexedEntity<?> builderIndexedEntity = searchFactoryImplementor.getDocumentBuilderIndexedEntity(
- clazz
- );
- if ( builderIndexedEntity == null ) {
- throw new SearchException( "No Lucene configuration set up for: " + clazz.getName() );
- }
- final int fieldNbr = fields.length;
- Object[] result = new Object[fieldNbr];
-
- if ( builderIndexedEntity.idKeywordName != null ) {
- populateResult(
- builderIndexedEntity.idKeywordName,
- builderIndexedEntity.idBridge,
- Field.Store.YES,
- fields,
- result,
- document
- );
- }
-
- final PropertiesMetadata metadata = builderIndexedEntity.metadata;
- processFieldsForProjection( metadata, fields, result, document );
- return result;
- }
-
- private static void populateResult(String fieldName, FieldBridge fieldBridge, Field.Store store,
- String[] fields, Object[] result, Document document) {
- int matchingPosition = getFieldPosition( fields, fieldName );
- if ( matchingPosition != -1 ) {
- //TODO make use of an isTwoWay() method
- if ( store != Field.Store.NO && TwoWayFieldBridge.class.isAssignableFrom( fieldBridge.getClass() ) ) {
- result[matchingPosition] = ( ( TwoWayFieldBridge ) fieldBridge ).get( fieldName, document );
- if ( log.isTraceEnabled() ) {
- log.trace( "Field {} projected as {}", fieldName, result[matchingPosition] );
- }
- }
- else {
- if ( store == Field.Store.NO ) {
- throw new SearchException( "Projecting an unstored field: " + fieldName );
- }
- else {
- throw new SearchException( "FieldBridge is not a TwoWayFieldBridge: " + fieldBridge.getClass() );
- }
- }
- }
- }
-
- private static void processFieldsForProjection(PropertiesMetadata metadata, String[] fields, Object[] result, Document document) {
- final int nbrFoEntityFields = metadata.fieldNames.size();
- for ( int index = 0; index < nbrFoEntityFields; index++ ) {
- populateResult(
- metadata.fieldNames.get( index ),
- metadata.fieldBridges.get( index ),
- metadata.fieldStore.get( index ),
- fields,
- result,
- document
- );
- }
- final int nbrOfEmbeddedObjects = metadata.embeddedPropertiesMetadata.size();
- for ( int index = 0; index < nbrOfEmbeddedObjects; index++ ) {
- //there is nothing we can do for collections
- if ( metadata.embeddedContainers.get( index ) == PropertiesMetadata.Container.OBJECT ) {
- processFieldsForProjection(
- metadata.embeddedPropertiesMetadata.get( index ), fields, result, document
- );
- }
- }
- }
-
- private static int getFieldPosition(String[] fields, String fieldName) {
- int fieldNbr = fields.length;
- for ( int index = 0; index < fieldNbr; index++ ) {
- if ( fieldName.equals( fields[index] ) ) {
- return index;
- }
- }
- return -1;
- }
-
- /**
- * Checks whether all involved bridges are two way string bridges. If so we can optimize document retrieval
- * by using <code>FieldSelector</code>. See HSEARCH-213.
- */
- private void checkAllowFieldSelection() {
- allowFieldSelectionInProjection = true;
- if ( !( idBridge instanceof TwoWayStringBridge || idBridge instanceof TwoWayString2FieldBridgeAdaptor ) ) {
- allowFieldSelectionInProjection = false;
- return;
- }
- for ( FieldBridge bridge : metadata.fieldBridges ) {
- if ( !( bridge instanceof TwoWayStringBridge || bridge instanceof TwoWayString2FieldBridgeAdaptor ) ) {
- allowFieldSelectionInProjection = false;
- return;
- }
- }
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.engine;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+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.slf4j.Logger;
+
+import org.hibernate.Hibernate;
+import org.hibernate.annotations.common.AssertionFailure;
+import org.hibernate.annotations.common.util.ReflectHelper;
+import org.hibernate.annotations.common.reflection.ReflectionManager;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XMember;
+import org.hibernate.annotations.common.reflection.XProperty;
+import org.hibernate.proxy.HibernateProxy;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.analyzer.Discriminator;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.ProvidedId;
+import org.hibernate.search.annotations.Store;
+import org.hibernate.search.annotations.TermVector;
+import org.hibernate.search.backend.AddLuceneWork;
+import org.hibernate.search.backend.DeleteLuceneWork;
+import org.hibernate.search.backend.LuceneWork;
+import org.hibernate.search.backend.PurgeAllLuceneWork;
+import org.hibernate.search.backend.WorkType;
+import org.hibernate.search.bridge.BridgeFactory;
+import org.hibernate.search.bridge.FieldBridge;
+import org.hibernate.search.bridge.LuceneOptions;
+import org.hibernate.search.bridge.TwoWayFieldBridge;
+import org.hibernate.search.bridge.TwoWayString2FieldBridgeAdaptor;
+import org.hibernate.search.bridge.TwoWayStringBridge;
+import org.hibernate.search.impl.InitContext;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.store.IndexShardingStrategy;
+import org.hibernate.search.util.LoggerFactory;
+import org.hibernate.search.util.ReflectionHelper;
+
+/**
+ * Set up and provide a manager for classes which are directly annotated with <code>@Indexed</code>.
+ *
+ * @author Gavin King
+ * @author Emmanuel Bernard
+ * @author Sylvain Vieujot
+ * @author Richard Hallier
+ * @author Hardy Ferentschik
+ */
+public class DocumentBuilderIndexedEntity<T> extends DocumentBuilderContainedEntity<T> {
+ private static final Logger log = LoggerFactory.make();
+
+ /**
+ * Arrays of directory providers for the underlying Lucene indexes of the indexed entity.
+ */
+ private final DirectoryProvider[] directoryProviders;
+
+ /**
+ * The sharding strategy used for the indexed entity.
+ */
+ private final IndexShardingStrategy shardingStrategy;
+
+ /**
+ * Flag indicating whether <code>@DocumentId</code> was explicitly specified.
+ */
+ private boolean explicitDocumentId = false;
+
+ /**
+ * Flag indicating whether {@link org.apache.lucene.search.Searcher#doc(int, org.apache.lucene.document.FieldSelector)}
+ * can be used in order to retrieve documents. This is only safe to do if we know that
+ * all involved bridges are implementing <code>TwoWayStringBridge</code>. See HSEARCH-213.
+ */
+ private boolean allowFieldSelectionInProjection = false;
+
+ /**
+ * The class member used as document id.
+ */
+ protected XMember idGetter;
+
+ /**
+ * Name of the document id field.
+ */
+ protected String idKeywordName;
+
+ /**
+ * Boost specified on the document id.
+ */
+ private Float idBoost;
+
+ /**
+ * The bridge used for the document id.
+ */
+ private TwoWayFieldBridge idBridge;
+
+ /**
+ * Flag indicating whether there is an explicit id (@DocumentId or @Id) or not. When Search is used as make
+ * for example using JBoss Cache Searchable the <code>idKeywordName</code> will be provided.
+ */
+ private boolean idProvided = false;
+
+
+ //if composite id, use of (a, b) in ((1,2), (3,4)) fails on most database
+ private boolean safeFromTupleId;
+
+ /**
+ * Creates a document builder for entities annotated with <code>@Indexed</code>.
+ *
+ * @param clazz The class for which to build a <code>DocumentBuilderContainedEntity</code>.
+ * @param context Handle to default configuration settings.
+ * @param directoryProviders Arrays of directory providers for the underlying Lucene indexes of the indexed entity.
+ * @param shardingStrategy The sharding strategy used for the indexed entity.
+ * @param reflectionManager Reflection manager to use for processing the annotations.
+ */
+ public DocumentBuilderIndexedEntity(XClass clazz, InitContext context, DirectoryProvider[] directoryProviders,
+ IndexShardingStrategy shardingStrategy, ReflectionManager reflectionManager) {
+
+ super( clazz, context, reflectionManager );
+
+ this.entityState = EntityState.INDEXED;
+ this.directoryProviders = directoryProviders;
+ this.shardingStrategy = shardingStrategy;
+ }
+
+ protected void init(XClass clazz, InitContext context) {
+ super.init( clazz, context );
+
+ // special case @ProvidedId
+ ProvidedId provided = findProvidedId( clazz, reflectionManager );
+ if ( provided != null ) {
+ idBridge = BridgeFactory.extractTwoWayType( provided.bridge() );
+ idKeywordName = provided.name();
+ }
+
+ if ( idKeywordName == null ) {
+ throw new SearchException( "No document id in: " + clazz.getName() );
+ }
+
+ //if composite id, use of (a, b) in ((1,2),(3,4)) fails on most database
+ //a TwoWayString2FieldBridgeAdaptor is never a composite id
+ safeFromTupleId = TwoWayString2FieldBridgeAdaptor.class.isAssignableFrom( idBridge.getClass() );
+
+ checkAllowFieldSelection();
+ if ( log.isDebugEnabled() ) {
+ log.debug(
+ "Field selection in projections is set to {} for entity {}.",
+ allowFieldSelectionInProjection,
+ clazz.getName()
+ );
+ }
+ }
+
+ protected void checkDocumentId(XProperty member, PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix, InitContext context) {
+ Annotation idAnnotation = getIdAnnotation( member, context );
+ if ( idAnnotation != null ) {
+ String attributeName = getIdAttributeName( member, idAnnotation );
+ if ( isRoot ) {
+ if ( idKeywordName != null && explicitDocumentId ) {
+ throw new AssertionFailure(
+ "Two document id assigned: "
+ + idKeywordName + " and " + attributeName
+ );
+ }
+ idKeywordName = prefix + attributeName;
+ FieldBridge fieldBridge = BridgeFactory.guessType( null, member, reflectionManager );
+ if ( fieldBridge instanceof TwoWayFieldBridge ) {
+ idBridge = ( TwoWayFieldBridge ) fieldBridge;
+ }
+ else {
+ throw new SearchException(
+ "Bridge for document id does not implement TwoWayFieldBridge: " + member.getName()
+ );
+ }
+ idBoost = getBoost( member, null );
+ ReflectionHelper.setAccessible( member );
+ idGetter = member;
+ }
+ else {
+ //component should index their document id
+ ReflectionHelper.setAccessible( member );
+ propertiesMetadata.fieldGetters.add( member );
+ String fieldName = prefix + attributeName;
+ propertiesMetadata.fieldNames.add( fieldName );
+ propertiesMetadata.fieldStore.add( getStore( Store.YES ) );
+ propertiesMetadata.fieldIndex.add( getIndex( Index.UN_TOKENIZED ) );
+ propertiesMetadata.fieldTermVectors.add( getTermVector( TermVector.NO ) );
+ propertiesMetadata.fieldBridges.add( BridgeFactory.guessType( null, member, reflectionManager ) );
+ propertiesMetadata.fieldBoosts.add( getBoost( member, null ) );
+ propertiesMetadata.dynamicFieldBoosts.add( getDynamicBoost( member ) );
+ // property > entity analyzer (no field analyzer)
+ Analyzer analyzer = getAnalyzer( member, context );
+ if ( analyzer == null ) {
+ analyzer = propertiesMetadata.analyzer;
+ }
+ if ( analyzer == null ) {
+ throw new AssertionFailure( "Analizer should not be undefined" );
+ }
+ this.analyzer.addScopedAnalyzer( fieldName, analyzer );
+ }
+ }
+ }
+
+ /**
+ * Checks whether the specified property contains an annotation used as document id.
+ * This can either be an explicit <code>@DocumentId</code> or if no <code>@DocumentId</code> is specified a
+ * JPA <code>@Id</code> annotation. The check for the JPA annotation is indirectly to avoid a hard dependency
+ * to Hibernate Annotations.
+ *
+ * @param member the property to check for the id annotation.
+ * @param context Handle to default configuration settings.
+ *
+ * @return the annotation used as document id or <code>null</code> if id annotation is specified on the property.
+ */
+ private Annotation getIdAnnotation(XProperty member, InitContext context) {
+ Annotation idAnnotation = null;
+
+ // check for explicit DocumentId
+ DocumentId documentIdAnn = member.getAnnotation( DocumentId.class );
+ if ( documentIdAnn != null ) {
+ explicitDocumentId = true;
+ idAnnotation = documentIdAnn;
+ }
+ // check for JPA @Id
+ else if ( !explicitDocumentId && context.isJpaPresent() ) {
+ Annotation jpaId;
+ try {
+ @SuppressWarnings("unchecked")
+ Class<? extends Annotation> jpaIdClass =
+ org.hibernate.annotations.common.util.ReflectHelper
+ .classForName( "javax.persistence.Id", InitContext.class );
+ jpaId = member.getAnnotation( jpaIdClass );
+ }
+ catch ( ClassNotFoundException e ) {
+ throw new SearchException( "Unable to load @Id.class even though it should be present ?!" );
+ }
+ if ( jpaId != null ) {
+ log.debug( "Found JPA id and using it as document id" );
+ idAnnotation = jpaId;
+ }
+ }
+ return idAnnotation;
+ }
+
+ private ProvidedId findProvidedId(XClass clazz, ReflectionManager reflectionManager) {
+ ProvidedId id = null;
+ XClass currentClass = clazz;
+ while ( id == null && ( !reflectionManager.equals( currentClass, Object.class ) ) ) {
+ id = currentClass.getAnnotation( ProvidedId.class );
+ currentClass = currentClass.getSuperclass();
+ }
+ return id;
+ }
+
+ //TODO could we use T instead of EntityClass?
+ public void addWorkToQueue(Class<T> entityClass, T entity, Serializable id, WorkType workType, List<LuceneWork> queue, SearchFactoryImplementor searchFactoryImplementor) {
+ //TODO with the caller loop we are in a n^2: optimize it using a HashMap for work recognition
+
+ boolean sameIdWasSetToBeDeleted = false;
+ List<LuceneWork> toDelete = new ArrayList<LuceneWork>();
+ boolean duplicateDelete = false;
+ for ( LuceneWork luceneWork : queue ) {
+ if ( luceneWork.getEntityClass() == entityClass ) {
+ Serializable currentId = luceneWork.getId();
+ if ( currentId != null && currentId.equals( id ) ) { //find a way to use Type.equals(x,y)
+ if ( luceneWork instanceof DeleteLuceneWork ) {
+ //flag this work as related to a to-be-deleted entity
+ sameIdWasSetToBeDeleted = true;
+ }
+ else if ( luceneWork instanceof AddLuceneWork ) {
+ //if a later work in the queue is adding it back, undo deletion flag:
+ sameIdWasSetToBeDeleted = false;
+ }
+ if ( workType == WorkType.DELETE ) { //TODO add PURGE?
+ //DELETE should have precedence over any update before (HSEARCH-257)
+ //if an Add work is here, remove it
+ //if an other delete is here remember but still search for Add
+ if ( luceneWork instanceof AddLuceneWork ) {
+ toDelete.add( luceneWork );
+ }
+ else if ( luceneWork instanceof DeleteLuceneWork ) {
+ duplicateDelete = true;
+ }
+ }
+ if ( workType == WorkType.ADD ) {
+ if ( luceneWork instanceof AddLuceneWork ) {
+ //embedded objects may issue an "UPDATE" right before the "ADD",
+ //leading to double insertions in the index
+ toDelete.add( luceneWork );
+ }
+ }
+ //TODO do something to avoid multiple PURGE ALL and OPTIMIZE
+ }
+ }
+ }
+
+ if ( sameIdWasSetToBeDeleted && workType == WorkType.COLLECTION ) {
+ //avoid updating (and thus adding) objects which are going to be deleted
+ return;
+ }
+
+ for ( LuceneWork luceneWork : toDelete ) {
+ queue.remove( luceneWork );
+ }
+ if ( duplicateDelete ) {
+ return;
+ }
+
+ if ( workType == WorkType.ADD ) {
+ String idInString = idBridge.objectToString( id );
+ queue.add( createAddWork( entityClass, entity, id, idInString, false ) );
+ }
+ else if ( workType == WorkType.DELETE || workType == WorkType.PURGE ) {
+ String idInString = idBridge.objectToString( id );
+ queue.add( new DeleteLuceneWork( id, idInString, entityClass ) );
+ }
+ else if ( workType == WorkType.PURGE_ALL ) {
+ queue.add( new PurgeAllLuceneWork( entityClass ) );
+ }
+ else if ( workType == WorkType.UPDATE || workType == WorkType.COLLECTION ) {
+ String idInString = idBridge.objectToString( id );
+ queue.add( new DeleteLuceneWork( id, idInString, entityClass ) );
+ queue.add( createAddWork( entityClass, entity, id, idInString, false ) );
+ }
+ else if ( workType == WorkType.INDEX ) {
+ String idInString = idBridge.objectToString( id );
+ queue.add( new DeleteLuceneWork( id, idInString, entityClass ) );
+ queue.add( createAddWork( entityClass, entity, id, idInString, true ) );
+ }
+ else {
+ throw new AssertionFailure( "Unknown WorkType: " + workType );
+ }
+
+ super.addWorkToQueue( entityClass, entity, id, workType, queue, searchFactoryImplementor );
+ }
+
+ public AddLuceneWork createAddWork(Class<T> entityClass, T entity, Serializable id, String idInString, boolean isBatch) {
+ Map<String, String> fieldToAnalyzerMap = new HashMap<String, String>();
+ Document doc = getDocument( entity, id, fieldToAnalyzerMap );
+ AddLuceneWork addWork;
+ if ( fieldToAnalyzerMap.isEmpty() ) {
+ addWork = new AddLuceneWork( id, idInString, entityClass, doc, isBatch );
+ }
+ else {
+ addWork = new AddLuceneWork( id, idInString, entityClass, doc, fieldToAnalyzerMap, isBatch );
+ }
+ return addWork;
+ }
+
+ /**
+ * Builds the Lucene <code>Document</code> for a given entity <code>instance</code> and its <code>id</code>.
+ *
+ * @param instance The entity for which to build the matching Lucene <code>Document</code>
+ * @param id the entity id.
+ * @param fieldToAnalyzerMap this maps gets populated while generating the <code>Document</code>.
+ * It allows to specify for any document field a named analyzer to use. This parameter cannot be <code>null</code>.
+ *
+ * @return The Lucene <code>Document</code> for the specified entity.
+ */
+ public Document getDocument(T instance, Serializable id, Map<String, String> fieldToAnalyzerMap) {
+ if ( fieldToAnalyzerMap == null ) {
+ throw new IllegalArgumentException( "fieldToAnalyzerMap cannot be null" );
+ }
+
+ Document doc = new Document();
+ final Class<?> entityType = Hibernate.getClass( instance );
+ doc.setBoost( metadata.getClassBoost( instance ) );
+
+ // add the class name of the entity to the document
+ Field classField =
+ new Field(
+ CLASS_FIELDNAME,
+ entityType.getName(),
+ Field.Store.YES,
+ Field.Index.NOT_ANALYZED,
+ Field.TermVector.NO
+ );
+ doc.add( classField );
+
+ // now add the entity id to the document
+ LuceneOptions luceneOptions = new LuceneOptionsImpl(
+ Field.Store.YES,
+ Field.Index.NOT_ANALYZED, Field.TermVector.NO, idBoost
+ );
+ idBridge.set( idKeywordName, id, doc, luceneOptions );
+
+ // finally add all other document fields
+ Set<String> processedFieldNames = new HashSet<String>();
+ buildDocumentFields( instance, doc, metadata, fieldToAnalyzerMap, processedFieldNames );
+ return doc;
+ }
+
+ private void buildDocumentFields(Object instance, Document doc, PropertiesMetadata propertiesMetadata, Map<String, String> fieldToAnalyzerMap,
+ Set<String> processedFieldNames) {
+ if ( instance == null ) {
+ return;
+ }
+
+ // needed for field access: I cannot work in the proxied version
+ Object unproxiedInstance = unproxy( instance );
+
+ // process the class bridges
+ for ( int i = 0; i < propertiesMetadata.classBridges.size(); i++ ) {
+ FieldBridge fb = propertiesMetadata.classBridges.get( i );
+ fb.set(
+ propertiesMetadata.classNames.get( i ), unproxiedInstance,
+ doc, propertiesMetadata.getClassLuceneOptions( i )
+ );
+ }
+
+ // process the indexed fields
+ for ( int i = 0; i < propertiesMetadata.fieldNames.size(); i++ ) {
+ XMember member = propertiesMetadata.fieldGetters.get( i );
+ Object value = ReflectionHelper.getMemberValue( unproxiedInstance, member );
+ propertiesMetadata.fieldBridges.get( i ).set(
+ propertiesMetadata.fieldNames.get( i ), value, doc,
+ propertiesMetadata.getFieldLuceneOptions( i, value )
+ );
+ }
+
+ // allow analyzer override for the fields added by the class and field bridges
+ allowAnalyzerDiscriminatorOverride(
+ doc, propertiesMetadata, fieldToAnalyzerMap, processedFieldNames, unproxiedInstance
+ );
+
+ // recursively process embedded objects
+ for ( int i = 0; i < propertiesMetadata.embeddedGetters.size(); i++ ) {
+ XMember member = propertiesMetadata.embeddedGetters.get( i );
+ Object value = ReflectionHelper.getMemberValue( unproxiedInstance, member );
+ //TODO handle boost at embedded level: already stored in propertiesMedatada.boost
+
+ if ( value == null ) {
+ continue;
+ }
+ PropertiesMetadata embeddedMetadata = propertiesMetadata.embeddedPropertiesMetadata.get( i );
+ switch ( propertiesMetadata.embeddedContainers.get( i ) ) {
+ case ARRAY:
+ for ( Object arrayValue : ( Object[] ) value ) {
+ buildDocumentFields(
+ arrayValue, doc, embeddedMetadata, fieldToAnalyzerMap, processedFieldNames
+ );
+ }
+ break;
+ case COLLECTION:
+ for ( Object collectionValue : ( Collection ) value ) {
+ buildDocumentFields(
+ collectionValue, doc, embeddedMetadata, fieldToAnalyzerMap, processedFieldNames
+ );
+ }
+ break;
+ case MAP:
+ for ( Object collectionValue : ( ( Map ) value ).values() ) {
+ buildDocumentFields(
+ collectionValue, doc, embeddedMetadata, fieldToAnalyzerMap, processedFieldNames
+ );
+ }
+ break;
+ case OBJECT:
+ buildDocumentFields( value, doc, embeddedMetadata, fieldToAnalyzerMap, processedFieldNames );
+ break;
+ default:
+ throw new AssertionFailure(
+ "Unknown embedded container: "
+ + propertiesMetadata.embeddedContainers.get( i )
+ );
+ }
+ }
+ }
+
+ /**
+ * Allows a analyzer discriminator to override the analyzer used for any field in the Lucene document.
+ *
+ * @param doc The Lucene <code>Document</code> which shall be indexed.
+ * @param propertiesMetadata The metadata for the entity we currently add to the document.
+ * @param fieldToAnalyzerMap This map contains the actual override data. It is a map between document fields names and
+ * analyzer definition names. This map will be added to the <code>Work</code> instance and processed at actual indexing time.
+ * @param processedFieldNames A list of field names we have already processed.
+ * @param unproxiedInstance The entity we currently "add" to the document.
+ */
+ private void allowAnalyzerDiscriminatorOverride(Document doc, PropertiesMetadata propertiesMetadata, Map<String, String> fieldToAnalyzerMap, Set<String> processedFieldNames, Object unproxiedInstance) {
+ Discriminator discriminator = propertiesMetadata.discriminator;
+ if ( discriminator == null ) {
+ return;
+ }
+
+ Object value = null;
+ if ( propertiesMetadata.discriminatorGetter != null ) {
+ value = ReflectionHelper.getMemberValue( unproxiedInstance, propertiesMetadata.discriminatorGetter );
+ }
+
+ // now we give the discriminator the opportunity to specify a analyzer per field level
+ for ( Object o : doc.getFields() ) {
+ Field field = ( Field ) o;
+ if ( !processedFieldNames.contains( field.name() ) ) {
+ String analyzerName = discriminator.getAnalyzerDefinitionName( value, unproxiedInstance, field.name() );
+ if ( analyzerName != null ) {
+ fieldToAnalyzerMap.put( field.name(), analyzerName );
+ }
+ processedFieldNames.add( field.name() );
+ }
+ }
+ }
+
+ private Object unproxy(Object value) {
+ //FIXME this service should be part of Core?
+ if ( value instanceof HibernateProxy ) {
+ // .getImplementation() initializes the data by side effect
+ value = ( ( HibernateProxy ) value ).getHibernateLazyInitializer()
+ .getImplementation();
+ }
+ return value;
+ }
+
+ public String getIdentifierName() {
+ return idGetter.getName();
+ }
+
+ public DirectoryProvider[] getDirectoryProviders() {
+ if ( entityState != EntityState.INDEXED ) {
+ throw new AssertionFailure( "Contained in only entity: getDirectoryProvider should not have been called." );
+ }
+ return directoryProviders;
+ }
+
+ public IndexShardingStrategy getDirectoryProviderSelectionStrategy() {
+ if ( entityState != EntityState.INDEXED ) {
+ throw new AssertionFailure(
+ "Contained in only entity: getDirectoryProviderSelectionStrategy should not have been called."
+ );
+ }
+ return shardingStrategy;
+ }
+
+ public boolean allowFieldSelectionInProjection() {
+ return allowFieldSelectionInProjection;
+ }
+
+ /**
+ * @return <code>false</code> if there is a risk of composite id. If composite id, use of (a, b) in ((1,2), (3,4)) fails on most database
+ */
+ public boolean isSafeFromTupleId() {
+ return safeFromTupleId;
+ }
+
+ public Term getTerm(Serializable id) {
+ if ( idProvided ) {
+ return new Term( idKeywordName, ( String ) id );
+ }
+
+ return new Term( idKeywordName, idBridge.objectToString( id ) );
+ }
+
+ public TwoWayFieldBridge getIdBridge() {
+ return idBridge;
+ }
+
+ public static Class getDocumentClass(Document document) {
+ String className = document.get( CLASS_FIELDNAME );
+ try {
+ return ReflectHelper.classForName( className );
+ }
+ catch ( ClassNotFoundException e ) {
+ throw new SearchException( "Unable to load indexed class: " + className, e );
+ }
+ }
+
+ public String getIdKeywordName() {
+ return idKeywordName;
+ }
+
+ public static Serializable getDocumentId(SearchFactoryImplementor searchFactoryImplementor, Class<?> clazz, Document document) {
+ DocumentBuilderIndexedEntity<?> builderIndexedEntity = searchFactoryImplementor.getDocumentBuilderIndexedEntity(
+ clazz
+ );
+ if ( builderIndexedEntity == null ) {
+ throw new SearchException( "No Lucene configuration set up for: " + clazz.getName() );
+ }
+ return ( Serializable ) builderIndexedEntity.getIdBridge()
+ .get( builderIndexedEntity.getIdKeywordName(), document );
+ }
+
+ public static Object[] getDocumentFields(SearchFactoryImplementor searchFactoryImplementor, Class<?> clazz, Document document, String[] fields) {
+ DocumentBuilderIndexedEntity<?> builderIndexedEntity = searchFactoryImplementor.getDocumentBuilderIndexedEntity(
+ clazz
+ );
+ if ( builderIndexedEntity == null ) {
+ throw new SearchException( "No Lucene configuration set up for: " + clazz.getName() );
+ }
+ final int fieldNbr = fields.length;
+ Object[] result = new Object[fieldNbr];
+
+ if ( builderIndexedEntity.idKeywordName != null ) {
+ populateResult(
+ builderIndexedEntity.idKeywordName,
+ builderIndexedEntity.idBridge,
+ Field.Store.YES,
+ fields,
+ result,
+ document
+ );
+ }
+
+ final PropertiesMetadata metadata = builderIndexedEntity.metadata;
+ processFieldsForProjection( metadata, fields, result, document );
+ return result;
+ }
+
+ private static void populateResult(String fieldName, FieldBridge fieldBridge, Field.Store store,
+ String[] fields, Object[] result, Document document) {
+ int matchingPosition = getFieldPosition( fields, fieldName );
+ if ( matchingPosition != -1 ) {
+ //TODO make use of an isTwoWay() method
+ if ( store != Field.Store.NO && TwoWayFieldBridge.class.isAssignableFrom( fieldBridge.getClass() ) ) {
+ result[matchingPosition] = ( ( TwoWayFieldBridge ) fieldBridge ).get( fieldName, document );
+ if ( log.isTraceEnabled() ) {
+ log.trace( "Field {} projected as {}", fieldName, result[matchingPosition] );
+ }
+ }
+ else {
+ if ( store == Field.Store.NO ) {
+ throw new SearchException( "Projecting an unstored field: " + fieldName );
+ }
+ else {
+ throw new SearchException( "FieldBridge is not a TwoWayFieldBridge: " + fieldBridge.getClass() );
+ }
+ }
+ }
+ }
+
+ private static void processFieldsForProjection(PropertiesMetadata metadata, String[] fields, Object[] result, Document document) {
+ final int nbrFoEntityFields = metadata.fieldNames.size();
+ for ( int index = 0; index < nbrFoEntityFields; index++ ) {
+ populateResult(
+ metadata.fieldNames.get( index ),
+ metadata.fieldBridges.get( index ),
+ metadata.fieldStore.get( index ),
+ fields,
+ result,
+ document
+ );
+ }
+ final int nbrOfEmbeddedObjects = metadata.embeddedPropertiesMetadata.size();
+ for ( int index = 0; index < nbrOfEmbeddedObjects; index++ ) {
+ //there is nothing we can do for collections
+ if ( metadata.embeddedContainers.get( index ) == PropertiesMetadata.Container.OBJECT ) {
+ processFieldsForProjection(
+ metadata.embeddedPropertiesMetadata.get( index ), fields, result, document
+ );
+ }
+ }
+ }
+
+ private static int getFieldPosition(String[] fields, String fieldName) {
+ int fieldNbr = fields.length;
+ for ( int index = 0; index < fieldNbr; index++ ) {
+ if ( fieldName.equals( fields[index] ) ) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Checks whether all involved bridges are two way string bridges. If so we can optimize document retrieval
+ * by using <code>FieldSelector</code>. See HSEARCH-213.
+ */
+ private void checkAllowFieldSelection() {
+ allowFieldSelectionInProjection = true;
+ if ( !( idBridge instanceof TwoWayStringBridge || idBridge instanceof TwoWayString2FieldBridgeAdaptor ) ) {
+ allowFieldSelectionInProjection = false;
+ return;
+ }
+ for ( FieldBridge bridge : metadata.fieldBridges ) {
+ if ( !( bridge instanceof TwoWayStringBridge || bridge instanceof TwoWayString2FieldBridgeAdaptor ) ) {
+ allowFieldSelectionInProjection = false;
+ return;
+ }
+ }
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/engine/DocumentExtractor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/DocumentExtractor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/DocumentExtractor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
import java.io.IOException;
Modified: search/trunk/src/main/java/org/hibernate/search/engine/EntityInfo.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/EntityInfo.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/EntityInfo.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,25 +1,48 @@
-//$Id$
-package org.hibernate.search.engine;
-
-import java.io.Serializable;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- *
- * @author Emmanuel Bernard
- */
-public class EntityInfo {
-
- public final Class clazz;
- public final Serializable id;
- public final Object[] projection;
- public final List<Integer> indexesOfThis = new LinkedList<Integer>();
-
- public EntityInfo(Class clazz, Serializable id, Object[] projection) {
- this.clazz = clazz;
- this.id = id;
- this.projection = projection;
- }
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.engine;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ *
+ * @author Emmanuel Bernard
+ */
+public class EntityInfo {
+
+ public final Class clazz;
+ public final Serializable id;
+ public final Object[] projection;
+ public final List<Integer> indexesOfThis = new LinkedList<Integer>();
+
+ public EntityInfo(Class clazz, Serializable id, Object[] projection) {
+ this.clazz = clazz;
+ this.id = id;
+ this.projection = projection;
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/engine/EntityState.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/EntityState.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/EntityState.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
/**
Modified: search/trunk/src/main/java/org/hibernate/search/engine/FilterDef.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/FilterDef.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/FilterDef.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
import java.lang.reflect.InvocationTargetException;
Modified: search/trunk/src/main/java/org/hibernate/search/engine/Loader.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/Loader.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/Loader.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
import java.util.List;
Modified: search/trunk/src/main/java/org/hibernate/search/engine/LoaderHelper.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/LoaderHelper.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/LoaderHelper.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
import java.util.ArrayList;
Modified: search/trunk/src/main/java/org/hibernate/search/engine/LuceneOptionsImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/LuceneOptionsImpl.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/LuceneOptionsImpl.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
import org.apache.lucene.document.Field.Index;
@@ -49,4 +72,4 @@
return 1.0f;
}
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/main/java/org/hibernate/search/engine/MultiClassesQueryLoader.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/MultiClassesQueryLoader.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/MultiClassesQueryLoader.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
import java.util.ArrayList;
Modified: search/trunk/src/main/java/org/hibernate/search/engine/ObjectLoader.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/ObjectLoader.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/ObjectLoader.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
import java.util.ArrayList;
Modified: search/trunk/src/main/java/org/hibernate/search/engine/ObjectLoaderHelper.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/ObjectLoaderHelper.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/ObjectLoaderHelper.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/engine/ProjectionLoader.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/ProjectionLoader.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/ProjectionLoader.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
import java.util.ArrayList;
Modified: search/trunk/src/main/java/org/hibernate/search/engine/QueryLoader.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/QueryLoader.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/QueryLoader.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
import java.util.List;
Modified: search/trunk/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.engine;
import java.util.Map;
Modified: search/trunk/src/main/java/org/hibernate/search/event/ContextHolder.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/event/ContextHolder.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/event/ContextHolder.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.event;
import java.util.WeakHashMap;
Modified: search/trunk/src/main/java/org/hibernate/search/event/EventListenerRegister.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/event/EventListenerRegister.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/event/EventListenerRegister.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.event;
import java.util.Properties;
Modified: search/trunk/src/main/java/org/hibernate/search/event/FullTextIndexCollectionEventListener.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/event/FullTextIndexCollectionEventListener.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/event/FullTextIndexCollectionEventListener.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.event;
import org.hibernate.event.PostCollectionRecreateEvent;
Modified: search/trunk/src/main/java/org/hibernate/search/event/FullTextIndexEventListener.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/event/FullTextIndexEventListener.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/event/FullTextIndexEventListener.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,235 +1,258 @@
-//$Id$
-package org.hibernate.search.event;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.util.Map;
-
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-
-import org.slf4j.Logger;
-
-import org.hibernate.Session;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.engine.EntityEntry;
-import org.hibernate.event.AbstractCollectionEvent;
-import org.hibernate.event.AbstractEvent;
-import org.hibernate.event.Destructible;
-import org.hibernate.event.EventSource;
-import org.hibernate.event.FlushEvent;
-import org.hibernate.event.FlushEventListener;
-import org.hibernate.event.Initializable;
-import org.hibernate.event.PostCollectionRecreateEvent;
-import org.hibernate.event.PostCollectionRecreateEventListener;
-import org.hibernate.event.PostCollectionRemoveEvent;
-import org.hibernate.event.PostCollectionRemoveEventListener;
-import org.hibernate.event.PostCollectionUpdateEvent;
-import org.hibernate.event.PostCollectionUpdateEventListener;
-import org.hibernate.event.PostDeleteEvent;
-import org.hibernate.event.PostDeleteEventListener;
-import org.hibernate.event.PostInsertEvent;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.event.PostUpdateEvent;
-import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.search.backend.Work;
-import org.hibernate.search.backend.WorkType;
-import org.hibernate.search.backend.impl.EventSourceTransactionContext;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.util.LoggerFactory;
-import org.hibernate.search.util.WeakIdentityHashMap;
-
-/**
- * This listener supports setting a parent directory for all generated index files.
- * It also supports setting the analyzer class to be used.
- *
- * @author Gavin King
- * @author Emmanuel Bernard
- * @author Mattias Arbin
- * @author Sanne Grinovero
- */
-//TODO implement and use a LockableDirectoryProvider that wraps a DP to handle the lock inside the LDP
-//TODO make this class final as soon as FullTextIndexCollectionEventListener is removed.
-@SuppressWarnings( "serial" )
-public class FullTextIndexEventListener implements PostDeleteEventListener,
- PostInsertEventListener, PostUpdateEventListener,
- PostCollectionRecreateEventListener, PostCollectionRemoveEventListener,
- PostCollectionUpdateEventListener, FlushEventListener, Initializable, Destructible {
-
- private static final Logger log = LoggerFactory.make();
-
- protected boolean used;
- protected SearchFactoryImplementor searchFactoryImplementor;
-
- //only used by the FullTextIndexEventListener instance playing in the FlushEventListener role.
- // transient because it's not serializable (and state doesn't need to live longer than a flush).
- // final because it's initialization should be published to other threads.
- // ! update the readObject() method in case of name changes !
- // make sure the Synchronization doesn't contain references to Session, otherwise we'll leak memory.
- private transient final Map<Session,Synchronization> flushSynch = new WeakIdentityHashMap<Session,Synchronization>(0);
-
- /**
- * Initialize method called by Hibernate Core when the SessionFactory starts
- */
-
- public void initialize(Configuration cfg) {
- searchFactoryImplementor = ContextHolder.getOrBuildSearchFactory( cfg );
- String indexingStrategy = searchFactoryImplementor.getIndexingStrategy();
- if ( "event".equals( indexingStrategy ) ) {
- used = searchFactoryImplementor.getDocumentBuildersIndexedEntities().size() != 0;
- }
- else if ( "manual".equals( indexingStrategy ) ) {
- used = false;
- }
- }
-
- public SearchFactoryImplementor getSearchFactoryImplementor() {
- return searchFactoryImplementor;
- }
-
- public void onPostDelete(PostDeleteEvent event) {
- if ( used ) {
- final Class<?> entityType = event.getEntity().getClass();
- if ( searchFactoryImplementor.getDocumentBuildersIndexedEntities().containsKey( entityType )
- || searchFactoryImplementor.getDocumentBuilderContainedEntity( entityType ) != null ) {
- processWork( event.getEntity(), event.getId(), WorkType.DELETE, event );
- }
- }
- }
-
- public void onPostInsert(PostInsertEvent event) {
- if ( used ) {
- final Object entity = event.getEntity();
- if ( searchFactoryImplementor.getDocumentBuilderIndexedEntity( entity.getClass() ) != null
- || searchFactoryImplementor.getDocumentBuilderContainedEntity( entity.getClass() ) != null ) {
- Serializable id = event.getId();
- processWork( entity, id, WorkType.ADD, event );
- }
- }
- }
-
- public void onPostUpdate(PostUpdateEvent event) {
- if ( used ) {
- final Object entity = event.getEntity();
- if ( searchFactoryImplementor.getDocumentBuilderIndexedEntity( entity.getClass() ) != null
- || searchFactoryImplementor.getDocumentBuilderContainedEntity( entity.getClass() ) != null ) {
- Serializable id = event.getId();
- processWork( entity, id, WorkType.UPDATE, event );
- }
- }
- }
-
- protected <T> void processWork(T entity, Serializable id, WorkType workType, AbstractEvent event) {
- Work<T> work = new Work<T>( entity, id, workType );
- final EventSourceTransactionContext transactionContext = new EventSourceTransactionContext( event.getSession() );
- searchFactoryImplementor.getWorker().performWork( work, transactionContext );
- }
-
- public void cleanup() {
- searchFactoryImplementor.close();
- }
-
- public void onPostRecreateCollection(PostCollectionRecreateEvent event) {
- processCollectionEvent( event );
- }
-
- public void onPostRemoveCollection(PostCollectionRemoveEvent event) {
- processCollectionEvent( event );
- }
-
- public void onPostUpdateCollection(PostCollectionUpdateEvent event) {
- processCollectionEvent( event );
- }
-
- protected void processCollectionEvent(AbstractCollectionEvent event) {
- Object entity = event.getAffectedOwnerOrNull();
- if ( entity == null ) {
- //Hibernate cannot determine every single time the owner especially in case detached objects are involved
- // or property-ref is used
- //Should log really but we don't know if we're interested in this collection for indexing
- return;
- }
- if ( used ) {
- if ( searchFactoryImplementor.getDocumentBuilderIndexedEntity( entity.getClass() ) != null
- || searchFactoryImplementor.getDocumentBuilderContainedEntity( entity.getClass() ) != null ) {
- Serializable id = getId( entity, event );
- if ( id == null ) {
- log.warn(
- "Unable to reindex entity on collection change, id cannot be extracted: {}",
- event.getAffectedOwnerEntityName()
- );
- return;
- }
- processWork( entity, id, WorkType.COLLECTION, event );
- }
- }
- }
-
- private Serializable getId(Object entity, AbstractCollectionEvent event) {
- Serializable id = event.getAffectedOwnerIdOrNull();
- if ( id == null ) {
- //most likely this recovery is unnecessary since Hibernate Core probably try that
- EntityEntry entityEntry = event.getSession().getPersistenceContext().getEntry( entity );
- id = entityEntry == null ? null : entityEntry.getId();
- }
- return id;
- }
-
- /**
- * Make sure the indexes are updated right after the hibernate flush,
- * avoiding object loading during a flush. Not needed during transactions.
- */
- public void onFlush(FlushEvent event) {
- if ( used ) {
- Session session = event.getSession();
- Synchronization synchronization = flushSynch.get( session );
- if ( synchronization != null ) {
- //first cleanup
- flushSynch.remove( session );
- log.debug( "flush event causing index update out of transaction" );
- synchronization.beforeCompletion();
- synchronization.afterCompletion( Status.STATUS_COMMITTED );
- }
- }
- }
-
- /**
- * Adds a synchronization to be performed in the onFlush method;
- * should only be used as workaround for the case a flush is happening
- * out of transaction.
- * Warning: if the synchronization contains a hard reference
- * to the Session proper cleanup is not guaranteed and memory leaks
- * will happen.
- * @param eventSource should be the Session doing the flush
- * @param synchronization
- */
- public void addSynchronization(EventSource eventSource, Synchronization synchronization) {
- this.flushSynch.put( eventSource, synchronization );
- }
-
- /* Might want to implement AutoFlushEventListener in future?
- public void onAutoFlush(AutoFlushEvent event) throws HibernateException {
- // Currently not needed as auto-flush is not happening
- // when out of transaction.
- }
- */
-
- private void writeObject(ObjectOutputStream os) throws IOException {
- os.defaultWriteObject();
- }
-
- //needs to implement custom readObject to restore the transient fields
- private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
- is.defaultReadObject();
- Class<FullTextIndexEventListener> cl = FullTextIndexEventListener.class;
- Field f = cl.getDeclaredField("flushSynch");
- f.setAccessible( true );
- Map<Session,Synchronization> flushSynch = new WeakIdentityHashMap<Session,Synchronization>(0);
- // setting a final field by reflection during a readObject is considered as safe as in a constructor:
- f.set( this, flushSynch );
- }
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.event;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.util.Map;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+
+import org.slf4j.Logger;
+
+import org.hibernate.Session;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.engine.EntityEntry;
+import org.hibernate.event.AbstractCollectionEvent;
+import org.hibernate.event.AbstractEvent;
+import org.hibernate.event.Destructible;
+import org.hibernate.event.EventSource;
+import org.hibernate.event.FlushEvent;
+import org.hibernate.event.FlushEventListener;
+import org.hibernate.event.Initializable;
+import org.hibernate.event.PostCollectionRecreateEvent;
+import org.hibernate.event.PostCollectionRecreateEventListener;
+import org.hibernate.event.PostCollectionRemoveEvent;
+import org.hibernate.event.PostCollectionRemoveEventListener;
+import org.hibernate.event.PostCollectionUpdateEvent;
+import org.hibernate.event.PostCollectionUpdateEventListener;
+import org.hibernate.event.PostDeleteEvent;
+import org.hibernate.event.PostDeleteEventListener;
+import org.hibernate.event.PostInsertEvent;
+import org.hibernate.event.PostInsertEventListener;
+import org.hibernate.event.PostUpdateEvent;
+import org.hibernate.event.PostUpdateEventListener;
+import org.hibernate.search.backend.Work;
+import org.hibernate.search.backend.WorkType;
+import org.hibernate.search.backend.impl.EventSourceTransactionContext;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.util.LoggerFactory;
+import org.hibernate.search.util.WeakIdentityHashMap;
+
+/**
+ * This listener supports setting a parent directory for all generated index files.
+ * It also supports setting the analyzer class to be used.
+ *
+ * @author Gavin King
+ * @author Emmanuel Bernard
+ * @author Mattias Arbin
+ * @author Sanne Grinovero
+ */
+//TODO implement and use a LockableDirectoryProvider that wraps a DP to handle the lock inside the LDP
+//TODO make this class final as soon as FullTextIndexCollectionEventListener is removed.
+@SuppressWarnings( "serial" )
+public class FullTextIndexEventListener implements PostDeleteEventListener,
+ PostInsertEventListener, PostUpdateEventListener,
+ PostCollectionRecreateEventListener, PostCollectionRemoveEventListener,
+ PostCollectionUpdateEventListener, FlushEventListener, Initializable, Destructible {
+
+ private static final Logger log = LoggerFactory.make();
+
+ protected boolean used;
+ protected SearchFactoryImplementor searchFactoryImplementor;
+
+ //only used by the FullTextIndexEventListener instance playing in the FlushEventListener role.
+ // transient because it's not serializable (and state doesn't need to live longer than a flush).
+ // final because it's initialization should be published to other threads.
+ // ! update the readObject() method in case of name changes !
+ // make sure the Synchronization doesn't contain references to Session, otherwise we'll leak memory.
+ private transient final Map<Session,Synchronization> flushSynch = new WeakIdentityHashMap<Session,Synchronization>(0);
+
+ /**
+ * Initialize method called by Hibernate Core when the SessionFactory starts
+ */
+
+ public void initialize(Configuration cfg) {
+ searchFactoryImplementor = ContextHolder.getOrBuildSearchFactory( cfg );
+ String indexingStrategy = searchFactoryImplementor.getIndexingStrategy();
+ if ( "event".equals( indexingStrategy ) ) {
+ used = searchFactoryImplementor.getDocumentBuildersIndexedEntities().size() != 0;
+ }
+ else if ( "manual".equals( indexingStrategy ) ) {
+ used = false;
+ }
+ }
+
+ public SearchFactoryImplementor getSearchFactoryImplementor() {
+ return searchFactoryImplementor;
+ }
+
+ public void onPostDelete(PostDeleteEvent event) {
+ if ( used ) {
+ final Class<?> entityType = event.getEntity().getClass();
+ if ( searchFactoryImplementor.getDocumentBuildersIndexedEntities().containsKey( entityType )
+ || searchFactoryImplementor.getDocumentBuilderContainedEntity( entityType ) != null ) {
+ processWork( event.getEntity(), event.getId(), WorkType.DELETE, event );
+ }
+ }
+ }
+
+ public void onPostInsert(PostInsertEvent event) {
+ if ( used ) {
+ final Object entity = event.getEntity();
+ if ( searchFactoryImplementor.getDocumentBuilderIndexedEntity( entity.getClass() ) != null
+ || searchFactoryImplementor.getDocumentBuilderContainedEntity( entity.getClass() ) != null ) {
+ Serializable id = event.getId();
+ processWork( entity, id, WorkType.ADD, event );
+ }
+ }
+ }
+
+ public void onPostUpdate(PostUpdateEvent event) {
+ if ( used ) {
+ final Object entity = event.getEntity();
+ if ( searchFactoryImplementor.getDocumentBuilderIndexedEntity( entity.getClass() ) != null
+ || searchFactoryImplementor.getDocumentBuilderContainedEntity( entity.getClass() ) != null ) {
+ Serializable id = event.getId();
+ processWork( entity, id, WorkType.UPDATE, event );
+ }
+ }
+ }
+
+ protected <T> void processWork(T entity, Serializable id, WorkType workType, AbstractEvent event) {
+ Work<T> work = new Work<T>( entity, id, workType );
+ final EventSourceTransactionContext transactionContext = new EventSourceTransactionContext( event.getSession() );
+ searchFactoryImplementor.getWorker().performWork( work, transactionContext );
+ }
+
+ public void cleanup() {
+ searchFactoryImplementor.close();
+ }
+
+ public void onPostRecreateCollection(PostCollectionRecreateEvent event) {
+ processCollectionEvent( event );
+ }
+
+ public void onPostRemoveCollection(PostCollectionRemoveEvent event) {
+ processCollectionEvent( event );
+ }
+
+ public void onPostUpdateCollection(PostCollectionUpdateEvent event) {
+ processCollectionEvent( event );
+ }
+
+ protected void processCollectionEvent(AbstractCollectionEvent event) {
+ Object entity = event.getAffectedOwnerOrNull();
+ if ( entity == null ) {
+ //Hibernate cannot determine every single time the owner especially in case detached objects are involved
+ // or property-ref is used
+ //Should log really but we don't know if we're interested in this collection for indexing
+ return;
+ }
+ if ( used ) {
+ if ( searchFactoryImplementor.getDocumentBuilderIndexedEntity( entity.getClass() ) != null
+ || searchFactoryImplementor.getDocumentBuilderContainedEntity( entity.getClass() ) != null ) {
+ Serializable id = getId( entity, event );
+ if ( id == null ) {
+ log.warn(
+ "Unable to reindex entity on collection change, id cannot be extracted: {}",
+ event.getAffectedOwnerEntityName()
+ );
+ return;
+ }
+ processWork( entity, id, WorkType.COLLECTION, event );
+ }
+ }
+ }
+
+ private Serializable getId(Object entity, AbstractCollectionEvent event) {
+ Serializable id = event.getAffectedOwnerIdOrNull();
+ if ( id == null ) {
+ //most likely this recovery is unnecessary since Hibernate Core probably try that
+ EntityEntry entityEntry = event.getSession().getPersistenceContext().getEntry( entity );
+ id = entityEntry == null ? null : entityEntry.getId();
+ }
+ return id;
+ }
+
+ /**
+ * Make sure the indexes are updated right after the hibernate flush,
+ * avoiding object loading during a flush. Not needed during transactions.
+ */
+ public void onFlush(FlushEvent event) {
+ if ( used ) {
+ Session session = event.getSession();
+ Synchronization synchronization = flushSynch.get( session );
+ if ( synchronization != null ) {
+ //first cleanup
+ flushSynch.remove( session );
+ log.debug( "flush event causing index update out of transaction" );
+ synchronization.beforeCompletion();
+ synchronization.afterCompletion( Status.STATUS_COMMITTED );
+ }
+ }
+ }
+
+ /**
+ * Adds a synchronization to be performed in the onFlush method;
+ * should only be used as workaround for the case a flush is happening
+ * out of transaction.
+ * Warning: if the synchronization contains a hard reference
+ * to the Session proper cleanup is not guaranteed and memory leaks
+ * will happen.
+ * @param eventSource should be the Session doing the flush
+ * @param synchronization
+ */
+ public void addSynchronization(EventSource eventSource, Synchronization synchronization) {
+ this.flushSynch.put( eventSource, synchronization );
+ }
+
+ /* Might want to implement AutoFlushEventListener in future?
+ public void onAutoFlush(AutoFlushEvent event) throws HibernateException {
+ // Currently not needed as auto-flush is not happening
+ // when out of transaction.
+ }
+ */
+
+ private void writeObject(ObjectOutputStream os) throws IOException {
+ os.defaultWriteObject();
+ }
+
+ //needs to implement custom readObject to restore the transient fields
+ private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
+ is.defaultReadObject();
+ Class<FullTextIndexEventListener> cl = FullTextIndexEventListener.class;
+ Field f = cl.getDeclaredField("flushSynch");
+ f.setAccessible( true );
+ Map<Session,Synchronization> flushSynch = new WeakIdentityHashMap<Session,Synchronization>(0);
+ // setting a final field by reflection during a readObject is considered as safe as in a constructor:
+ f.set( this, flushSynch );
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/filter/AndDocIdSet.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/filter/AndDocIdSet.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/filter/AndDocIdSet.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.filter;
import java.io.IOException;
Modified: search/trunk/src/main/java/org/hibernate/search/filter/CachingWrapperFilter.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/filter/CachingWrapperFilter.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/filter/CachingWrapperFilter.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.filter;
import java.io.IOException;
Modified: search/trunk/src/main/java/org/hibernate/search/filter/ChainedFilter.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/filter/ChainedFilter.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/filter/ChainedFilter.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.filter;
import java.util.BitSet;
Modified: search/trunk/src/main/java/org/hibernate/search/filter/EmptyDocIdBitSet.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/filter/EmptyDocIdBitSet.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/filter/EmptyDocIdBitSet.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.filter;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/filter/FilterCachingStrategy.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/filter/FilterCachingStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/filter/FilterCachingStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.filter;
import java.util.Properties;
Modified: search/trunk/src/main/java/org/hibernate/search/filter/FilterKey.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/filter/FilterKey.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/filter/FilterKey.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.filter;
/**
Modified: search/trunk/src/main/java/org/hibernate/search/filter/FilterOptimizationHelper.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/filter/FilterOptimizationHelper.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/filter/FilterOptimizationHelper.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.filter;
import java.util.ArrayList;
Modified: search/trunk/src/main/java/org/hibernate/search/filter/FullTextFilterImplementor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/filter/FullTextFilterImplementor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/filter/FullTextFilterImplementor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.filter;
import org.hibernate.search.FullTextFilter;
Modified: search/trunk/src/main/java/org/hibernate/search/filter/MRUFilterCachingStrategy.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/filter/MRUFilterCachingStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/filter/MRUFilterCachingStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.filter;
import java.util.Properties;
Modified: search/trunk/src/main/java/org/hibernate/search/filter/ShardSensitiveOnlyFilter.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/filter/ShardSensitiveOnlyFilter.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/filter/ShardSensitiveOnlyFilter.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.filter;
/**
Modified: search/trunk/src/main/java/org/hibernate/search/filter/StandardFilterKey.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/filter/StandardFilterKey.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/filter/StandardFilterKey.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.filter;
import java.util.List;
Modified: search/trunk/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,737 +1,760 @@
-//$Id$
-package org.hibernate.search.impl;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.hibernate.CacheMode;
-import org.hibernate.Criteria;
-import org.hibernate.EntityMode;
-import org.hibernate.Filter;
-import org.hibernate.FlushMode;
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.Interceptor;
-import org.hibernate.LockMode;
-import org.hibernate.Query;
-import org.hibernate.ReplicationMode;
-import org.hibernate.SQLQuery;
-import org.hibernate.ScrollMode;
-import org.hibernate.ScrollableResults;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.UnknownProfileException;
-import org.hibernate.classic.Session;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.engine.EntityKey;
-import org.hibernate.engine.PersistenceContext;
-import org.hibernate.engine.QueryParameters;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.LoadQueryInfluencers;
-import org.hibernate.engine.query.ParameterMetadata;
-import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
-import org.hibernate.event.EventListeners;
-import org.hibernate.event.EventSource;
-import org.hibernate.impl.CriteriaImpl;
-import org.hibernate.jdbc.Batcher;
-import org.hibernate.jdbc.JDBCContext;
-import org.hibernate.loader.custom.CustomQuery;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.search.FullTextQuery;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.SearchFactory;
-import org.hibernate.search.MassIndexer;
-import org.hibernate.search.backend.TransactionContext;
-import org.hibernate.search.backend.Work;
-import org.hibernate.search.backend.WorkType;
-import org.hibernate.search.backend.impl.EventSourceTransactionContext;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.query.FullTextQueryImpl;
-import org.hibernate.search.util.ContextHelper;
-import org.hibernate.stat.SessionStatistics;
-import org.hibernate.type.Type;
-
-/**
- * Lucene full text search aware session.
- *
- * @author Emmanuel Bernard
- * @author John Griffin
- * @author Hardy Ferentschik
- */
-@SuppressWarnings( "deprecation" )
-public class FullTextSessionImpl implements FullTextSession, SessionImplementor {
-
- private final Session session;
- private final SessionImplementor sessionImplementor;
- private transient SearchFactoryImplementor searchFactory;
- private final TransactionContext transactionContext;
-
-
- public FullTextSessionImpl(org.hibernate.Session session) {
- this.session = ( Session ) session;
- this.transactionContext = new EventSourceTransactionContext( ( EventSource ) session );
- this.sessionImplementor = ( SessionImplementor ) session;
- }
-
- /**
- * Execute a Lucene query and retrieve managed objects of type entities (or their indexed subclasses)
- * If entities is empty, include all indexed entities
- *
- * @param entities must be immutable for the lifetime of the query object
- */
- public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class... entities) {
- return new FullTextQueryImpl( luceneQuery, entities, sessionImplementor, new ParameterMetadata( null, null ) );
- }
-
- /**
- * {@inheritDoc}
- */
- public <T> void purgeAll(Class<T> entityType) {
- purge( entityType, null );
- }
-
- public void flushToIndexes() {
- SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
- searchFactoryImplementor.getWorker().flushWorks( transactionContext );
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings( "unchecked" )
- public <T> void purge(Class<T> entityType, Serializable id) {
- if ( entityType == null ) {
- return;
- }
-
- SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
- Set<Class<?>> targetedClasses = searchFactoryImplementor.getIndexedTypesPolymorphic( new Class[] {entityType} );
- if ( targetedClasses.isEmpty() ) {
- String msg = entityType.getName() + " is not an indexed entity or a subclass of an indexed entity";
- throw new IllegalArgumentException( msg );
- }
-
- Work<T> work;
- for ( Class clazz : targetedClasses ) {
- if ( id == null ) {
- work = new Work<T>( clazz, null, WorkType.PURGE_ALL );
- searchFactoryImplementor.getWorker().performWork( work, transactionContext );
- }
- else {
- work = new Work<T>( clazz, id, WorkType.PURGE );
- searchFactoryImplementor.getWorker().performWork( work, transactionContext );
- }
- }
- }
-
- /**
- * (Re-)index an entity.
- * The entity must be associated with the session and non indexable entities are ignored.
- *
- * @param entity The entity to index - must not be <code>null</code>.
- *
- * @throws IllegalArgumentException if entity is null or not an @Indexed entity
- */
- public <T> void index(T entity) {
- if ( entity == null ) {
- throw new IllegalArgumentException( "Entity to index should not be null" );
- }
-
- Class<?> clazz = Hibernate.getClass( entity );
- //TODO cache that at the FTSession level
- SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
- //not strictly necessary but a small optimization
- if ( searchFactoryImplementor.getDocumentBuilderIndexedEntity( clazz ) == null ) {
- String msg = "Entity to index is not an @Indexed entity: " + entity.getClass().getName();
- throw new IllegalArgumentException( msg );
- }
- Serializable id = session.getIdentifier( entity );
- Work<T> work = new Work<T>( entity, id, WorkType.INDEX );
- searchFactoryImplementor.getWorker().performWork( work, transactionContext );
-
- //TODO
- //need to add elements in a queue kept at the Session level
- //the queue will be processed by a Lucene(Auto)FlushEventListener
- //note that we could keep this queue somewhere in the event listener in the mean time but that requires
- //a synchronized hashmap holding this queue on a per session basis plus some session house keeping (yuk)
- //another solution would be to subclass SessionImpl instead of having this LuceneSession delegation model
- //this is an open discussion
- }
-
- public MassIndexer createIndexer(Class<?>... types) {
- if ( types.length == 0 ) {
- return new MassIndexerImpl( getSearchFactoryImplementor(), getSessionFactory(), Object.class );
- }
- else {
- return new MassIndexerImpl( getSearchFactoryImplementor(), getSessionFactory(), types );
- }
- }
-
- public SearchFactory getSearchFactory() {
- if ( searchFactory == null ) {
- searchFactory = ContextHelper.getSearchFactory( session );
- }
- return searchFactory;
- }
-
- private SearchFactoryImplementor getSearchFactoryImplementor() {
- if ( searchFactory == null ) {
- searchFactory = ContextHelper.getSearchFactory( session );
- }
- return searchFactory;
- }
-
- public Query createSQLQuery(String sql, String returnAlias, Class returnClass) {
- return session.createSQLQuery( sql, returnAlias, returnClass );
- }
-
- public Query createSQLQuery(String sql, String[] returnAliases, Class[] returnClasses) {
- return session.createSQLQuery( sql, returnAliases, returnClasses );
- }
-
- public int delete(String query) throws HibernateException {
- return session.delete( query );
- }
-
- public int delete(String query, Object value, Type type) throws HibernateException {
- return session.delete( query, value, type );
- }
-
- public int delete(String query, Object[] values, Type[] types) throws HibernateException {
- return session.delete( query, values, types );
- }
-
- public Collection filter(Object collection, String filter) throws HibernateException {
- return session.filter( collection, filter );
- }
-
- public Collection filter(Object collection, String filter, Object value, Type type) throws HibernateException {
- return session.filter( collection, filter, value, type );
- }
-
- public Collection filter(Object collection, String filter, Object[] values, Type[] types)
- throws HibernateException {
- return session.filter( collection, filter, values, types );
- }
-
- public List find(String query) throws HibernateException {
- return session.find( query );
- }
-
- public List find(String query, Object value, Type type) throws HibernateException {
- return session.find( query, value, type );
- }
-
- public List find(String query, Object[] values, Type[] types) throws HibernateException {
- return session.find( query, values, types );
- }
-
- public Iterator iterate(String query) throws HibernateException {
- return session.iterate( query );
- }
-
- public Iterator iterate(String query, Object value, Type type) throws HibernateException {
- return session.iterate( query, value, type );
- }
-
- public Iterator iterate(String query, Object[] values, Type[] types) throws HibernateException {
- return session.iterate( query, values, types );
- }
-
- public void save(String entityName, Object object, Serializable id) throws HibernateException {
- session.save( entityName, object, id );
- }
-
- public void save(Object object, Serializable id) throws HibernateException {
- session.save( object, id );
- }
-
- public Object saveOrUpdateCopy(String entityName, Object object) throws HibernateException {
- return session.saveOrUpdateCopy( entityName, object );
- }
-
- public Object saveOrUpdateCopy(String entityName, Object object, Serializable id) throws HibernateException {
- return session.saveOrUpdateCopy( entityName, object, id );
- }
-
- public Object saveOrUpdateCopy(Object object) throws HibernateException {
- return session.saveOrUpdateCopy( object );
- }
-
- public Object saveOrUpdateCopy(Object object, Serializable id) throws HibernateException {
- return session.saveOrUpdateCopy( object, id );
- }
-
- public void update(String entityName, Object object, Serializable id) throws HibernateException {
- session.update( entityName, object, id );
- }
-
- public void update(Object object, Serializable id) throws HibernateException {
- session.update( object, id );
- }
-
- public Transaction beginTransaction() throws HibernateException {
- return session.beginTransaction();
- }
-
- public void cancelQuery() throws HibernateException {
- session.cancelQuery();
- }
-
- public void clear() {
- //FIXME should session clear work with the lucene queue
- session.clear();
- }
-
- public Connection close() throws HibernateException {
- return session.close();
- }
-
- public Connection connection() throws HibernateException {
- return session.connection();
- }
-
- public boolean contains(Object object) {
- return session.contains( object );
- }
-
- public Criteria createCriteria(String entityName) {
- return session.createCriteria( entityName );
- }
-
- public Criteria createCriteria(String entityName, String alias) {
- return session.createCriteria( entityName, alias );
- }
-
- public Criteria createCriteria(Class persistentClass) {
- return session.createCriteria( persistentClass );
- }
-
- public Criteria createCriteria(Class persistentClass, String alias) {
- return session.createCriteria( persistentClass, alias );
- }
-
- public Query createFilter(Object collection, String queryString) throws HibernateException {
- return session.createFilter( collection, queryString );
- }
-
- public Query createQuery(String queryString) throws HibernateException {
- return session.createQuery( queryString );
- }
-
- public SQLQuery createSQLQuery(String queryString) throws HibernateException {
- return session.createSQLQuery( queryString );
- }
-
- public void delete(String entityName, Object object) throws HibernateException {
- session.delete( entityName, object );
- }
-
- public void delete(Object object) throws HibernateException {
- session.delete( object );
- }
-
- public void disableFilter(String filterName) {
- session.disableFilter( filterName );
- }
-
- public Connection disconnect() throws HibernateException {
- return session.disconnect();
- }
-
- public Filter enableFilter(String filterName) {
- return session.enableFilter( filterName );
- }
-
- public void evict(Object object) throws HibernateException {
- session.evict( object );
- }
-
- public void flush() throws HibernateException {
- session.flush();
- }
-
- public Object get(Class clazz, Serializable id) throws HibernateException {
- return session.get( clazz, id );
- }
-
- public Object get(Class clazz, Serializable id, LockMode lockMode) throws HibernateException {
- return session.get( clazz, id, lockMode );
- }
-
- public Object get(String entityName, Serializable id) throws HibernateException {
- return session.get( entityName, id );
- }
-
- public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException {
- return session.get( entityName, id, lockMode );
- }
-
- public CacheMode getCacheMode() {
- return session.getCacheMode();
- }
-
- public LockMode getCurrentLockMode(Object object) throws HibernateException {
- return session.getCurrentLockMode( object );
- }
-
- public Filter getEnabledFilter(String filterName) {
- return session.getEnabledFilter( filterName );
- }
-
- public Interceptor getInterceptor() {
- return sessionImplementor.getInterceptor();
- }
-
- public void setAutoClear(boolean enabled) {
- sessionImplementor.setAutoClear( enabled );
- }
-
- public boolean isTransactionInProgress() {
- return sessionImplementor.isTransactionInProgress();
- }
-
- public void initializeCollection(PersistentCollection collection, boolean writing) throws HibernateException {
- sessionImplementor.initializeCollection( collection, writing );
- }
-
- public Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable)
- throws HibernateException {
- return sessionImplementor.internalLoad( entityName, id, eager, nullable );
- }
-
- public Object immediateLoad(String entityName, Serializable id) throws HibernateException {
- return sessionImplementor.immediateLoad( entityName, id );
- }
-
- public long getTimestamp() {
- return sessionImplementor.getTimestamp();
- }
-
- public SessionFactoryImplementor getFactory() {
- return sessionImplementor.getFactory();
- }
-
- public Batcher getBatcher() {
- return sessionImplementor.getBatcher();
- }
-
- public List list(String query, QueryParameters queryParameters) throws HibernateException {
- return sessionImplementor.list( query, queryParameters );
- }
-
- public Iterator iterate(String query, QueryParameters queryParameters) throws HibernateException {
- return sessionImplementor.iterate( query, queryParameters );
- }
-
- public ScrollableResults scroll(String query, QueryParameters queryParameters) throws HibernateException {
- return sessionImplementor.scroll( query, queryParameters );
- }
-
- public ScrollableResults scroll(CriteriaImpl criteria, ScrollMode scrollMode) {
- return sessionImplementor.scroll( criteria, scrollMode );
- }
-
- public List list(CriteriaImpl criteria) {
- return sessionImplementor.list( criteria );
- }
-
- public List listFilter(Object collection, String filter, QueryParameters queryParameters)
- throws HibernateException {
- return sessionImplementor.listFilter( collection, filter, queryParameters );
- }
-
- public Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters)
- throws HibernateException {
- return sessionImplementor.iterateFilter( collection, filter, queryParameters );
- }
-
- public EntityPersister getEntityPersister(String entityName, Object object) throws HibernateException {
- return sessionImplementor.getEntityPersister( entityName, object );
- }
-
- public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException {
- return sessionImplementor.getEntityUsingInterceptor( key );
- }
-
- public void afterTransactionCompletion(boolean successful, Transaction tx) {
- sessionImplementor.afterTransactionCompletion( successful, tx );
- }
-
- public void beforeTransactionCompletion(Transaction tx) {
- sessionImplementor.beforeTransactionCompletion( tx );
- }
-
- public Serializable getContextEntityIdentifier(Object object) {
- return sessionImplementor.getContextEntityIdentifier( object );
- }
-
- public String bestGuessEntityName(Object object) {
- return sessionImplementor.bestGuessEntityName( object );
- }
-
- public String guessEntityName(Object entity) throws HibernateException {
- return sessionImplementor.guessEntityName( entity );
- }
-
- public Object instantiate(String entityName, Serializable id) throws HibernateException {
- return sessionImplementor.instantiate( entityName, id );
- }
-
- public List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException {
- return sessionImplementor.listCustomQuery( customQuery, queryParameters );
- }
-
- public ScrollableResults scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters)
- throws HibernateException {
- return sessionImplementor.scrollCustomQuery( customQuery, queryParameters );
- }
-
- public List list(NativeSQLQuerySpecification spec, QueryParameters queryParameters) throws HibernateException {
- return sessionImplementor.list( spec, queryParameters );
- }
-
- public ScrollableResults scroll(NativeSQLQuerySpecification spec, QueryParameters queryParameters)
- throws HibernateException {
- return sessionImplementor.scroll( spec, queryParameters );
- }
-
- public Object getFilterParameterValue(String filterParameterName) {
- return sessionImplementor.getFilterParameterValue( filterParameterName );
- }
-
- public Type getFilterParameterType(String filterParameterName) {
- return sessionImplementor.getFilterParameterType( filterParameterName );
- }
-
- public Map getEnabledFilters() {
- return sessionImplementor.getEnabledFilters();
- }
-
- public int getDontFlushFromFind() {
- return sessionImplementor.getDontFlushFromFind();
- }
-
- public EventListeners getListeners() {
- return sessionImplementor.getListeners();
- }
-
- public PersistenceContext getPersistenceContext() {
- return sessionImplementor.getPersistenceContext();
- }
-
- public int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException {
- return sessionImplementor.executeUpdate( query, queryParameters );
- }
-
- public int executeNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters)
- throws HibernateException {
- return sessionImplementor.executeNativeUpdate( specification, queryParameters );
- }
-
- public EntityMode getEntityMode() {
- return session.getEntityMode();
- }
-
- public String getEntityName(Object object) throws HibernateException {
- return session.getEntityName( object );
- }
-
- public FlushMode getFlushMode() {
- return session.getFlushMode();
- }
-
- public Serializable getIdentifier(Object object) throws HibernateException {
- return session.getIdentifier( object );
- }
-
- public Query getNamedQuery(String queryName) throws HibernateException {
- return session.getNamedQuery( queryName );
- }
-
- public Query getNamedSQLQuery(String name) {
- return sessionImplementor.getNamedSQLQuery( name );
- }
-
- public boolean isEventSource() {
- return sessionImplementor.isEventSource();
- }
-
- public void afterScrollOperation() {
- sessionImplementor.afterScrollOperation();
- }
-
- public void setFetchProfile(String name) {
- sessionImplementor.setFetchProfile( name );
- }
-
- public String getFetchProfile() {
- return sessionImplementor.getFetchProfile();
- }
-
- public JDBCContext getJDBCContext() {
- return sessionImplementor.getJDBCContext();
- }
-
- public boolean isClosed() {
- return sessionImplementor.isClosed();
- }
-
- public LoadQueryInfluencers getLoadQueryInfluencers() {
- return sessionImplementor.getLoadQueryInfluencers();
- }
-
- public org.hibernate.Session getSession(EntityMode entityMode) {
- return session.getSession( entityMode );
- }
-
- public SessionFactory getSessionFactory() {
- return session.getSessionFactory();
- }
-
- public SessionStatistics getStatistics() {
- return session.getStatistics();
- }
-
- public Transaction getTransaction() {
- return session.getTransaction();
- }
-
- public boolean isConnected() {
- return session.isConnected();
- }
-
- public boolean isDirty() throws HibernateException {
- return session.isDirty();
- }
-
- public boolean isOpen() {
- return session.isOpen();
- }
-
- public Object load(String entityName, Serializable id) throws HibernateException {
- return session.load( entityName, id );
- }
-
- public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException {
- return session.load( entityName, id, lockMode );
- }
-
- public void load(Object object, Serializable id) throws HibernateException {
- session.load( object, id );
- }
-
- public Object load(Class theClass, Serializable id) throws HibernateException {
- return session.load( theClass, id );
- }
-
- public Object load(Class theClass, Serializable id, LockMode lockMode) throws HibernateException {
- return session.load( theClass, id, lockMode );
- }
-
- public void lock(String entityName, Object object, LockMode lockMode) throws HibernateException {
- session.lock( entityName, object, lockMode );
- }
-
- public void lock(Object object, LockMode lockMode) throws HibernateException {
- session.lock( object, lockMode );
- }
-
- public Object merge(String entityName, Object object) throws HibernateException {
- return session.merge( entityName, object );
- }
-
- public Object merge(Object object) throws HibernateException {
- return session.merge( object );
- }
-
- public void persist(String entityName, Object object) throws HibernateException {
- session.persist( entityName, object );
- }
-
- public void persist(Object object) throws HibernateException {
- session.persist( object );
- }
-
- public void reconnect() throws HibernateException {
- session.reconnect();
- }
-
- public void reconnect(Connection connection) throws HibernateException {
- session.reconnect( connection );
- }
-
- public void refresh(Object object) throws HibernateException {
- session.refresh( object );
- }
-
- public void refresh(Object object, LockMode lockMode) throws HibernateException {
- session.refresh( object, lockMode );
- }
-
- public void replicate(String entityName, Object object, ReplicationMode replicationMode) throws HibernateException {
- session.replicate( entityName, object, replicationMode );
- }
-
- public void replicate(Object object, ReplicationMode replicationMode) throws HibernateException {
- session.replicate( object, replicationMode );
- }
-
- public Serializable save(String entityName, Object object) throws HibernateException {
- return session.save( entityName, object );
- }
-
- public Serializable save(Object object) throws HibernateException {
- return session.save( object );
- }
-
- public void saveOrUpdate(String entityName, Object object) throws HibernateException {
- session.saveOrUpdate( entityName, object );
- }
-
- public void saveOrUpdate(Object object) throws HibernateException {
- session.saveOrUpdate( object );
- }
-
- public void setCacheMode(CacheMode cacheMode) {
- session.setCacheMode( cacheMode );
- }
-
- public void setFlushMode(FlushMode flushMode) {
- session.setFlushMode( flushMode );
- }
-
- public void setReadOnly(Object entity, boolean readOnly) {
- session.setReadOnly( entity, readOnly );
- }
-
- public void doWork(org.hibernate.jdbc.Work work) throws HibernateException {
- session.doWork( work );
- }
-
- public void update(String entityName, Object object) throws HibernateException {
- session.update( entityName, object );
- }
-
- public void update(Object object) throws HibernateException {
- session.update( object );
- }
-
- public boolean isFetchProfileEnabled(String name) throws UnknownProfileException {
- return session.isFetchProfileEnabled( name );
- }
-
- public void enableFetchProfile(String name) throws UnknownProfileException {
- session.enableFetchProfile( name );
- }
-
- public void disableFetchProfile(String name) throws UnknownProfileException {
- session.disableFetchProfile( name );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.impl;
+
+import java.io.Serializable;
+import java.sql.Connection;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.hibernate.CacheMode;
+import org.hibernate.Criteria;
+import org.hibernate.EntityMode;
+import org.hibernate.Filter;
+import org.hibernate.FlushMode;
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.Interceptor;
+import org.hibernate.LockMode;
+import org.hibernate.Query;
+import org.hibernate.ReplicationMode;
+import org.hibernate.SQLQuery;
+import org.hibernate.ScrollMode;
+import org.hibernate.ScrollableResults;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.UnknownProfileException;
+import org.hibernate.classic.Session;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.engine.EntityKey;
+import org.hibernate.engine.PersistenceContext;
+import org.hibernate.engine.QueryParameters;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.LoadQueryInfluencers;
+import org.hibernate.engine.query.ParameterMetadata;
+import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
+import org.hibernate.event.EventListeners;
+import org.hibernate.event.EventSource;
+import org.hibernate.impl.CriteriaImpl;
+import org.hibernate.jdbc.Batcher;
+import org.hibernate.jdbc.JDBCContext;
+import org.hibernate.loader.custom.CustomQuery;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.search.FullTextQuery;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.SearchFactory;
+import org.hibernate.search.MassIndexer;
+import org.hibernate.search.backend.TransactionContext;
+import org.hibernate.search.backend.Work;
+import org.hibernate.search.backend.WorkType;
+import org.hibernate.search.backend.impl.EventSourceTransactionContext;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.query.FullTextQueryImpl;
+import org.hibernate.search.util.ContextHelper;
+import org.hibernate.stat.SessionStatistics;
+import org.hibernate.type.Type;
+
+/**
+ * Lucene full text search aware session.
+ *
+ * @author Emmanuel Bernard
+ * @author John Griffin
+ * @author Hardy Ferentschik
+ */
+@SuppressWarnings( "deprecation" )
+public class FullTextSessionImpl implements FullTextSession, SessionImplementor {
+
+ private final Session session;
+ private final SessionImplementor sessionImplementor;
+ private transient SearchFactoryImplementor searchFactory;
+ private final TransactionContext transactionContext;
+
+
+ public FullTextSessionImpl(org.hibernate.Session session) {
+ this.session = ( Session ) session;
+ this.transactionContext = new EventSourceTransactionContext( ( EventSource ) session );
+ this.sessionImplementor = ( SessionImplementor ) session;
+ }
+
+ /**
+ * Execute a Lucene query and retrieve managed objects of type entities (or their indexed subclasses)
+ * If entities is empty, include all indexed entities
+ *
+ * @param entities must be immutable for the lifetime of the query object
+ */
+ public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class... entities) {
+ return new FullTextQueryImpl( luceneQuery, entities, sessionImplementor, new ParameterMetadata( null, null ) );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public <T> void purgeAll(Class<T> entityType) {
+ purge( entityType, null );
+ }
+
+ public void flushToIndexes() {
+ SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
+ searchFactoryImplementor.getWorker().flushWorks( transactionContext );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings( "unchecked" )
+ public <T> void purge(Class<T> entityType, Serializable id) {
+ if ( entityType == null ) {
+ return;
+ }
+
+ SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
+ Set<Class<?>> targetedClasses = searchFactoryImplementor.getIndexedTypesPolymorphic( new Class[] {entityType} );
+ if ( targetedClasses.isEmpty() ) {
+ String msg = entityType.getName() + " is not an indexed entity or a subclass of an indexed entity";
+ throw new IllegalArgumentException( msg );
+ }
+
+ Work<T> work;
+ for ( Class clazz : targetedClasses ) {
+ if ( id == null ) {
+ work = new Work<T>( clazz, null, WorkType.PURGE_ALL );
+ searchFactoryImplementor.getWorker().performWork( work, transactionContext );
+ }
+ else {
+ work = new Work<T>( clazz, id, WorkType.PURGE );
+ searchFactoryImplementor.getWorker().performWork( work, transactionContext );
+ }
+ }
+ }
+
+ /**
+ * (Re-)index an entity.
+ * The entity must be associated with the session and non indexable entities are ignored.
+ *
+ * @param entity The entity to index - must not be <code>null</code>.
+ *
+ * @throws IllegalArgumentException if entity is null or not an @Indexed entity
+ */
+ public <T> void index(T entity) {
+ if ( entity == null ) {
+ throw new IllegalArgumentException( "Entity to index should not be null" );
+ }
+
+ Class<?> clazz = Hibernate.getClass( entity );
+ //TODO cache that at the FTSession level
+ SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
+ //not strictly necessary but a small optimization
+ if ( searchFactoryImplementor.getDocumentBuilderIndexedEntity( clazz ) == null ) {
+ String msg = "Entity to index is not an @Indexed entity: " + entity.getClass().getName();
+ throw new IllegalArgumentException( msg );
+ }
+ Serializable id = session.getIdentifier( entity );
+ Work<T> work = new Work<T>( entity, id, WorkType.INDEX );
+ searchFactoryImplementor.getWorker().performWork( work, transactionContext );
+
+ //TODO
+ //need to add elements in a queue kept at the Session level
+ //the queue will be processed by a Lucene(Auto)FlushEventListener
+ //note that we could keep this queue somewhere in the event listener in the mean time but that requires
+ //a synchronized hashmap holding this queue on a per session basis plus some session house keeping (yuk)
+ //another solution would be to subclass SessionImpl instead of having this LuceneSession delegation model
+ //this is an open discussion
+ }
+
+ public MassIndexer createIndexer(Class<?>... types) {
+ if ( types.length == 0 ) {
+ return new MassIndexerImpl( getSearchFactoryImplementor(), getSessionFactory(), Object.class );
+ }
+ else {
+ return new MassIndexerImpl( getSearchFactoryImplementor(), getSessionFactory(), types );
+ }
+ }
+
+ public SearchFactory getSearchFactory() {
+ if ( searchFactory == null ) {
+ searchFactory = ContextHelper.getSearchFactory( session );
+ }
+ return searchFactory;
+ }
+
+ private SearchFactoryImplementor getSearchFactoryImplementor() {
+ if ( searchFactory == null ) {
+ searchFactory = ContextHelper.getSearchFactory( session );
+ }
+ return searchFactory;
+ }
+
+ public Query createSQLQuery(String sql, String returnAlias, Class returnClass) {
+ return session.createSQLQuery( sql, returnAlias, returnClass );
+ }
+
+ public Query createSQLQuery(String sql, String[] returnAliases, Class[] returnClasses) {
+ return session.createSQLQuery( sql, returnAliases, returnClasses );
+ }
+
+ public int delete(String query) throws HibernateException {
+ return session.delete( query );
+ }
+
+ public int delete(String query, Object value, Type type) throws HibernateException {
+ return session.delete( query, value, type );
+ }
+
+ public int delete(String query, Object[] values, Type[] types) throws HibernateException {
+ return session.delete( query, values, types );
+ }
+
+ public Collection filter(Object collection, String filter) throws HibernateException {
+ return session.filter( collection, filter );
+ }
+
+ public Collection filter(Object collection, String filter, Object value, Type type) throws HibernateException {
+ return session.filter( collection, filter, value, type );
+ }
+
+ public Collection filter(Object collection, String filter, Object[] values, Type[] types)
+ throws HibernateException {
+ return session.filter( collection, filter, values, types );
+ }
+
+ public List find(String query) throws HibernateException {
+ return session.find( query );
+ }
+
+ public List find(String query, Object value, Type type) throws HibernateException {
+ return session.find( query, value, type );
+ }
+
+ public List find(String query, Object[] values, Type[] types) throws HibernateException {
+ return session.find( query, values, types );
+ }
+
+ public Iterator iterate(String query) throws HibernateException {
+ return session.iterate( query );
+ }
+
+ public Iterator iterate(String query, Object value, Type type) throws HibernateException {
+ return session.iterate( query, value, type );
+ }
+
+ public Iterator iterate(String query, Object[] values, Type[] types) throws HibernateException {
+ return session.iterate( query, values, types );
+ }
+
+ public void save(String entityName, Object object, Serializable id) throws HibernateException {
+ session.save( entityName, object, id );
+ }
+
+ public void save(Object object, Serializable id) throws HibernateException {
+ session.save( object, id );
+ }
+
+ public Object saveOrUpdateCopy(String entityName, Object object) throws HibernateException {
+ return session.saveOrUpdateCopy( entityName, object );
+ }
+
+ public Object saveOrUpdateCopy(String entityName, Object object, Serializable id) throws HibernateException {
+ return session.saveOrUpdateCopy( entityName, object, id );
+ }
+
+ public Object saveOrUpdateCopy(Object object) throws HibernateException {
+ return session.saveOrUpdateCopy( object );
+ }
+
+ public Object saveOrUpdateCopy(Object object, Serializable id) throws HibernateException {
+ return session.saveOrUpdateCopy( object, id );
+ }
+
+ public void update(String entityName, Object object, Serializable id) throws HibernateException {
+ session.update( entityName, object, id );
+ }
+
+ public void update(Object object, Serializable id) throws HibernateException {
+ session.update( object, id );
+ }
+
+ public Transaction beginTransaction() throws HibernateException {
+ return session.beginTransaction();
+ }
+
+ public void cancelQuery() throws HibernateException {
+ session.cancelQuery();
+ }
+
+ public void clear() {
+ //FIXME should session clear work with the lucene queue
+ session.clear();
+ }
+
+ public Connection close() throws HibernateException {
+ return session.close();
+ }
+
+ public Connection connection() throws HibernateException {
+ return session.connection();
+ }
+
+ public boolean contains(Object object) {
+ return session.contains( object );
+ }
+
+ public Criteria createCriteria(String entityName) {
+ return session.createCriteria( entityName );
+ }
+
+ public Criteria createCriteria(String entityName, String alias) {
+ return session.createCriteria( entityName, alias );
+ }
+
+ public Criteria createCriteria(Class persistentClass) {
+ return session.createCriteria( persistentClass );
+ }
+
+ public Criteria createCriteria(Class persistentClass, String alias) {
+ return session.createCriteria( persistentClass, alias );
+ }
+
+ public Query createFilter(Object collection, String queryString) throws HibernateException {
+ return session.createFilter( collection, queryString );
+ }
+
+ public Query createQuery(String queryString) throws HibernateException {
+ return session.createQuery( queryString );
+ }
+
+ public SQLQuery createSQLQuery(String queryString) throws HibernateException {
+ return session.createSQLQuery( queryString );
+ }
+
+ public void delete(String entityName, Object object) throws HibernateException {
+ session.delete( entityName, object );
+ }
+
+ public void delete(Object object) throws HibernateException {
+ session.delete( object );
+ }
+
+ public void disableFilter(String filterName) {
+ session.disableFilter( filterName );
+ }
+
+ public Connection disconnect() throws HibernateException {
+ return session.disconnect();
+ }
+
+ public Filter enableFilter(String filterName) {
+ return session.enableFilter( filterName );
+ }
+
+ public void evict(Object object) throws HibernateException {
+ session.evict( object );
+ }
+
+ public void flush() throws HibernateException {
+ session.flush();
+ }
+
+ public Object get(Class clazz, Serializable id) throws HibernateException {
+ return session.get( clazz, id );
+ }
+
+ public Object get(Class clazz, Serializable id, LockMode lockMode) throws HibernateException {
+ return session.get( clazz, id, lockMode );
+ }
+
+ public Object get(String entityName, Serializable id) throws HibernateException {
+ return session.get( entityName, id );
+ }
+
+ public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException {
+ return session.get( entityName, id, lockMode );
+ }
+
+ public CacheMode getCacheMode() {
+ return session.getCacheMode();
+ }
+
+ public LockMode getCurrentLockMode(Object object) throws HibernateException {
+ return session.getCurrentLockMode( object );
+ }
+
+ public Filter getEnabledFilter(String filterName) {
+ return session.getEnabledFilter( filterName );
+ }
+
+ public Interceptor getInterceptor() {
+ return sessionImplementor.getInterceptor();
+ }
+
+ public void setAutoClear(boolean enabled) {
+ sessionImplementor.setAutoClear( enabled );
+ }
+
+ public boolean isTransactionInProgress() {
+ return sessionImplementor.isTransactionInProgress();
+ }
+
+ public void initializeCollection(PersistentCollection collection, boolean writing) throws HibernateException {
+ sessionImplementor.initializeCollection( collection, writing );
+ }
+
+ public Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable)
+ throws HibernateException {
+ return sessionImplementor.internalLoad( entityName, id, eager, nullable );
+ }
+
+ public Object immediateLoad(String entityName, Serializable id) throws HibernateException {
+ return sessionImplementor.immediateLoad( entityName, id );
+ }
+
+ public long getTimestamp() {
+ return sessionImplementor.getTimestamp();
+ }
+
+ public SessionFactoryImplementor getFactory() {
+ return sessionImplementor.getFactory();
+ }
+
+ public Batcher getBatcher() {
+ return sessionImplementor.getBatcher();
+ }
+
+ public List list(String query, QueryParameters queryParameters) throws HibernateException {
+ return sessionImplementor.list( query, queryParameters );
+ }
+
+ public Iterator iterate(String query, QueryParameters queryParameters) throws HibernateException {
+ return sessionImplementor.iterate( query, queryParameters );
+ }
+
+ public ScrollableResults scroll(String query, QueryParameters queryParameters) throws HibernateException {
+ return sessionImplementor.scroll( query, queryParameters );
+ }
+
+ public ScrollableResults scroll(CriteriaImpl criteria, ScrollMode scrollMode) {
+ return sessionImplementor.scroll( criteria, scrollMode );
+ }
+
+ public List list(CriteriaImpl criteria) {
+ return sessionImplementor.list( criteria );
+ }
+
+ public List listFilter(Object collection, String filter, QueryParameters queryParameters)
+ throws HibernateException {
+ return sessionImplementor.listFilter( collection, filter, queryParameters );
+ }
+
+ public Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters)
+ throws HibernateException {
+ return sessionImplementor.iterateFilter( collection, filter, queryParameters );
+ }
+
+ public EntityPersister getEntityPersister(String entityName, Object object) throws HibernateException {
+ return sessionImplementor.getEntityPersister( entityName, object );
+ }
+
+ public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException {
+ return sessionImplementor.getEntityUsingInterceptor( key );
+ }
+
+ public void afterTransactionCompletion(boolean successful, Transaction tx) {
+ sessionImplementor.afterTransactionCompletion( successful, tx );
+ }
+
+ public void beforeTransactionCompletion(Transaction tx) {
+ sessionImplementor.beforeTransactionCompletion( tx );
+ }
+
+ public Serializable getContextEntityIdentifier(Object object) {
+ return sessionImplementor.getContextEntityIdentifier( object );
+ }
+
+ public String bestGuessEntityName(Object object) {
+ return sessionImplementor.bestGuessEntityName( object );
+ }
+
+ public String guessEntityName(Object entity) throws HibernateException {
+ return sessionImplementor.guessEntityName( entity );
+ }
+
+ public Object instantiate(String entityName, Serializable id) throws HibernateException {
+ return sessionImplementor.instantiate( entityName, id );
+ }
+
+ public List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException {
+ return sessionImplementor.listCustomQuery( customQuery, queryParameters );
+ }
+
+ public ScrollableResults scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters)
+ throws HibernateException {
+ return sessionImplementor.scrollCustomQuery( customQuery, queryParameters );
+ }
+
+ public List list(NativeSQLQuerySpecification spec, QueryParameters queryParameters) throws HibernateException {
+ return sessionImplementor.list( spec, queryParameters );
+ }
+
+ public ScrollableResults scroll(NativeSQLQuerySpecification spec, QueryParameters queryParameters)
+ throws HibernateException {
+ return sessionImplementor.scroll( spec, queryParameters );
+ }
+
+ public Object getFilterParameterValue(String filterParameterName) {
+ return sessionImplementor.getFilterParameterValue( filterParameterName );
+ }
+
+ public Type getFilterParameterType(String filterParameterName) {
+ return sessionImplementor.getFilterParameterType( filterParameterName );
+ }
+
+ public Map getEnabledFilters() {
+ return sessionImplementor.getEnabledFilters();
+ }
+
+ public int getDontFlushFromFind() {
+ return sessionImplementor.getDontFlushFromFind();
+ }
+
+ public EventListeners getListeners() {
+ return sessionImplementor.getListeners();
+ }
+
+ public PersistenceContext getPersistenceContext() {
+ return sessionImplementor.getPersistenceContext();
+ }
+
+ public int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException {
+ return sessionImplementor.executeUpdate( query, queryParameters );
+ }
+
+ public int executeNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters)
+ throws HibernateException {
+ return sessionImplementor.executeNativeUpdate( specification, queryParameters );
+ }
+
+ public EntityMode getEntityMode() {
+ return session.getEntityMode();
+ }
+
+ public String getEntityName(Object object) throws HibernateException {
+ return session.getEntityName( object );
+ }
+
+ public FlushMode getFlushMode() {
+ return session.getFlushMode();
+ }
+
+ public Serializable getIdentifier(Object object) throws HibernateException {
+ return session.getIdentifier( object );
+ }
+
+ public Query getNamedQuery(String queryName) throws HibernateException {
+ return session.getNamedQuery( queryName );
+ }
+
+ public Query getNamedSQLQuery(String name) {
+ return sessionImplementor.getNamedSQLQuery( name );
+ }
+
+ public boolean isEventSource() {
+ return sessionImplementor.isEventSource();
+ }
+
+ public void afterScrollOperation() {
+ sessionImplementor.afterScrollOperation();
+ }
+
+ public void setFetchProfile(String name) {
+ sessionImplementor.setFetchProfile( name );
+ }
+
+ public String getFetchProfile() {
+ return sessionImplementor.getFetchProfile();
+ }
+
+ public JDBCContext getJDBCContext() {
+ return sessionImplementor.getJDBCContext();
+ }
+
+ public boolean isClosed() {
+ return sessionImplementor.isClosed();
+ }
+
+ public LoadQueryInfluencers getLoadQueryInfluencers() {
+ return sessionImplementor.getLoadQueryInfluencers();
+ }
+
+ public org.hibernate.Session getSession(EntityMode entityMode) {
+ return session.getSession( entityMode );
+ }
+
+ public SessionFactory getSessionFactory() {
+ return session.getSessionFactory();
+ }
+
+ public SessionStatistics getStatistics() {
+ return session.getStatistics();
+ }
+
+ public Transaction getTransaction() {
+ return session.getTransaction();
+ }
+
+ public boolean isConnected() {
+ return session.isConnected();
+ }
+
+ public boolean isDirty() throws HibernateException {
+ return session.isDirty();
+ }
+
+ public boolean isOpen() {
+ return session.isOpen();
+ }
+
+ public Object load(String entityName, Serializable id) throws HibernateException {
+ return session.load( entityName, id );
+ }
+
+ public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException {
+ return session.load( entityName, id, lockMode );
+ }
+
+ public void load(Object object, Serializable id) throws HibernateException {
+ session.load( object, id );
+ }
+
+ public Object load(Class theClass, Serializable id) throws HibernateException {
+ return session.load( theClass, id );
+ }
+
+ public Object load(Class theClass, Serializable id, LockMode lockMode) throws HibernateException {
+ return session.load( theClass, id, lockMode );
+ }
+
+ public void lock(String entityName, Object object, LockMode lockMode) throws HibernateException {
+ session.lock( entityName, object, lockMode );
+ }
+
+ public void lock(Object object, LockMode lockMode) throws HibernateException {
+ session.lock( object, lockMode );
+ }
+
+ public Object merge(String entityName, Object object) throws HibernateException {
+ return session.merge( entityName, object );
+ }
+
+ public Object merge(Object object) throws HibernateException {
+ return session.merge( object );
+ }
+
+ public void persist(String entityName, Object object) throws HibernateException {
+ session.persist( entityName, object );
+ }
+
+ public void persist(Object object) throws HibernateException {
+ session.persist( object );
+ }
+
+ public void reconnect() throws HibernateException {
+ session.reconnect();
+ }
+
+ public void reconnect(Connection connection) throws HibernateException {
+ session.reconnect( connection );
+ }
+
+ public void refresh(Object object) throws HibernateException {
+ session.refresh( object );
+ }
+
+ public void refresh(Object object, LockMode lockMode) throws HibernateException {
+ session.refresh( object, lockMode );
+ }
+
+ public void replicate(String entityName, Object object, ReplicationMode replicationMode) throws HibernateException {
+ session.replicate( entityName, object, replicationMode );
+ }
+
+ public void replicate(Object object, ReplicationMode replicationMode) throws HibernateException {
+ session.replicate( object, replicationMode );
+ }
+
+ public Serializable save(String entityName, Object object) throws HibernateException {
+ return session.save( entityName, object );
+ }
+
+ public Serializable save(Object object) throws HibernateException {
+ return session.save( object );
+ }
+
+ public void saveOrUpdate(String entityName, Object object) throws HibernateException {
+ session.saveOrUpdate( entityName, object );
+ }
+
+ public void saveOrUpdate(Object object) throws HibernateException {
+ session.saveOrUpdate( object );
+ }
+
+ public void setCacheMode(CacheMode cacheMode) {
+ session.setCacheMode( cacheMode );
+ }
+
+ public void setFlushMode(FlushMode flushMode) {
+ session.setFlushMode( flushMode );
+ }
+
+ public void setReadOnly(Object entity, boolean readOnly) {
+ session.setReadOnly( entity, readOnly );
+ }
+
+ public void doWork(org.hibernate.jdbc.Work work) throws HibernateException {
+ session.doWork( work );
+ }
+
+ public void update(String entityName, Object object) throws HibernateException {
+ session.update( entityName, object );
+ }
+
+ public void update(Object object) throws HibernateException {
+ session.update( object );
+ }
+
+ public boolean isFetchProfileEnabled(String name) throws UnknownProfileException {
+ return session.isFetchProfileEnabled( name );
+ }
+
+ public void enableFetchProfile(String name) throws UnknownProfileException {
+ session.enableFetchProfile( name );
+ }
+
+ public void disableFetchProfile(String name) throws UnknownProfileException {
+ session.disableFetchProfile( name );
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/impl/InitContext.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/InitContext.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/impl/InitContext.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.impl;
import java.util.ArrayList;
Modified: search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.impl;
import java.util.Map;
Modified: search/trunk/src/main/java/org/hibernate/search/impl/MassIndexerImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/MassIndexerImpl.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/impl/MassIndexerImpl.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.impl;
import java.util.HashSet;
Modified: search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,603 +1,626 @@
-//$Id$
-package org.hibernate.search.impl;
-
-import java.beans.Introspector;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Arrays;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.slf4j.Logger;
-
-import org.hibernate.annotations.common.reflection.ReflectionManager;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.MetadataProvider;
-import org.hibernate.annotations.common.reflection.MetadataProviderInjector;
-import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;
-import org.hibernate.util.StringHelper;
-import org.hibernate.search.Environment;
-import org.hibernate.search.SearchException;
-import org.hibernate.search.Version;
-import org.hibernate.search.annotations.Factory;
-import org.hibernate.search.annotations.FullTextFilterDef;
-import org.hibernate.search.annotations.FullTextFilterDefs;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.Key;
-import org.hibernate.search.annotations.AnalyzerDef;
-import org.hibernate.search.annotations.AnalyzerDefs;
-import org.hibernate.search.backend.BackendQueueProcessorFactory;
-import org.hibernate.search.backend.LuceneIndexingParameters;
-import org.hibernate.search.backend.LuceneWork;
-import org.hibernate.search.backend.OptimizeLuceneWork;
-import org.hibernate.search.backend.Worker;
-import org.hibernate.search.backend.WorkerFactory;
-import org.hibernate.search.backend.configuration.ConfigurationParseHelper;
-import org.hibernate.search.backend.configuration.MaskedProperty;
-import org.hibernate.search.backend.impl.batchlucene.BatchBackend;
-import org.hibernate.search.backend.impl.batchlucene.LuceneBatchBackend;
-import org.hibernate.search.batchindexing.MassIndexerProgressMonitor;
-import org.hibernate.search.cfg.SearchConfiguration;
-import org.hibernate.search.cfg.SearchMapping;
-import org.hibernate.search.engine.DocumentBuilderIndexedEntity;
-import org.hibernate.search.engine.FilterDef;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.engine.EntityState;
-import org.hibernate.search.engine.DocumentBuilderContainedEntity;
-import org.hibernate.search.filter.CachingWrapperFilter;
-import org.hibernate.search.filter.FilterCachingStrategy;
-import org.hibernate.search.filter.MRUFilterCachingStrategy;
-import org.hibernate.search.filter.ShardSensitiveOnlyFilter;
-import org.hibernate.search.reader.ReaderProvider;
-import org.hibernate.search.reader.ReaderProviderFactory;
-import org.hibernate.search.store.DirectoryProvider;
-import org.hibernate.search.store.DirectoryProviderFactory;
-import org.hibernate.search.store.optimization.OptimizerStrategy;
-import org.hibernate.search.util.LoggerFactory;
-import org.hibernate.search.util.PluginLoader;
-
-/**
- * @author Emmanuel Bernard
- */
-public class SearchFactoryImpl implements SearchFactoryImplementor {
-
- static {
- Version.touch();
- }
-
- private static final Logger log = LoggerFactory.make();
-
- private final Map<Class<?>, DocumentBuilderIndexedEntity<?>> documentBuildersIndexedEntities = new HashMap<Class<?>, DocumentBuilderIndexedEntity<?>>();
- private final Map<Class<?>, DocumentBuilderContainedEntity<?>> documentBuildersContainedEntities = new HashMap<Class<?>, DocumentBuilderContainedEntity<?>>();
- //keep track of the index modifiers per DirectoryProvider since multiple entity can use the same directory provider
- private final Map<DirectoryProvider<?>, DirectoryProviderData> dirProviderData = new HashMap<DirectoryProvider<?>, DirectoryProviderData>();
- private final Worker worker;
- private final ReaderProvider readerProvider;
- private BackendQueueProcessorFactory backendQueueProcessorFactory;
- private final Map<String, FilterDef> filterDefinitions = new HashMap<String, FilterDef>();
- private final FilterCachingStrategy filterCachingStrategy;
- private Map<String, Analyzer> analyzers;
- private final AtomicBoolean stopped = new AtomicBoolean( false );
- private final int cacheBitResultsSize;
- private final Properties configurationProperties;
-
- private final PolymorphicIndexHierarchy indexHierarchy = new PolymorphicIndexHierarchy();
-
- /*
- * Used as a barrier (piggyback usage) between initialization and subsequent usage of searchFactory in different threads
- * this is due to our use of the initialize pattern is a few areas
- * subsequent reads on volatiles should be very cheap on most platform especially since we don't write after init
- *
- * This volatile is meant to be written after initialization
- * and read by all subsequent methods accessing the SearchFactory state
- * read to be as barrier != 0. If barrier == 0 we have a race condition, but is not likely to happen.
- */
- private volatile short barrier;
-
- /**
- * Each directory provider (index) can have its own performance settings.
- */
- private Map<DirectoryProvider, LuceneIndexingParameters> dirProviderIndexingParams =
- new HashMap<DirectoryProvider, LuceneIndexingParameters>();
- private final String indexingStrategy;
-
-
- public BackendQueueProcessorFactory getBackendQueueProcessorFactory() {
- if ( barrier != 0 ) {
- } //read barrier
- return backendQueueProcessorFactory;
- }
-
- public void setBackendQueueProcessorFactory(BackendQueueProcessorFactory backendQueueProcessorFactory) {
- //no need to set a barrier, we init in the same thread as the init one
- this.backendQueueProcessorFactory = backendQueueProcessorFactory;
- }
-
- public SearchFactoryImpl(SearchConfiguration cfg) {
- ReflectionManager reflectionManager = getReflectionManager(cfg);
-
- this.indexingStrategy = defineIndexingStrategy( cfg ); //need to be done before the document builds
- initDocumentBuilders( cfg, reflectionManager );
-
- Set<Class<?>> indexedClasses = documentBuildersIndexedEntities.keySet();
- for ( DocumentBuilderIndexedEntity builder : documentBuildersIndexedEntities.values() ) {
- builder.postInitialize( indexedClasses );
- }
- //not really necessary today
- for ( DocumentBuilderContainedEntity builder : documentBuildersContainedEntities.values() ) {
- builder.postInitialize( indexedClasses );
- }
- this.worker = WorkerFactory.createWorker( cfg, this );
- this.readerProvider = ReaderProviderFactory.createReaderProvider( cfg, this );
- this.filterCachingStrategy = buildFilterCachingStrategy( cfg.getProperties() );
- this.cacheBitResultsSize = ConfigurationParseHelper.getIntValue(
- cfg.getProperties(), Environment.CACHE_DOCIDRESULTS_SIZE, CachingWrapperFilter.DEFAULT_SIZE
- );
- this.configurationProperties = cfg.getProperties();
- this.barrier = 1; //write barrier
- }
-
- private ReflectionManager getReflectionManager(SearchConfiguration cfg) {
- ReflectionManager reflectionManager = cfg.getReflectionManager();
- if ( reflectionManager == null ) {
- reflectionManager = new JavaReflectionManager();
- }
- final SearchMapping mapping = cfg.getProgrammaticMapping();
- if ( mapping != null) {
- if ( ! ( reflectionManager instanceof MetadataProviderInjector)) {
- throw new SearchException("Programmatic mapping model used but ReflectionManager does not implement "
- + MetadataProviderInjector.class.getName() );
- }
- MetadataProviderInjector injector = (MetadataProviderInjector) reflectionManager;
- MetadataProvider original = injector.getMetadataProvider();
- injector.setMetadataProvider( new MappingModelMetadataProvider( original, mapping ) );
-
- }
- return reflectionManager;
- }
-
- private static String defineIndexingStrategy(SearchConfiguration cfg) {
- String indexingStrategy = cfg.getProperties().getProperty( Environment.INDEXING_STRATEGY, "event" );
- if ( !( "event".equals( indexingStrategy ) || "manual".equals( indexingStrategy ) ) ) {
- throw new SearchException( Environment.INDEXING_STRATEGY + " unknown: " + indexingStrategy );
- }
- return indexingStrategy;
- }
-
- public String getIndexingStrategy() {
- if ( barrier != 0 ) {
- } //read barrier
- return indexingStrategy;
- }
-
- public void close() {
- if ( barrier != 0 ) {
- } //read barrier
- if ( stopped.compareAndSet( false, true ) ) {
- try {
- worker.close();
- }
- catch ( Exception e ) {
- log.error( "Worker raises an exception on close()", e );
- }
-
- try {
- readerProvider.destroy();
- }
- catch ( Exception e ) {
- log.error( "ReaderProvider raises an exception on destroy()", e );
- }
-
- //TODO move to DirectoryProviderFactory for cleaner
- for ( DirectoryProvider dp : getDirectoryProviders() ) {
- try {
- dp.stop();
- }
- catch ( Exception e ) {
- log.error( "DirectoryProvider raises an exception on stop() ", e );
- }
- }
- }
- }
-
- public void addClassToDirectoryProvider(Class<?> clazz, DirectoryProvider<?> directoryProvider) {
- //no need to set a read barrier, we only use this class in the init thread
- DirectoryProviderData data = dirProviderData.get( directoryProvider );
- if ( data == null ) {
- data = new DirectoryProviderData();
- dirProviderData.put( directoryProvider, data );
- }
- data.classes.add( clazz );
- }
-
- public Set<Class<?>> getClassesInDirectoryProvider(DirectoryProvider<?> directoryProvider) {
- if ( barrier != 0 ) {
- } //read barrier
- return Collections.unmodifiableSet( dirProviderData.get( directoryProvider ).classes );
- }
-
- private void bindFilterDefs(XClass mappedXClass) {
- FullTextFilterDef defAnn = mappedXClass.getAnnotation( FullTextFilterDef.class );
- if ( defAnn != null ) {
- bindFilterDef( defAnn, mappedXClass );
- }
- FullTextFilterDefs defsAnn = mappedXClass.getAnnotation( FullTextFilterDefs.class );
- if ( defsAnn != null ) {
- for ( FullTextFilterDef def : defsAnn.value() ) {
- bindFilterDef( def, mappedXClass );
- }
- }
- }
-
- private void bindFilterDef(FullTextFilterDef defAnn, XClass mappedXClass) {
- if ( filterDefinitions.containsKey( defAnn.name() ) ) {
- throw new SearchException(
- "Multiple definition of @FullTextFilterDef.name=" + defAnn.name() + ": "
- + mappedXClass.getName()
- );
- }
-
- FilterDef filterDef = new FilterDef( defAnn );
- if ( filterDef.getImpl().equals( ShardSensitiveOnlyFilter.class ) ) {
- //this is a placeholder don't process regularly
- filterDefinitions.put( defAnn.name(), filterDef );
- return;
- }
- try {
- filterDef.getImpl().newInstance();
- }
- catch ( IllegalAccessException e ) {
- throw new SearchException( "Unable to create Filter class: " + filterDef.getImpl().getName(), e );
- }
- catch ( InstantiationException e ) {
- throw new SearchException( "Unable to create Filter class: " + filterDef.getImpl().getName(), e );
- }
- for ( Method method : filterDef.getImpl().getMethods() ) {
- if ( method.isAnnotationPresent( Factory.class ) ) {
- if ( filterDef.getFactoryMethod() != null ) {
- throw new SearchException(
- "Multiple @Factory methods found" + defAnn.name() + ": "
- + filterDef.getImpl().getName() + "." + method.getName()
- );
- }
- if ( !method.isAccessible() ) {
- method.setAccessible( true );
- }
- filterDef.setFactoryMethod( method );
- }
- if ( method.isAnnotationPresent( Key.class ) ) {
- if ( filterDef.getKeyMethod() != null ) {
- throw new SearchException(
- "Multiple @Key methods found" + defAnn.name() + ": "
- + filterDef.getImpl().getName() + "." + method.getName()
- );
- }
- if ( !method.isAccessible() ) {
- method.setAccessible( true );
- }
- filterDef.setKeyMethod( method );
- }
-
- String name = method.getName();
- if ( name.startsWith( "set" ) && method.getParameterTypes().length == 1 ) {
- filterDef.addSetter( Introspector.decapitalize( name.substring( 3 ) ), method );
- }
- }
- filterDefinitions.put( defAnn.name(), filterDef );
- }
-
-
- public Map<Class<?>, DocumentBuilderIndexedEntity<?>> getDocumentBuildersIndexedEntities() {
- if ( barrier != 0 ) {
- } //read barrier
- return documentBuildersIndexedEntities;
- }
-
- @SuppressWarnings("unchecked")
- public <T> DocumentBuilderIndexedEntity<T> getDocumentBuilderIndexedEntity(Class<T> entityType) {
- if ( barrier != 0 ) {
- } //read barrier
- return ( DocumentBuilderIndexedEntity<T> ) documentBuildersIndexedEntities.get( entityType );
- }
-
- @SuppressWarnings("unchecked")
- public <T> DocumentBuilderContainedEntity<T> getDocumentBuilderContainedEntity(Class<T> entityType) {
- if ( barrier != 0 ) {
- } //read barrier
- return ( DocumentBuilderContainedEntity<T> ) documentBuildersContainedEntities.get( entityType );
- }
-
- public Set<DirectoryProvider<?>> getDirectoryProviders() {
- if ( barrier != 0 ) {
- } //read barrier
- return this.dirProviderData.keySet();
- }
-
- public Worker getWorker() {
- if ( barrier != 0 ) {
- } //read barrier
- return worker;
- }
-
- public void addOptimizerStrategy(DirectoryProvider<?> provider, OptimizerStrategy optimizerStrategy) {
- //no need to set a read barrier, we run this method on the init thread
- DirectoryProviderData data = dirProviderData.get( provider );
- if ( data == null ) {
- data = new DirectoryProviderData();
- dirProviderData.put( provider, data );
- }
- data.optimizerStrategy = optimizerStrategy;
- }
-
- public void addIndexingParameters(DirectoryProvider<?> provider, LuceneIndexingParameters indexingParams) {
- //no need to set a read barrier, we run this method on the init thread
- dirProviderIndexingParams.put( provider, indexingParams );
- }
-
- public OptimizerStrategy getOptimizerStrategy(DirectoryProvider<?> provider) {
- if ( barrier != 0 ) {
- } //read barrier
- return dirProviderData.get( provider ).optimizerStrategy;
- }
-
- public LuceneIndexingParameters getIndexingParameters(DirectoryProvider<?> provider) {
- if ( barrier != 0 ) {
- } //read barrier
- return dirProviderIndexingParams.get( provider );
- }
-
- public ReaderProvider getReaderProvider() {
- if ( barrier != 0 ) {
- } //read barrier
- return readerProvider;
- }
-
- public DirectoryProvider[] getDirectoryProviders(Class<?> entity) {
- if ( barrier != 0 ) {
- } //read barrier
- DocumentBuilderIndexedEntity<?> documentBuilder = getDocumentBuilderIndexedEntity( entity );
- return documentBuilder == null ? null : documentBuilder.getDirectoryProviders();
- }
-
- public void optimize() {
- if ( barrier != 0 ) {
- } //read barrier
- Set<Class<?>> clazzs = getDocumentBuildersIndexedEntities().keySet();
- for ( Class clazz : clazzs ) {
- optimize( clazz );
- }
- }
-
- public void optimize(Class entityType) {
- if ( barrier != 0 ) {
- } //read barrier
- if ( !getDocumentBuildersIndexedEntities().containsKey( entityType ) ) {
- throw new SearchException( "Entity not indexed: " + entityType );
- }
- List<LuceneWork> queue = new ArrayList<LuceneWork>( 1 );
- queue.add( new OptimizeLuceneWork( entityType ) );
- getBackendQueueProcessorFactory().getProcessor( queue ).run();
- }
-
- public Analyzer getAnalyzer(String name) {
- if ( barrier != 0 ) {
- } //read barrier
- final Analyzer analyzer = analyzers.get( name );
- if ( analyzer == null ) {
- throw new SearchException( "Unknown Analyzer definition: " + name );
- }
- return analyzer;
- }
-
- public Analyzer getAnalyzer(Class clazz) {
- if ( clazz == null ) {
- throw new IllegalArgumentException( "A class has to be specified for retrieving a scoped analyzer" );
- }
-
- DocumentBuilderIndexedEntity<?> builder = documentBuildersIndexedEntities.get( clazz );
- if ( builder == null ) {
- throw new IllegalArgumentException(
- "Entity for which to retrieve the scoped analyzer is not an @Indexed entity: " + clazz.getName()
- );
- }
-
- return builder.getAnalyzer();
- }
-
- private void initDocumentBuilders(SearchConfiguration cfg, ReflectionManager reflectionManager) {
- InitContext context = new InitContext( cfg );
- Iterator<Class<?>> iter = cfg.getClassMappings();
- DirectoryProviderFactory factory = new DirectoryProviderFactory();
-
- initProgrammaticAnalyzers(context, reflectionManager);
-
- while ( iter.hasNext() ) {
- Class mappedClass = iter.next();
- if ( mappedClass == null ) {
- continue;
- }
- @SuppressWarnings( "unchecked" )
- XClass mappedXClass = reflectionManager.toXClass( mappedClass );
- if ( mappedXClass == null ) {
- continue;
- }
-
- if ( mappedXClass.isAnnotationPresent( Indexed.class ) ) {
-
- if ( mappedXClass.isAbstract() ) {
- log.warn( "Abstract classes can never insert index documents. Remove @Indexed." );
- continue;
- }
-
- DirectoryProviderFactory.DirectoryProviders providers = factory.createDirectoryProviders(
- mappedXClass, cfg, this, reflectionManager
- );
- //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
- //XClass unfortunately is not (yet) genericized: TODO?
- final DocumentBuilderIndexedEntity<?> documentBuilder = new DocumentBuilderIndexedEntity(
- mappedXClass, context, providers.getProviders(), providers.getSelectionStrategy(),
- reflectionManager
- );
-
- indexHierarchy.addIndexedClass( mappedClass );
- documentBuildersIndexedEntities.put( mappedClass, documentBuilder );
- }
- else {
- //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
- //XClass unfortunately is not (yet) genericized: TODO?
- final DocumentBuilderContainedEntity<?> documentBuilder = new DocumentBuilderContainedEntity(
- mappedXClass, context, reflectionManager
- );
- //TODO enhance that, I don't like to expose EntityState
- if ( documentBuilder.getEntityState() != EntityState.NON_INDEXABLE ) {
- documentBuildersContainedEntities.put( mappedClass, documentBuilder );
- }
- }
- bindFilterDefs( mappedXClass );
- //TODO should analyzer def for classes at tyher sqme level???
- }
- analyzers = context.initLazyAnalyzers();
- factory.startDirectoryProviders();
- }
-
- private void initProgrammaticAnalyzers(InitContext context, ReflectionManager reflectionManager) {
- final Map defaults = reflectionManager.getDefaults();
-
- if (defaults != null) {
- AnalyzerDef[] defs = (AnalyzerDef[]) defaults.get( AnalyzerDefs.class );
- if ( defs != null ) {
- for (AnalyzerDef def : defs) {
- context.addAnalyzerDef( def );
- }
- }
- }
- }
-
- private static FilterCachingStrategy buildFilterCachingStrategy(Properties properties) {
- FilterCachingStrategy filterCachingStrategy;
- String impl = properties.getProperty( Environment.FILTER_CACHING_STRATEGY );
- if ( StringHelper.isEmpty( impl ) || "mru".equalsIgnoreCase( impl ) ) {
- filterCachingStrategy = new MRUFilterCachingStrategy();
- }
- else {
- filterCachingStrategy = PluginLoader.instanceFromName( FilterCachingStrategy.class,
- impl, SearchFactoryImpl.class, "filterCachingStrategy" );
- }
- filterCachingStrategy.initialize( properties );
- return filterCachingStrategy;
- }
-
- public FilterCachingStrategy getFilterCachingStrategy() {
- if ( barrier != 0 ) {
- } //read barrier
- return filterCachingStrategy;
- }
-
- public FilterDef getFilterDefinition(String name) {
- if ( barrier != 0 ) {
- } //read barrier
- return filterDefinitions.get( name );
- }
-
- private static class DirectoryProviderData {
- public final ReentrantLock dirLock = new ReentrantLock();
- public OptimizerStrategy optimizerStrategy;
- public Set<Class<?>> classes = new HashSet<Class<?>>( 2 );
- }
-
- public ReentrantLock getDirectoryProviderLock(DirectoryProvider<?> dp) {
- if ( barrier != 0 ) {
- } //read barrier
- return this.dirProviderData.get( dp ).dirLock;
- }
-
- public void addDirectoryProvider(DirectoryProvider<?> provider) {
- //no need to set a barrier we use this method in the init thread
- this.dirProviderData.put( provider, new DirectoryProviderData() );
- }
-
- public int getFilterCacheBitResultsSize() {
- if ( barrier != 0 ) {
- } //read barrier
- return cacheBitResultsSize;
- }
-
- public Set<Class<?>> getIndexedTypesPolymorphic(Class<?>[] classes) {
- if ( barrier != 0 ) {
- } //read barrier
- return indexHierarchy.getIndexedClasses( classes );
- }
-
- public BatchBackend makeBatchBackend(MassIndexerProgressMonitor progressMonitor) {
- BatchBackend batchBackend;
- String impl = configurationProperties.getProperty( Environment.BATCH_BACKEND );
- if ( StringHelper.isEmpty( impl ) || "LuceneBatch".equalsIgnoreCase( impl ) ) {
- batchBackend = new LuceneBatchBackend();
- }
- else {
- batchBackend = PluginLoader.instanceFromName( BatchBackend.class, impl, SearchFactoryImpl.class,
- "batchbackend" );
- }
- Properties batchBackendConfiguration = new MaskedProperty(
- this.configurationProperties, Environment.BATCH_BACKEND );
- batchBackend.initialize( batchBackendConfiguration, progressMonitor, this );
- return batchBackend;
- }
-
- /**
- * Helper class which keeps track of all super classes and interfaces of the indexed entities.
- */
- private static class PolymorphicIndexHierarchy {
- private Map<Class<?>, Set<Class<?>>> classToIndexedClass;
-
- PolymorphicIndexHierarchy() {
- classToIndexedClass = new HashMap<Class<?>, Set<Class<?>>>();
- }
-
- void addIndexedClass(Class indexedClass) {
- addClass( indexedClass, indexedClass );
- Class superClass = indexedClass.getSuperclass();
- while ( superClass != null ) {
- addClass( superClass, indexedClass );
- superClass = superClass.getSuperclass();
- }
- for ( Class clazz : indexedClass.getInterfaces() ) {
- addClass( clazz, indexedClass );
- }
- }
-
- private void addClass(Class superclass, Class indexedClass) {
- Set<Class<?>> classesSet = classToIndexedClass.get( superclass );
- if ( classesSet == null ) {
- classesSet = new HashSet<Class<?>>();
- classToIndexedClass.put( superclass, classesSet );
- }
- classesSet.add( indexedClass );
- }
-
- Set<Class<?>> getIndexedClasses(Class<?>[] classes) {
- Set<Class<?>> idexedClasses = new HashSet<Class<?>>();
- for ( Class clazz : classes ) {
- Set<Class<?>> set = classToIndexedClass.get( clazz );
- if ( set != null ) {
- // at this point we don't have to care about including indexed subclasses of a indexed class
- // MultiClassesQueryLoader will take care of this later and optimise the queries
- idexedClasses.addAll( set );
- }
- }
- if ( log.isTraceEnabled() ) {
- log.trace( "Targeted indexed classes for {}: {}", Arrays.toString( classes ), idexedClasses );
- }
- return idexedClasses;
- }
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.impl;
+
+import java.beans.Introspector;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.slf4j.Logger;
+
+import org.hibernate.annotations.common.reflection.ReflectionManager;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.MetadataProvider;
+import org.hibernate.annotations.common.reflection.MetadataProviderInjector;
+import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;
+import org.hibernate.util.StringHelper;
+import org.hibernate.search.Environment;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.Version;
+import org.hibernate.search.annotations.Factory;
+import org.hibernate.search.annotations.FullTextFilterDef;
+import org.hibernate.search.annotations.FullTextFilterDefs;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Key;
+import org.hibernate.search.annotations.AnalyzerDef;
+import org.hibernate.search.annotations.AnalyzerDefs;
+import org.hibernate.search.backend.BackendQueueProcessorFactory;
+import org.hibernate.search.backend.LuceneIndexingParameters;
+import org.hibernate.search.backend.LuceneWork;
+import org.hibernate.search.backend.OptimizeLuceneWork;
+import org.hibernate.search.backend.Worker;
+import org.hibernate.search.backend.WorkerFactory;
+import org.hibernate.search.backend.configuration.ConfigurationParseHelper;
+import org.hibernate.search.backend.configuration.MaskedProperty;
+import org.hibernate.search.backend.impl.batchlucene.BatchBackend;
+import org.hibernate.search.backend.impl.batchlucene.LuceneBatchBackend;
+import org.hibernate.search.batchindexing.MassIndexerProgressMonitor;
+import org.hibernate.search.cfg.SearchConfiguration;
+import org.hibernate.search.cfg.SearchMapping;
+import org.hibernate.search.engine.DocumentBuilderIndexedEntity;
+import org.hibernate.search.engine.FilterDef;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.engine.EntityState;
+import org.hibernate.search.engine.DocumentBuilderContainedEntity;
+import org.hibernate.search.filter.CachingWrapperFilter;
+import org.hibernate.search.filter.FilterCachingStrategy;
+import org.hibernate.search.filter.MRUFilterCachingStrategy;
+import org.hibernate.search.filter.ShardSensitiveOnlyFilter;
+import org.hibernate.search.reader.ReaderProvider;
+import org.hibernate.search.reader.ReaderProviderFactory;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.store.DirectoryProviderFactory;
+import org.hibernate.search.store.optimization.OptimizerStrategy;
+import org.hibernate.search.util.LoggerFactory;
+import org.hibernate.search.util.PluginLoader;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class SearchFactoryImpl implements SearchFactoryImplementor {
+
+ static {
+ Version.touch();
+ }
+
+ private static final Logger log = LoggerFactory.make();
+
+ private final Map<Class<?>, DocumentBuilderIndexedEntity<?>> documentBuildersIndexedEntities = new HashMap<Class<?>, DocumentBuilderIndexedEntity<?>>();
+ private final Map<Class<?>, DocumentBuilderContainedEntity<?>> documentBuildersContainedEntities = new HashMap<Class<?>, DocumentBuilderContainedEntity<?>>();
+ //keep track of the index modifiers per DirectoryProvider since multiple entity can use the same directory provider
+ private final Map<DirectoryProvider<?>, DirectoryProviderData> dirProviderData = new HashMap<DirectoryProvider<?>, DirectoryProviderData>();
+ private final Worker worker;
+ private final ReaderProvider readerProvider;
+ private BackendQueueProcessorFactory backendQueueProcessorFactory;
+ private final Map<String, FilterDef> filterDefinitions = new HashMap<String, FilterDef>();
+ private final FilterCachingStrategy filterCachingStrategy;
+ private Map<String, Analyzer> analyzers;
+ private final AtomicBoolean stopped = new AtomicBoolean( false );
+ private final int cacheBitResultsSize;
+ private final Properties configurationProperties;
+
+ private final PolymorphicIndexHierarchy indexHierarchy = new PolymorphicIndexHierarchy();
+
+ /*
+ * Used as a barrier (piggyback usage) between initialization and subsequent usage of searchFactory in different threads
+ * this is due to our use of the initialize pattern is a few areas
+ * subsequent reads on volatiles should be very cheap on most platform especially since we don't write after init
+ *
+ * This volatile is meant to be written after initialization
+ * and read by all subsequent methods accessing the SearchFactory state
+ * read to be as barrier != 0. If barrier == 0 we have a race condition, but is not likely to happen.
+ */
+ private volatile short barrier;
+
+ /**
+ * Each directory provider (index) can have its own performance settings.
+ */
+ private Map<DirectoryProvider, LuceneIndexingParameters> dirProviderIndexingParams =
+ new HashMap<DirectoryProvider, LuceneIndexingParameters>();
+ private final String indexingStrategy;
+
+
+ public BackendQueueProcessorFactory getBackendQueueProcessorFactory() {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return backendQueueProcessorFactory;
+ }
+
+ public void setBackendQueueProcessorFactory(BackendQueueProcessorFactory backendQueueProcessorFactory) {
+ //no need to set a barrier, we init in the same thread as the init one
+ this.backendQueueProcessorFactory = backendQueueProcessorFactory;
+ }
+
+ public SearchFactoryImpl(SearchConfiguration cfg) {
+ ReflectionManager reflectionManager = getReflectionManager(cfg);
+
+ this.indexingStrategy = defineIndexingStrategy( cfg ); //need to be done before the document builds
+ initDocumentBuilders( cfg, reflectionManager );
+
+ Set<Class<?>> indexedClasses = documentBuildersIndexedEntities.keySet();
+ for ( DocumentBuilderIndexedEntity builder : documentBuildersIndexedEntities.values() ) {
+ builder.postInitialize( indexedClasses );
+ }
+ //not really necessary today
+ for ( DocumentBuilderContainedEntity builder : documentBuildersContainedEntities.values() ) {
+ builder.postInitialize( indexedClasses );
+ }
+ this.worker = WorkerFactory.createWorker( cfg, this );
+ this.readerProvider = ReaderProviderFactory.createReaderProvider( cfg, this );
+ this.filterCachingStrategy = buildFilterCachingStrategy( cfg.getProperties() );
+ this.cacheBitResultsSize = ConfigurationParseHelper.getIntValue(
+ cfg.getProperties(), Environment.CACHE_DOCIDRESULTS_SIZE, CachingWrapperFilter.DEFAULT_SIZE
+ );
+ this.configurationProperties = cfg.getProperties();
+ this.barrier = 1; //write barrier
+ }
+
+ private ReflectionManager getReflectionManager(SearchConfiguration cfg) {
+ ReflectionManager reflectionManager = cfg.getReflectionManager();
+ if ( reflectionManager == null ) {
+ reflectionManager = new JavaReflectionManager();
+ }
+ final SearchMapping mapping = cfg.getProgrammaticMapping();
+ if ( mapping != null) {
+ if ( ! ( reflectionManager instanceof MetadataProviderInjector)) {
+ throw new SearchException("Programmatic mapping model used but ReflectionManager does not implement "
+ + MetadataProviderInjector.class.getName() );
+ }
+ MetadataProviderInjector injector = (MetadataProviderInjector) reflectionManager;
+ MetadataProvider original = injector.getMetadataProvider();
+ injector.setMetadataProvider( new MappingModelMetadataProvider( original, mapping ) );
+
+ }
+ return reflectionManager;
+ }
+
+ private static String defineIndexingStrategy(SearchConfiguration cfg) {
+ String indexingStrategy = cfg.getProperties().getProperty( Environment.INDEXING_STRATEGY, "event" );
+ if ( !( "event".equals( indexingStrategy ) || "manual".equals( indexingStrategy ) ) ) {
+ throw new SearchException( Environment.INDEXING_STRATEGY + " unknown: " + indexingStrategy );
+ }
+ return indexingStrategy;
+ }
+
+ public String getIndexingStrategy() {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return indexingStrategy;
+ }
+
+ public void close() {
+ if ( barrier != 0 ) {
+ } //read barrier
+ if ( stopped.compareAndSet( false, true ) ) {
+ try {
+ worker.close();
+ }
+ catch ( Exception e ) {
+ log.error( "Worker raises an exception on close()", e );
+ }
+
+ try {
+ readerProvider.destroy();
+ }
+ catch ( Exception e ) {
+ log.error( "ReaderProvider raises an exception on destroy()", e );
+ }
+
+ //TODO move to DirectoryProviderFactory for cleaner
+ for ( DirectoryProvider dp : getDirectoryProviders() ) {
+ try {
+ dp.stop();
+ }
+ catch ( Exception e ) {
+ log.error( "DirectoryProvider raises an exception on stop() ", e );
+ }
+ }
+ }
+ }
+
+ public void addClassToDirectoryProvider(Class<?> clazz, DirectoryProvider<?> directoryProvider) {
+ //no need to set a read barrier, we only use this class in the init thread
+ DirectoryProviderData data = dirProviderData.get( directoryProvider );
+ if ( data == null ) {
+ data = new DirectoryProviderData();
+ dirProviderData.put( directoryProvider, data );
+ }
+ data.classes.add( clazz );
+ }
+
+ public Set<Class<?>> getClassesInDirectoryProvider(DirectoryProvider<?> directoryProvider) {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return Collections.unmodifiableSet( dirProviderData.get( directoryProvider ).classes );
+ }
+
+ private void bindFilterDefs(XClass mappedXClass) {
+ FullTextFilterDef defAnn = mappedXClass.getAnnotation( FullTextFilterDef.class );
+ if ( defAnn != null ) {
+ bindFilterDef( defAnn, mappedXClass );
+ }
+ FullTextFilterDefs defsAnn = mappedXClass.getAnnotation( FullTextFilterDefs.class );
+ if ( defsAnn != null ) {
+ for ( FullTextFilterDef def : defsAnn.value() ) {
+ bindFilterDef( def, mappedXClass );
+ }
+ }
+ }
+
+ private void bindFilterDef(FullTextFilterDef defAnn, XClass mappedXClass) {
+ if ( filterDefinitions.containsKey( defAnn.name() ) ) {
+ throw new SearchException(
+ "Multiple definition of @FullTextFilterDef.name=" + defAnn.name() + ": "
+ + mappedXClass.getName()
+ );
+ }
+
+ FilterDef filterDef = new FilterDef( defAnn );
+ if ( filterDef.getImpl().equals( ShardSensitiveOnlyFilter.class ) ) {
+ //this is a placeholder don't process regularly
+ filterDefinitions.put( defAnn.name(), filterDef );
+ return;
+ }
+ try {
+ filterDef.getImpl().newInstance();
+ }
+ catch ( IllegalAccessException e ) {
+ throw new SearchException( "Unable to create Filter class: " + filterDef.getImpl().getName(), e );
+ }
+ catch ( InstantiationException e ) {
+ throw new SearchException( "Unable to create Filter class: " + filterDef.getImpl().getName(), e );
+ }
+ for ( Method method : filterDef.getImpl().getMethods() ) {
+ if ( method.isAnnotationPresent( Factory.class ) ) {
+ if ( filterDef.getFactoryMethod() != null ) {
+ throw new SearchException(
+ "Multiple @Factory methods found" + defAnn.name() + ": "
+ + filterDef.getImpl().getName() + "." + method.getName()
+ );
+ }
+ if ( !method.isAccessible() ) {
+ method.setAccessible( true );
+ }
+ filterDef.setFactoryMethod( method );
+ }
+ if ( method.isAnnotationPresent( Key.class ) ) {
+ if ( filterDef.getKeyMethod() != null ) {
+ throw new SearchException(
+ "Multiple @Key methods found" + defAnn.name() + ": "
+ + filterDef.getImpl().getName() + "." + method.getName()
+ );
+ }
+ if ( !method.isAccessible() ) {
+ method.setAccessible( true );
+ }
+ filterDef.setKeyMethod( method );
+ }
+
+ String name = method.getName();
+ if ( name.startsWith( "set" ) && method.getParameterTypes().length == 1 ) {
+ filterDef.addSetter( Introspector.decapitalize( name.substring( 3 ) ), method );
+ }
+ }
+ filterDefinitions.put( defAnn.name(), filterDef );
+ }
+
+
+ public Map<Class<?>, DocumentBuilderIndexedEntity<?>> getDocumentBuildersIndexedEntities() {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return documentBuildersIndexedEntities;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> DocumentBuilderIndexedEntity<T> getDocumentBuilderIndexedEntity(Class<T> entityType) {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return ( DocumentBuilderIndexedEntity<T> ) documentBuildersIndexedEntities.get( entityType );
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> DocumentBuilderContainedEntity<T> getDocumentBuilderContainedEntity(Class<T> entityType) {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return ( DocumentBuilderContainedEntity<T> ) documentBuildersContainedEntities.get( entityType );
+ }
+
+ public Set<DirectoryProvider<?>> getDirectoryProviders() {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return this.dirProviderData.keySet();
+ }
+
+ public Worker getWorker() {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return worker;
+ }
+
+ public void addOptimizerStrategy(DirectoryProvider<?> provider, OptimizerStrategy optimizerStrategy) {
+ //no need to set a read barrier, we run this method on the init thread
+ DirectoryProviderData data = dirProviderData.get( provider );
+ if ( data == null ) {
+ data = new DirectoryProviderData();
+ dirProviderData.put( provider, data );
+ }
+ data.optimizerStrategy = optimizerStrategy;
+ }
+
+ public void addIndexingParameters(DirectoryProvider<?> provider, LuceneIndexingParameters indexingParams) {
+ //no need to set a read barrier, we run this method on the init thread
+ dirProviderIndexingParams.put( provider, indexingParams );
+ }
+
+ public OptimizerStrategy getOptimizerStrategy(DirectoryProvider<?> provider) {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return dirProviderData.get( provider ).optimizerStrategy;
+ }
+
+ public LuceneIndexingParameters getIndexingParameters(DirectoryProvider<?> provider) {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return dirProviderIndexingParams.get( provider );
+ }
+
+ public ReaderProvider getReaderProvider() {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return readerProvider;
+ }
+
+ public DirectoryProvider[] getDirectoryProviders(Class<?> entity) {
+ if ( barrier != 0 ) {
+ } //read barrier
+ DocumentBuilderIndexedEntity<?> documentBuilder = getDocumentBuilderIndexedEntity( entity );
+ return documentBuilder == null ? null : documentBuilder.getDirectoryProviders();
+ }
+
+ public void optimize() {
+ if ( barrier != 0 ) {
+ } //read barrier
+ Set<Class<?>> clazzs = getDocumentBuildersIndexedEntities().keySet();
+ for ( Class clazz : clazzs ) {
+ optimize( clazz );
+ }
+ }
+
+ public void optimize(Class entityType) {
+ if ( barrier != 0 ) {
+ } //read barrier
+ if ( !getDocumentBuildersIndexedEntities().containsKey( entityType ) ) {
+ throw new SearchException( "Entity not indexed: " + entityType );
+ }
+ List<LuceneWork> queue = new ArrayList<LuceneWork>( 1 );
+ queue.add( new OptimizeLuceneWork( entityType ) );
+ getBackendQueueProcessorFactory().getProcessor( queue ).run();
+ }
+
+ public Analyzer getAnalyzer(String name) {
+ if ( barrier != 0 ) {
+ } //read barrier
+ final Analyzer analyzer = analyzers.get( name );
+ if ( analyzer == null ) {
+ throw new SearchException( "Unknown Analyzer definition: " + name );
+ }
+ return analyzer;
+ }
+
+ public Analyzer getAnalyzer(Class clazz) {
+ if ( clazz == null ) {
+ throw new IllegalArgumentException( "A class has to be specified for retrieving a scoped analyzer" );
+ }
+
+ DocumentBuilderIndexedEntity<?> builder = documentBuildersIndexedEntities.get( clazz );
+ if ( builder == null ) {
+ throw new IllegalArgumentException(
+ "Entity for which to retrieve the scoped analyzer is not an @Indexed entity: " + clazz.getName()
+ );
+ }
+
+ return builder.getAnalyzer();
+ }
+
+ private void initDocumentBuilders(SearchConfiguration cfg, ReflectionManager reflectionManager) {
+ InitContext context = new InitContext( cfg );
+ Iterator<Class<?>> iter = cfg.getClassMappings();
+ DirectoryProviderFactory factory = new DirectoryProviderFactory();
+
+ initProgrammaticAnalyzers(context, reflectionManager);
+
+ while ( iter.hasNext() ) {
+ Class mappedClass = iter.next();
+ if ( mappedClass == null ) {
+ continue;
+ }
+ @SuppressWarnings( "unchecked" )
+ XClass mappedXClass = reflectionManager.toXClass( mappedClass );
+ if ( mappedXClass == null ) {
+ continue;
+ }
+
+ if ( mappedXClass.isAnnotationPresent( Indexed.class ) ) {
+
+ if ( mappedXClass.isAbstract() ) {
+ log.warn( "Abstract classes can never insert index documents. Remove @Indexed." );
+ continue;
+ }
+
+ DirectoryProviderFactory.DirectoryProviders providers = factory.createDirectoryProviders(
+ mappedXClass, cfg, this, reflectionManager
+ );
+ //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
+ //XClass unfortunately is not (yet) genericized: TODO?
+ final DocumentBuilderIndexedEntity<?> documentBuilder = new DocumentBuilderIndexedEntity(
+ mappedXClass, context, providers.getProviders(), providers.getSelectionStrategy(),
+ reflectionManager
+ );
+
+ indexHierarchy.addIndexedClass( mappedClass );
+ documentBuildersIndexedEntities.put( mappedClass, documentBuilder );
+ }
+ else {
+ //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
+ //XClass unfortunately is not (yet) genericized: TODO?
+ final DocumentBuilderContainedEntity<?> documentBuilder = new DocumentBuilderContainedEntity(
+ mappedXClass, context, reflectionManager
+ );
+ //TODO enhance that, I don't like to expose EntityState
+ if ( documentBuilder.getEntityState() != EntityState.NON_INDEXABLE ) {
+ documentBuildersContainedEntities.put( mappedClass, documentBuilder );
+ }
+ }
+ bindFilterDefs( mappedXClass );
+ //TODO should analyzer def for classes at tyher sqme level???
+ }
+ analyzers = context.initLazyAnalyzers();
+ factory.startDirectoryProviders();
+ }
+
+ private void initProgrammaticAnalyzers(InitContext context, ReflectionManager reflectionManager) {
+ final Map defaults = reflectionManager.getDefaults();
+
+ if (defaults != null) {
+ AnalyzerDef[] defs = (AnalyzerDef[]) defaults.get( AnalyzerDefs.class );
+ if ( defs != null ) {
+ for (AnalyzerDef def : defs) {
+ context.addAnalyzerDef( def );
+ }
+ }
+ }
+ }
+
+ private static FilterCachingStrategy buildFilterCachingStrategy(Properties properties) {
+ FilterCachingStrategy filterCachingStrategy;
+ String impl = properties.getProperty( Environment.FILTER_CACHING_STRATEGY );
+ if ( StringHelper.isEmpty( impl ) || "mru".equalsIgnoreCase( impl ) ) {
+ filterCachingStrategy = new MRUFilterCachingStrategy();
+ }
+ else {
+ filterCachingStrategy = PluginLoader.instanceFromName( FilterCachingStrategy.class,
+ impl, SearchFactoryImpl.class, "filterCachingStrategy" );
+ }
+ filterCachingStrategy.initialize( properties );
+ return filterCachingStrategy;
+ }
+
+ public FilterCachingStrategy getFilterCachingStrategy() {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return filterCachingStrategy;
+ }
+
+ public FilterDef getFilterDefinition(String name) {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return filterDefinitions.get( name );
+ }
+
+ private static class DirectoryProviderData {
+ public final ReentrantLock dirLock = new ReentrantLock();
+ public OptimizerStrategy optimizerStrategy;
+ public Set<Class<?>> classes = new HashSet<Class<?>>( 2 );
+ }
+
+ public ReentrantLock getDirectoryProviderLock(DirectoryProvider<?> dp) {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return this.dirProviderData.get( dp ).dirLock;
+ }
+
+ public void addDirectoryProvider(DirectoryProvider<?> provider) {
+ //no need to set a barrier we use this method in the init thread
+ this.dirProviderData.put( provider, new DirectoryProviderData() );
+ }
+
+ public int getFilterCacheBitResultsSize() {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return cacheBitResultsSize;
+ }
+
+ public Set<Class<?>> getIndexedTypesPolymorphic(Class<?>[] classes) {
+ if ( barrier != 0 ) {
+ } //read barrier
+ return indexHierarchy.getIndexedClasses( classes );
+ }
+
+ public BatchBackend makeBatchBackend(MassIndexerProgressMonitor progressMonitor) {
+ BatchBackend batchBackend;
+ String impl = configurationProperties.getProperty( Environment.BATCH_BACKEND );
+ if ( StringHelper.isEmpty( impl ) || "LuceneBatch".equalsIgnoreCase( impl ) ) {
+ batchBackend = new LuceneBatchBackend();
+ }
+ else {
+ batchBackend = PluginLoader.instanceFromName( BatchBackend.class, impl, SearchFactoryImpl.class,
+ "batchbackend" );
+ }
+ Properties batchBackendConfiguration = new MaskedProperty(
+ this.configurationProperties, Environment.BATCH_BACKEND );
+ batchBackend.initialize( batchBackendConfiguration, progressMonitor, this );
+ return batchBackend;
+ }
+
+ /**
+ * Helper class which keeps track of all super classes and interfaces of the indexed entities.
+ */
+ private static class PolymorphicIndexHierarchy {
+ private Map<Class<?>, Set<Class<?>>> classToIndexedClass;
+
+ PolymorphicIndexHierarchy() {
+ classToIndexedClass = new HashMap<Class<?>, Set<Class<?>>>();
+ }
+
+ void addIndexedClass(Class indexedClass) {
+ addClass( indexedClass, indexedClass );
+ Class superClass = indexedClass.getSuperclass();
+ while ( superClass != null ) {
+ addClass( superClass, indexedClass );
+ superClass = superClass.getSuperclass();
+ }
+ for ( Class clazz : indexedClass.getInterfaces() ) {
+ addClass( clazz, indexedClass );
+ }
+ }
+
+ private void addClass(Class superclass, Class indexedClass) {
+ Set<Class<?>> classesSet = classToIndexedClass.get( superclass );
+ if ( classesSet == null ) {
+ classesSet = new HashSet<Class<?>>();
+ classToIndexedClass.put( superclass, classesSet );
+ }
+ classesSet.add( indexedClass );
+ }
+
+ Set<Class<?>> getIndexedClasses(Class<?>[] classes) {
+ Set<Class<?>> idexedClasses = new HashSet<Class<?>>();
+ for ( Class clazz : classes ) {
+ Set<Class<?>> set = classToIndexedClass.get( clazz );
+ if ( set != null ) {
+ // at this point we don't have to care about including indexed subclasses of a indexed class
+ // MultiClassesQueryLoader will take care of this later and optimise the queries
+ idexedClasses.addAll( set );
+ }
+ }
+ if ( log.isTraceEnabled() ) {
+ log.trace( "Targeted indexed classes for {}: {}", Arrays.toString( classes ), idexedClasses );
+ }
+ return idexedClasses;
+ }
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/impl/SimpleIndexingProgressMonitor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/SimpleIndexingProgressMonitor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/impl/SimpleIndexingProgressMonitor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.impl;
import java.util.concurrent.atomic.AtomicLong;
Modified: search/trunk/src/main/java/org/hibernate/search/impl/SolrAnalyzerBuilder.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/SolrAnalyzerBuilder.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/impl/SolrAnalyzerBuilder.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.impl;
import java.util.Map;
Modified: search/trunk/src/main/java/org/hibernate/search/jpa/FullTextEntityManager.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/jpa/FullTextEntityManager.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/jpa/FullTextEntityManager.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.jpa;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/jpa/FullTextQuery.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/jpa/FullTextQuery.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/jpa/FullTextQuery.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.jpa;
import javax.persistence.Query;
Modified: search/trunk/src/main/java/org/hibernate/search/jpa/Search.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/jpa/Search.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/jpa/Search.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.jpa;
import javax.persistence.EntityManager;
@@ -36,4 +59,4 @@
public static FullTextEntityManager createFullTextEntityManager(EntityManager em) {
return getFullTextEntityManager(em);
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.jpa.impl;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.jpa.impl;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/query/FullTextFilterImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/query/FullTextFilterImpl.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/query/FullTextFilterImpl.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.query;
import java.util.HashMap;
Modified: search/trunk/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,915 +1,938 @@
-//$Id$
-package org.hibernate.search.query;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Explanation;
-import org.apache.lucene.search.Filter;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Searcher;
-import org.apache.lucene.search.Similarity;
-import org.apache.lucene.search.Sort;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.TopDocs;
-import org.slf4j.Logger;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.LockMode;
-import org.hibernate.Query;
-import org.hibernate.ScrollMode;
-import org.hibernate.ScrollableResults;
-import org.hibernate.Session;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.query.ParameterMetadata;
-import org.hibernate.impl.AbstractQueryImpl;
-import org.hibernate.impl.CriteriaImpl;
-import org.hibernate.search.FullTextFilter;
-import org.hibernate.search.FullTextQuery;
-import org.hibernate.search.SearchException;
-import org.hibernate.search.engine.DocumentBuilder;
-import org.hibernate.search.engine.DocumentBuilderIndexedEntity;
-import org.hibernate.search.engine.DocumentExtractor;
-import org.hibernate.search.engine.EntityInfo;
-import org.hibernate.search.engine.FilterDef;
-import org.hibernate.search.engine.Loader;
-import org.hibernate.search.engine.MultiClassesQueryLoader;
-import org.hibernate.search.engine.ProjectionLoader;
-import org.hibernate.search.engine.QueryLoader;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.filter.ChainedFilter;
-import org.hibernate.search.filter.FilterKey;
-import org.hibernate.search.filter.StandardFilterKey;
-import org.hibernate.search.filter.FullTextFilterImplementor;
-import org.hibernate.search.filter.ShardSensitiveOnlyFilter;
-import org.hibernate.search.reader.ReaderProvider;
-import static org.hibernate.search.reader.ReaderProviderHelper.getIndexReaders;
-import org.hibernate.search.store.DirectoryProvider;
-import org.hibernate.search.store.IndexShardingStrategy;
-import org.hibernate.search.util.ContextHelper;
-import static org.hibernate.search.util.FilterCacheModeTypeHelper.cacheInstance;
-import static org.hibernate.search.util.FilterCacheModeTypeHelper.cacheResults;
-import org.hibernate.search.util.LoggerFactory;
-import org.hibernate.transform.ResultTransformer;
-import org.hibernate.util.ReflectHelper;
-
-/**
- * Implementation of {@link org.hibernate.search.FullTextQuery}.
- *
- * @author Emmanuel Bernard
- * @author Hardy Ferentschik
- * @todo Implements setParameter()
- */
-public class FullTextQueryImpl extends AbstractQueryImpl implements FullTextQuery {
- private static final Logger log = LoggerFactory.make();
- private final org.apache.lucene.search.Query luceneQuery;
- private Set<Class<?>> indexedTargetedEntities;
- private List<Class<?>> targetedEntities;
- private Set<Class<?>> classesAndSubclasses;
- //optimization: if we can avoid the filter clause (we can most of the time) do it as it has a significant perf impact
- private boolean needClassFilterClause;
- private Integer firstResult;
- private Integer maxResults;
- private Integer resultSize;
- private Sort sort;
- private Filter filter;
- private Filter userFilter;
- private Criteria criteria;
- private String[] indexProjection;
- private Set<String> idFieldNames;
- private boolean allowFieldSelectionInProjection = true;
- private ResultTransformer resultTransformer;
- private SearchFactoryImplementor searchFactoryImplementor;
- private final Map<String, FullTextFilterImpl> filterDefinitions = new HashMap<String, FullTextFilterImpl>();
- private int fetchSize = 1;
- private static final FullTextFilterImplementor[] EMPTY_FULL_TEXT_FILTER_IMPLEMENTOR = new FullTextFilterImplementor[0];
-
-
- /**
- * Constructs a <code>FullTextQueryImpl</code> instance.
- *
- * @param query The Lucene query.
- * @param classes Array of classes (must be immutable) used to filter the results to the given class types.
- * @param session Access to the Hibernate session.
- * @param parameterMetadata Additional query metadata.
- */
- public FullTextQueryImpl(org.apache.lucene.search.Query query, Class<?>[] classes, SessionImplementor session,
- ParameterMetadata parameterMetadata) {
- //TODO handle flushMode
- super( query.toString(), null, session, parameterMetadata );
- this.luceneQuery = query;
- this.targetedEntities = Arrays.asList( classes );
- searchFactoryImplementor = getSearchFactoryImplementor();
- this.indexedTargetedEntities = searchFactoryImplementor.getIndexedTypesPolymorphic( classes );
- if ( classes != null && classes.length > 0 && indexedTargetedEntities.size() == 0 ) {
- String msg = "None of the specified entity types or any of their subclasses are indexed.";
- throw new IllegalArgumentException( msg );
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public FullTextQuery setSort(Sort sort) {
- this.sort = sort;
- return this;
- }
-
- /**
- * {@inheritDoc}
- */
- public FullTextQuery setFilter(Filter filter) {
- this.userFilter = filter;
- return this;
- }
-
- /**
- * Return an interator on the results.
- * Retrieve the object one by one (initialize it during the next() operation)
- */
- public Iterator iterate() throws HibernateException {
- //implement an interator which keep the id/class for each hit and get the object on demand
- //cause I can't keep the searcher and hence the hit opened. I dont have any hook to know when the
- //user stop using it
- //scrollable is better in this area
-
- //find the directories
- IndexSearcher searcher = buildSearcher( searchFactoryImplementor );
- if ( searcher == null ) {
- return new IteratorImpl( Collections.EMPTY_LIST, noLoader );
- }
- try {
- QueryHits queryHits = getQueryHits( searcher, calculateTopDocsRetrievalSize() );
- int first = first();
- int max = max( first, queryHits.totalHits );
-
- int size = max - first + 1 < 0 ? 0 : max - first + 1;
- List<EntityInfo> infos = new ArrayList<EntityInfo>( size );
- DocumentExtractor extractor = new DocumentExtractor(
- queryHits, searchFactoryImplementor, indexProjection, idFieldNames, allowFieldSelectionInProjection
- );
- for ( int index = first; index <= max; index++ ) {
- infos.add( extractor.extract( index ) );
- }
- Loader loader = getLoader();
- return new IteratorImpl( infos, loader );
- }
- catch ( IOException e ) {
- throw new HibernateException( "Unable to query Lucene index", e );
- }
- finally {
- try {
- closeSearcher( searcher, searchFactoryImplementor.getReaderProvider() );
- }
- catch ( SearchException e ) {
- log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
- }
- }
- }
-
- /**
- * Decide which object loader to use depending on the targeted entities. If there is only a single entity targeted
- * a <code>QueryLoader</code> can be used which will only execute a single query to load the entities. If more than
- * one entity is targeted a <code>MultiClassesQueryLoader</code> must be used. We also have to consider whether
- * projections or <code>Criteria</code> are used.
- *
- * @return The loader instance to use to load the results of the query.
- */
- private Loader getLoader() {
- Loader loader;
- if ( indexProjection != null ) {
- loader = getProjectionLoader();
- }
- else if ( criteria != null ) {
- loader = getCriteriaLoader();
- }
- else if ( targetedEntities.size() == 1 ) {
- loader = getSingleEntityLoader();
- }
- else {
- loader = getMultipleEntitiesLoader();
- }
- return loader;
- }
-
- private Loader getMultipleEntitiesLoader() {
- final MultiClassesQueryLoader multiClassesLoader = new MultiClassesQueryLoader();
- multiClassesLoader.init( ( Session ) session, searchFactoryImplementor );
- multiClassesLoader.setEntityTypes( indexedTargetedEntities );
- return multiClassesLoader;
- }
-
- private Loader getSingleEntityLoader() {
- final QueryLoader queryLoader = new QueryLoader();
- queryLoader.init( ( Session ) session, searchFactoryImplementor );
- queryLoader.setEntityType( targetedEntities.iterator().next() );
- return queryLoader;
- }
-
- private Loader getCriteriaLoader() {
- if ( targetedEntities.size() > 1 ) {
- throw new SearchException( "Cannot mix criteria and multiple entity types" );
- }
- Class entityType = targetedEntities.size() == 0 ? null : targetedEntities.iterator().next();
- if ( criteria instanceof CriteriaImpl ) {
- String targetEntity = ( ( CriteriaImpl ) criteria ).getEntityOrClassName();
- if ( entityType != null && !entityType.getName().equals( targetEntity ) ) {
- throw new SearchException( "Criteria query entity should match query entity" );
- }
- else {
- try {
- entityType = ReflectHelper.classForName( targetEntity );
- }
- catch ( ClassNotFoundException e ) {
- throw new SearchException( "Unable to load entity class from criteria: " + targetEntity, e );
- }
- }
- }
- QueryLoader queryLoader = new QueryLoader();
- queryLoader.init( ( Session ) session, searchFactoryImplementor );
- queryLoader.setEntityType( entityType );
- queryLoader.setCriteria( criteria );
- return queryLoader;
- }
-
- private Loader getProjectionLoader() {
- ProjectionLoader loader = new ProjectionLoader();
- loader.init( ( Session ) session, searchFactoryImplementor, resultTransformer, indexProjection );
- loader.setEntityTypes( indexedTargetedEntities );
- return loader;
- }
-
- public ScrollableResults scroll() throws HibernateException {
- //keep the searcher open until the resultset is closed
-
- //find the directories
- IndexSearcher searcher = buildSearcher( searchFactoryImplementor );
- //FIXME: handle null searcher
- try {
- QueryHits queryHits = getQueryHits( searcher, calculateTopDocsRetrievalSize() );
- int first = first();
- int max = max( first, queryHits.totalHits );
- DocumentExtractor extractor = new DocumentExtractor(
- queryHits, searchFactoryImplementor, indexProjection, idFieldNames, allowFieldSelectionInProjection
- );
- Loader loader = getLoader();
- return new ScrollableResultsImpl(
- searcher, first, max, fetchSize, extractor, loader, searchFactoryImplementor, this.session
- );
- }
- catch ( IOException e ) {
- //close only in case of exception
- try {
- closeSearcher( searcher, searchFactoryImplementor.getReaderProvider() );
- }
- catch ( SearchException ee ) {
- //we have the initial issue already
- }
- throw new HibernateException( "Unable to query Lucene index", e );
- }
- }
-
- public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException {
- //TODO think about this scrollmode
- return scroll();
- }
-
- public List list() throws HibernateException {
- //find the directories
- IndexSearcher searcher = buildSearcher( searchFactoryImplementor );
- if ( searcher == null ) {
- return Collections.EMPTY_LIST;
- }
- try {
- QueryHits queryHits = getQueryHits( searcher, calculateTopDocsRetrievalSize() );
- int first = first();
- int max = max( first, queryHits.totalHits );
-
- int size = max - first + 1 < 0 ? 0 : max - first + 1;
- List<EntityInfo> infos = new ArrayList<EntityInfo>( size );
- DocumentExtractor extractor = new DocumentExtractor(
- queryHits, searchFactoryImplementor, indexProjection, idFieldNames, allowFieldSelectionInProjection
- );
- for ( int index = first; index <= max; index++ ) {
- infos.add( extractor.extract( index ) );
- }
- Loader loader = getLoader();
- List list = loader.load( infos.toArray( new EntityInfo[infos.size()] ) );
- if ( resultTransformer == null || loader instanceof ProjectionLoader ) {
- //stay consistent with transformTuple which can only be executed during a projection
- return list;
- }
- else {
- return resultTransformer.transformList( list );
- }
- }
- catch ( IOException e ) {
- throw new HibernateException( "Unable to query Lucene index", e );
- }
- finally {
- try {
- closeSearcher( searcher, searchFactoryImplementor.getReaderProvider() );
- }
- catch ( SearchException e ) {
- log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
- }
- }
- }
-
- public Explanation explain(int documentId) {
- Explanation explanation = null;
- Searcher searcher = buildSearcher( searchFactoryImplementor );
- if ( searcher == null ) {
- throw new SearchException(
- "Unable to build explanation for document id:"
- + documentId + ". no index found"
- );
- }
- try {
- org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
- buildFilters();
- explanation = searcher.explain( query, documentId );
- }
- catch ( IOException e ) {
- throw new HibernateException( "Unable to query Lucene index and build explanation", e );
- }
- finally {
- //searcher cannot be null
- try {
- closeSearcher( searcher, searchFactoryImplementor.getReaderProvider() );
- }
- catch ( SearchException e ) {
- log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
- }
- }
- return explanation;
- }
-
- /**
- * Execute the lucene search and return the matching hits.
- *
- * @param searcher The index searcher.
- * @param n Numer of documents to retrieve
- *
- * @return An instance of <code>QueryHits</code> wrapping the Lucene query and the matching documents.
- *
- * @throws IOException in case there is an error executing the lucene search.
- */
- private QueryHits getQueryHits(Searcher searcher, Integer n) throws IOException {
- org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
- buildFilters();
- QueryHits queryHits;
- if ( n == null ) { // try to make sure that we get the right amount of top docs
- queryHits = new QueryHits( searcher, query, filter, sort );
- }
- else {
- queryHits = new QueryHits( searcher, query, filter, sort, n );
- }
- resultSize = queryHits.totalHits;
- return queryHits;
- }
-
- /**
- * @return Calculates the number of <code>TopDocs</code> which should be retrieved as part of the query. If Hibernate's
- * pagination parameters are set returned value is <code>first + maxResults</code>. Otherwise <code>null</code> is
- * returned.
- */
- private Integer calculateTopDocsRetrievalSize() {
- if ( maxResults == null ) {
- return null;
- }
- else {
- long tmpMaxResult = ( long ) first() + maxResults;
- if ( tmpMaxResult >= Integer.MAX_VALUE ) {
- // don't return just Integer.MAX_VALUE due to a bug in Lucene - see HSEARCH-330
- return Integer.MAX_VALUE - 1;
- }
- else {
- return ( int ) tmpMaxResult;
- }
- }
- }
-
- private void buildFilters() {
- ChainedFilter chainedFilter = null;
- if ( ! filterDefinitions.isEmpty() ) {
- chainedFilter = new ChainedFilter();
- for ( FullTextFilterImpl fullTextFilter : filterDefinitions.values() ) {
- Filter filter = buildLuceneFilter( fullTextFilter );
- if (filter != null) chainedFilter.addFilter( filter );
- }
- }
-
- if ( userFilter != null ) {
- //chainedFilter is not always necessary here but the code is easier to read
- if (chainedFilter == null) chainedFilter = new ChainedFilter();
- chainedFilter.addFilter( userFilter );
- }
-
- if ( chainedFilter == null || chainedFilter.isEmpty() ) {
- filter = null;
- }
- else {
- filter = chainedFilter;
- }
- }
-
- /**
- * Builds a Lucene filter using the given <code>FullTextFilter</code>.
- *
- * @param fullTextFilter the Hibernate specific <code>FullTextFilter</code> used to create the
- * Lucene <code>Filter</code>.
- *
- * @return the Lucene filter mapped to the filter definition
- */
- private Filter buildLuceneFilter(FullTextFilterImpl fullTextFilter) {
-
- /*
- * FilterKey implementations and Filter(Factory) do not have to be threadsafe wrt their parameter injection
- * as FilterCachingStrategy ensure a memory barrier between concurrent thread calls
- */
- FilterDef def = searchFactoryImplementor.getFilterDefinition( fullTextFilter.getName() );
- //def can never be null, ti's guarded by enableFullTextFilter(String)
-
- if ( isPreQueryFilterOnly(def) ) return null;
-
- Object instance = createFilterInstance( fullTextFilter, def );
- FilterKey key = createFilterKey( def, instance );
-
- // try to get the filter out of the cache
- Filter filter = cacheInstance( def.getCacheMode() ) ?
- searchFactoryImplementor.getFilterCachingStrategy().getCachedFilter( key ) :
- null;
-
- if ( filter == null ) {
- filter = createFilter( def, instance );
-
- // add filter to cache if we have to
- if ( cacheInstance( def.getCacheMode() ) ) {
- searchFactoryImplementor.getFilterCachingStrategy().addCachedFilter( key, filter );
- }
- }
- return filter;
- }
-
- private boolean isPreQueryFilterOnly(FilterDef def) {
- return def.getImpl().equals( ShardSensitiveOnlyFilter.class );
- }
-
- private Filter createFilter(FilterDef def, Object instance) {
- Filter filter;
- if ( def.getFactoryMethod() != null ) {
- try {
- filter = ( Filter ) def.getFactoryMethod().invoke( instance );
- }
- catch ( IllegalAccessException e ) {
- throw new SearchException(
- "Unable to access @Factory method: "
- + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
- );
- }
- catch ( InvocationTargetException e ) {
- throw new SearchException(
- "Unable to access @Factory method: "
- + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
- );
- }
- catch ( ClassCastException e ) {
- throw new SearchException(
- "@Key method does not return a org.apache.lucene.search.Filter class: "
- + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
- );
- }
- }
- else {
- try {
- filter = ( Filter ) instance;
- }
- catch ( ClassCastException e ) {
- throw new SearchException(
- "Filter implementation does not implement the Filter interface: "
- + def.getImpl().getName() + ". "
- + ( def.getFactoryMethod() != null ? def.getFactoryMethod().getName() : "" ), e
- );
- }
- }
-
- filter = addCachingWrapperFilter( filter, def );
- return filter;
- }
-
- /**
- * Decides whether to wrap the given filter around a <code>CachingWrapperFilter<code>.
- *
- * @param filter the filter which maybe gets wrapped.
- * @param def The filter definition used to decide whether wrapping should occur or not.
- *
- * @return The original filter or wrapped filter depending on the information extracted from
- * <code>def</code>.
- */
- private Filter addCachingWrapperFilter(Filter filter, FilterDef def) {
- if ( cacheResults( def.getCacheMode() ) ) {
- int cachingWrapperFilterSize = searchFactoryImplementor.getFilterCacheBitResultsSize();
- filter = new org.hibernate.search.filter.CachingWrapperFilter( filter, cachingWrapperFilterSize );
- }
-
- return filter;
- }
-
- private FilterKey createFilterKey(FilterDef def, Object instance) {
- FilterKey key = null;
- if ( !cacheInstance( def.getCacheMode() ) ) {
- return key; // if the filter is not cached there is no key!
- }
-
- if ( def.getKeyMethod() == null ) {
- key = new FilterKey() {
- public int hashCode() {
- return getImpl().hashCode();
- }
-
- public boolean equals(Object obj) {
- if ( !( obj instanceof FilterKey ) ) {
- return false;
- }
- FilterKey that = ( FilterKey ) obj;
- return this.getImpl().equals( that.getImpl() );
- }
- };
- }
- else {
- try {
- key = ( FilterKey ) def.getKeyMethod().invoke( instance );
- }
- catch ( IllegalAccessException e ) {
- throw new SearchException(
- "Unable to access @Key method: "
- + def.getImpl().getName() + "." + def.getKeyMethod().getName()
- );
- }
- catch ( InvocationTargetException e ) {
- throw new SearchException(
- "Unable to access @Key method: "
- + def.getImpl().getName() + "." + def.getKeyMethod().getName()
- );
- }
- catch ( ClassCastException e ) {
- throw new SearchException(
- "@Key method does not return FilterKey: "
- + def.getImpl().getName() + "." + def.getKeyMethod().getName()
- );
- }
- }
- key.setImpl( def.getImpl() );
-
- //Make sure Filters are isolated by filter def name
- StandardFilterKey wrapperKey = new StandardFilterKey();
- wrapperKey.addParameter( def.getName() );
- wrapperKey.addParameter( key );
- return wrapperKey;
- }
-
- private Object createFilterInstance(FullTextFilterImpl fullTextFilter,
- FilterDef def) {
- Object instance;
- try {
- instance = def.getImpl().newInstance();
- }
- catch ( InstantiationException e ) {
- throw new SearchException( "Unable to create @FullTextFilterDef: " + def.getImpl(), e );
- }
- catch ( IllegalAccessException e ) {
- throw new SearchException( "Unable to create @FullTextFilterDef: " + def.getImpl(), e );
- }
- for ( Map.Entry<String, Object> entry : fullTextFilter.getParameters().entrySet() ) {
- def.invoke( entry.getKey(), instance, entry.getValue() );
- }
- if ( cacheInstance( def.getCacheMode() ) && def.getKeyMethod() == null && fullTextFilter.getParameters()
- .size() > 0 ) {
- throw new SearchException( "Filter with parameters and no @Key method: " + fullTextFilter.getName() );
- }
- return instance;
- }
-
- private org.apache.lucene.search.Query filterQueryByClasses(org.apache.lucene.search.Query luceneQuery) {
- if ( !needClassFilterClause ) {
- return luceneQuery;
- }
- else {
- //A query filter is more practical than a manual class filtering post query (esp on scrollable resultsets)
- //it also probably minimise the memory footprint
- BooleanQuery classFilter = new BooleanQuery();
- //annihilate the scoring impact of DocumentBuilderIndexedEntity.CLASS_FIELDNAME
- classFilter.setBoost( 0 );
- for ( Class clazz : classesAndSubclasses ) {
- Term t = new Term( DocumentBuilder.CLASS_FIELDNAME, clazz.getName() );
- TermQuery termQuery = new TermQuery( t );
- classFilter.add( termQuery, BooleanClause.Occur.SHOULD );
- }
- BooleanQuery filteredQuery = new BooleanQuery();
- filteredQuery.add( luceneQuery, BooleanClause.Occur.MUST );
- filteredQuery.add( classFilter, BooleanClause.Occur.MUST );
- return filteredQuery;
- }
- }
-
- private int max(int first, int totalHits) {
- if ( maxResults == null ) {
- return totalHits - 1;
- }
- else {
- return maxResults + first < totalHits ?
- first + maxResults - 1 :
- totalHits - 1;
- }
- }
-
- private int first() {
- return firstResult != null ?
- firstResult :
- 0;
- }
-
- /**
- * Build the index searcher for this fulltext query.
- *
- * @param searchFactoryImplementor the search factory.
- *
- * @return the <code>IndexSearcher</code> for this query (can be <code>null</code>.
- * TODO change classesAndSubclasses by side effect, which is a mismatch with the Searcher return, fix that.
- */
- private IndexSearcher buildSearcher(SearchFactoryImplementor searchFactoryImplementor) {
- Map<Class<?>, DocumentBuilderIndexedEntity<?>> builders = searchFactoryImplementor.getDocumentBuildersIndexedEntities();
- List<DirectoryProvider> targetedDirectories = new ArrayList<DirectoryProvider>();
- Set<String> idFieldNames = new HashSet<String>();
-
- Similarity searcherSimilarity = null;
- //TODO check if caching this work for the last n list of indexedTargetedEntities makes a perf boost
- if ( indexedTargetedEntities.size() == 0 ) {
- // empty indexedTargetedEntities array means search over all indexed enities,
- // but we have to make sure there is at least one
- if ( builders.isEmpty() ) {
- throw new HibernateException(
- "There are no mapped entities. Don't forget to add @Indexed to at least one class."
- );
- }
-
- for ( DocumentBuilderIndexedEntity builder : builders.values() ) {
- searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
- if ( builder.getIdKeywordName() != null ) {
- idFieldNames.add( builder.getIdKeywordName() );
- allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
- }
- populateDirectories( targetedDirectories, builder );
- }
- classesAndSubclasses = null;
- }
- else {
- Set<Class<?>> involvedClasses = new HashSet<Class<?>>( indexedTargetedEntities.size() );
- involvedClasses.addAll( indexedTargetedEntities );
- for ( Class<?> clazz : indexedTargetedEntities ) {
- DocumentBuilderIndexedEntity<?> builder = builders.get( clazz );
- if ( builder != null ) {
- involvedClasses.addAll( builder.getMappedSubclasses() );
- }
- }
-
- for ( Class clazz : involvedClasses ) {
- DocumentBuilderIndexedEntity builder = builders.get( clazz );
- //TODO should we rather choose a polymorphic path and allow non mapped entities
- if ( builder == null ) {
- throw new HibernateException( "Not a mapped entity (don't forget to add @Indexed): " + clazz );
- }
- if ( builder.getIdKeywordName() != null ) {
- idFieldNames.add( builder.getIdKeywordName() );
- allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
- }
- searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
- populateDirectories( targetedDirectories, builder );
- }
- this.classesAndSubclasses = involvedClasses;
- }
- this.idFieldNames = idFieldNames;
-
- //compute optimization needClassFilterClause
- //if at least one DP contains one class that is not part of the targeted classesAndSubclasses we can't optimize
- if ( classesAndSubclasses != null ) {
- for ( DirectoryProvider dp : targetedDirectories ) {
- final Set<Class<?>> classesInDirectoryProvider = searchFactoryImplementor.getClassesInDirectoryProvider(
- dp
- );
- // if a DP contains only one class, we know for sure it's part of classesAndSubclasses
- if ( classesInDirectoryProvider.size() > 1 ) {
- //risk of needClassFilterClause
- for ( Class clazz : classesInDirectoryProvider ) {
- if ( !classesAndSubclasses.contains( clazz ) ) {
- this.needClassFilterClause = true;
- break;
- }
- }
- }
- if ( this.needClassFilterClause ) {
- break;
- }
- }
- }
-
- //set up the searcher
- final DirectoryProvider[] directoryProviders = targetedDirectories.toArray( new DirectoryProvider[targetedDirectories.size()] );
- IndexSearcher is = new IndexSearcher(
- searchFactoryImplementor.getReaderProvider().openReader(
- directoryProviders
- )
- );
- is.setSimilarity( searcherSimilarity );
- return is;
- }
-
- private void populateDirectories(List<DirectoryProvider> directories, DocumentBuilderIndexedEntity builder) {
- final IndexShardingStrategy indexShardingStrategy = builder.getDirectoryProviderSelectionStrategy();
- final DirectoryProvider[] directoryProviders;
- if ( filterDefinitions != null && !filterDefinitions.isEmpty() ) {
- directoryProviders = indexShardingStrategy.getDirectoryProvidersForQuery(
- filterDefinitions.values().toArray( new FullTextFilterImplementor[filterDefinitions.size()] )
- );
- }
- else {
- //no filter get all shards
- directoryProviders = indexShardingStrategy.getDirectoryProvidersForQuery( EMPTY_FULL_TEXT_FILTER_IMPLEMENTOR );
- }
-
- for ( DirectoryProvider provider : directoryProviders ) {
- if ( !directories.contains( provider ) ) {
- directories.add( provider );
- }
- }
- }
-
- private Similarity checkSimilarity(Similarity similarity, DocumentBuilderIndexedEntity builder) {
- if ( similarity == null ) {
- similarity = builder.getSimilarity();
- }
- else if ( !similarity.getClass().equals( builder.getSimilarity().getClass() ) ) {
- throw new HibernateException(
- "Cannot perform search on two entities with differing Similarity implementations (" + similarity.getClass()
- .getName() + " & " + builder.getSimilarity().getClass().getName() + ")"
- );
- }
-
- return similarity;
- }
-
- private void closeSearcher(Searcher searcher, ReaderProvider readerProvider) {
- Set<IndexReader> indexReaders = getIndexReaders( searcher );
-
- for ( IndexReader indexReader : indexReaders ) {
- readerProvider.closeReader( indexReader );
- }
- }
-
- public int getResultSize() {
- if ( resultSize == null ) {
- //get result size without object initialization
- IndexSearcher searcher = buildSearcher( searchFactoryImplementor );
- if ( searcher == null ) {
- resultSize = 0;
- }
- else {
- TopDocs hits;
- try {
- hits = getQueryHits(
- searcher, 1
- ).topDocs; // Lucene enforces that at least one top doc will be retrieved.
- resultSize = hits.totalHits;
- }
- catch ( IOException e ) {
- throw new HibernateException( "Unable to query Lucene index", e );
- }
- finally {
- //searcher cannot be null
- try {
- closeSearcher( searcher, searchFactoryImplementor.getReaderProvider() );
- //searchFactoryImplementor.getReaderProvider().closeReader( searcher.getIndexReader() );
- }
- catch ( SearchException e ) {
- log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
- }
- }
- }
- }
- return this.resultSize;
- }
-
- public FullTextQuery setCriteriaQuery(Criteria criteria) {
- this.criteria = criteria;
- return this;
- }
-
- public FullTextQuery setProjection(String... fields) {
- if ( fields == null || fields.length == 0 ) {
- this.indexProjection = null;
- }
- else {
- this.indexProjection = fields;
- }
- return this;
- }
-
- public FullTextQuery setFirstResult(int firstResult) {
- if ( firstResult < 0 ) {
- throw new IllegalArgumentException( "'first' pagination parameter less than 0" );
- }
- this.firstResult = firstResult;
- return this;
- }
-
- public FullTextQuery setMaxResults(int maxResults) {
- if ( maxResults < 0 ) {
- throw new IllegalArgumentException( "'max' pagination parameter less than 0" );
- }
- this.maxResults = maxResults;
- return this;
- }
-
- public FullTextQuery setFetchSize(int fetchSize) {
- super.setFetchSize( fetchSize );
- if ( fetchSize <= 0 ) {
- throw new IllegalArgumentException( "'fetch size' parameter less than or equals to 0" );
- }
- this.fetchSize = fetchSize;
- return this;
- }
-
- @Override
- public FullTextQuery setResultTransformer(ResultTransformer transformer) {
- super.setResultTransformer( transformer );
- this.resultTransformer = transformer;
- return this;
- }
-
- public int executeUpdate() throws HibernateException {
- throw new HibernateException( "Not supported operation" );
- }
-
- public Query setLockMode(String alias, LockMode lockMode) {
- return null;
- }
-
- protected Map getLockModes() {
- return null;
- }
-
- public FullTextFilter enableFullTextFilter(String name) {
- FullTextFilterImpl filterDefinition = filterDefinitions.get( name );
- if ( filterDefinition != null ) {
- return filterDefinition;
- }
-
- filterDefinition = new FullTextFilterImpl();
- filterDefinition.setName( name );
- FilterDef filterDef = searchFactoryImplementor.getFilterDefinition( name );
- if ( filterDef == null ) {
- throw new SearchException( "Unkown @FullTextFilter: " + name );
- }
- filterDefinitions.put( name, filterDefinition );
- return filterDefinition;
- }
-
- public void disableFullTextFilter(String name) {
- filterDefinitions.remove( name );
- }
-
- private SearchFactoryImplementor getSearchFactoryImplementor() {
- if ( searchFactoryImplementor == null ) {
- searchFactoryImplementor = ContextHelper.getSearchFactoryBySFI( session );
- }
- return searchFactoryImplementor;
- }
-
- private static Loader noLoader = new Loader() {
- public void init(Session session, SearchFactoryImplementor searchFactoryImplementor) {
- }
-
- public Object load(EntityInfo entityInfo) {
- throw new UnsupportedOperationException( "noLoader should not be used" );
- }
-
- public List load(EntityInfo... entityInfos) {
- throw new UnsupportedOperationException( "noLoader should not be used" );
- }
- };
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.query;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Explanation;
+import org.apache.lucene.search.Filter;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Searcher;
+import org.apache.lucene.search.Similarity;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopDocs;
+import org.slf4j.Logger;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+import org.hibernate.Query;
+import org.hibernate.ScrollMode;
+import org.hibernate.ScrollableResults;
+import org.hibernate.Session;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.query.ParameterMetadata;
+import org.hibernate.impl.AbstractQueryImpl;
+import org.hibernate.impl.CriteriaImpl;
+import org.hibernate.search.FullTextFilter;
+import org.hibernate.search.FullTextQuery;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.engine.DocumentBuilder;
+import org.hibernate.search.engine.DocumentBuilderIndexedEntity;
+import org.hibernate.search.engine.DocumentExtractor;
+import org.hibernate.search.engine.EntityInfo;
+import org.hibernate.search.engine.FilterDef;
+import org.hibernate.search.engine.Loader;
+import org.hibernate.search.engine.MultiClassesQueryLoader;
+import org.hibernate.search.engine.ProjectionLoader;
+import org.hibernate.search.engine.QueryLoader;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.filter.ChainedFilter;
+import org.hibernate.search.filter.FilterKey;
+import org.hibernate.search.filter.StandardFilterKey;
+import org.hibernate.search.filter.FullTextFilterImplementor;
+import org.hibernate.search.filter.ShardSensitiveOnlyFilter;
+import org.hibernate.search.reader.ReaderProvider;
+import static org.hibernate.search.reader.ReaderProviderHelper.getIndexReaders;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.store.IndexShardingStrategy;
+import org.hibernate.search.util.ContextHelper;
+import static org.hibernate.search.util.FilterCacheModeTypeHelper.cacheInstance;
+import static org.hibernate.search.util.FilterCacheModeTypeHelper.cacheResults;
+import org.hibernate.search.util.LoggerFactory;
+import org.hibernate.transform.ResultTransformer;
+import org.hibernate.util.ReflectHelper;
+
+/**
+ * Implementation of {@link org.hibernate.search.FullTextQuery}.
+ *
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ * @todo Implements setParameter()
+ */
+public class FullTextQueryImpl extends AbstractQueryImpl implements FullTextQuery {
+ private static final Logger log = LoggerFactory.make();
+ private final org.apache.lucene.search.Query luceneQuery;
+ private Set<Class<?>> indexedTargetedEntities;
+ private List<Class<?>> targetedEntities;
+ private Set<Class<?>> classesAndSubclasses;
+ //optimization: if we can avoid the filter clause (we can most of the time) do it as it has a significant perf impact
+ private boolean needClassFilterClause;
+ private Integer firstResult;
+ private Integer maxResults;
+ private Integer resultSize;
+ private Sort sort;
+ private Filter filter;
+ private Filter userFilter;
+ private Criteria criteria;
+ private String[] indexProjection;
+ private Set<String> idFieldNames;
+ private boolean allowFieldSelectionInProjection = true;
+ private ResultTransformer resultTransformer;
+ private SearchFactoryImplementor searchFactoryImplementor;
+ private final Map<String, FullTextFilterImpl> filterDefinitions = new HashMap<String, FullTextFilterImpl>();
+ private int fetchSize = 1;
+ private static final FullTextFilterImplementor[] EMPTY_FULL_TEXT_FILTER_IMPLEMENTOR = new FullTextFilterImplementor[0];
+
+
+ /**
+ * Constructs a <code>FullTextQueryImpl</code> instance.
+ *
+ * @param query The Lucene query.
+ * @param classes Array of classes (must be immutable) used to filter the results to the given class types.
+ * @param session Access to the Hibernate session.
+ * @param parameterMetadata Additional query metadata.
+ */
+ public FullTextQueryImpl(org.apache.lucene.search.Query query, Class<?>[] classes, SessionImplementor session,
+ ParameterMetadata parameterMetadata) {
+ //TODO handle flushMode
+ super( query.toString(), null, session, parameterMetadata );
+ this.luceneQuery = query;
+ this.targetedEntities = Arrays.asList( classes );
+ searchFactoryImplementor = getSearchFactoryImplementor();
+ this.indexedTargetedEntities = searchFactoryImplementor.getIndexedTypesPolymorphic( classes );
+ if ( classes != null && classes.length > 0 && indexedTargetedEntities.size() == 0 ) {
+ String msg = "None of the specified entity types or any of their subclasses are indexed.";
+ throw new IllegalArgumentException( msg );
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public FullTextQuery setSort(Sort sort) {
+ this.sort = sort;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public FullTextQuery setFilter(Filter filter) {
+ this.userFilter = filter;
+ return this;
+ }
+
+ /**
+ * Return an interator on the results.
+ * Retrieve the object one by one (initialize it during the next() operation)
+ */
+ public Iterator iterate() throws HibernateException {
+ //implement an interator which keep the id/class for each hit and get the object on demand
+ //cause I can't keep the searcher and hence the hit opened. I dont have any hook to know when the
+ //user stop using it
+ //scrollable is better in this area
+
+ //find the directories
+ IndexSearcher searcher = buildSearcher( searchFactoryImplementor );
+ if ( searcher == null ) {
+ return new IteratorImpl( Collections.EMPTY_LIST, noLoader );
+ }
+ try {
+ QueryHits queryHits = getQueryHits( searcher, calculateTopDocsRetrievalSize() );
+ int first = first();
+ int max = max( first, queryHits.totalHits );
+
+ int size = max - first + 1 < 0 ? 0 : max - first + 1;
+ List<EntityInfo> infos = new ArrayList<EntityInfo>( size );
+ DocumentExtractor extractor = new DocumentExtractor(
+ queryHits, searchFactoryImplementor, indexProjection, idFieldNames, allowFieldSelectionInProjection
+ );
+ for ( int index = first; index <= max; index++ ) {
+ infos.add( extractor.extract( index ) );
+ }
+ Loader loader = getLoader();
+ return new IteratorImpl( infos, loader );
+ }
+ catch ( IOException e ) {
+ throw new HibernateException( "Unable to query Lucene index", e );
+ }
+ finally {
+ try {
+ closeSearcher( searcher, searchFactoryImplementor.getReaderProvider() );
+ }
+ catch ( SearchException e ) {
+ log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
+ }
+ }
+ }
+
+ /**
+ * Decide which object loader to use depending on the targeted entities. If there is only a single entity targeted
+ * a <code>QueryLoader</code> can be used which will only execute a single query to load the entities. If more than
+ * one entity is targeted a <code>MultiClassesQueryLoader</code> must be used. We also have to consider whether
+ * projections or <code>Criteria</code> are used.
+ *
+ * @return The loader instance to use to load the results of the query.
+ */
+ private Loader getLoader() {
+ Loader loader;
+ if ( indexProjection != null ) {
+ loader = getProjectionLoader();
+ }
+ else if ( criteria != null ) {
+ loader = getCriteriaLoader();
+ }
+ else if ( targetedEntities.size() == 1 ) {
+ loader = getSingleEntityLoader();
+ }
+ else {
+ loader = getMultipleEntitiesLoader();
+ }
+ return loader;
+ }
+
+ private Loader getMultipleEntitiesLoader() {
+ final MultiClassesQueryLoader multiClassesLoader = new MultiClassesQueryLoader();
+ multiClassesLoader.init( ( Session ) session, searchFactoryImplementor );
+ multiClassesLoader.setEntityTypes( indexedTargetedEntities );
+ return multiClassesLoader;
+ }
+
+ private Loader getSingleEntityLoader() {
+ final QueryLoader queryLoader = new QueryLoader();
+ queryLoader.init( ( Session ) session, searchFactoryImplementor );
+ queryLoader.setEntityType( targetedEntities.iterator().next() );
+ return queryLoader;
+ }
+
+ private Loader getCriteriaLoader() {
+ if ( targetedEntities.size() > 1 ) {
+ throw new SearchException( "Cannot mix criteria and multiple entity types" );
+ }
+ Class entityType = targetedEntities.size() == 0 ? null : targetedEntities.iterator().next();
+ if ( criteria instanceof CriteriaImpl ) {
+ String targetEntity = ( ( CriteriaImpl ) criteria ).getEntityOrClassName();
+ if ( entityType != null && !entityType.getName().equals( targetEntity ) ) {
+ throw new SearchException( "Criteria query entity should match query entity" );
+ }
+ else {
+ try {
+ entityType = ReflectHelper.classForName( targetEntity );
+ }
+ catch ( ClassNotFoundException e ) {
+ throw new SearchException( "Unable to load entity class from criteria: " + targetEntity, e );
+ }
+ }
+ }
+ QueryLoader queryLoader = new QueryLoader();
+ queryLoader.init( ( Session ) session, searchFactoryImplementor );
+ queryLoader.setEntityType( entityType );
+ queryLoader.setCriteria( criteria );
+ return queryLoader;
+ }
+
+ private Loader getProjectionLoader() {
+ ProjectionLoader loader = new ProjectionLoader();
+ loader.init( ( Session ) session, searchFactoryImplementor, resultTransformer, indexProjection );
+ loader.setEntityTypes( indexedTargetedEntities );
+ return loader;
+ }
+
+ public ScrollableResults scroll() throws HibernateException {
+ //keep the searcher open until the resultset is closed
+
+ //find the directories
+ IndexSearcher searcher = buildSearcher( searchFactoryImplementor );
+ //FIXME: handle null searcher
+ try {
+ QueryHits queryHits = getQueryHits( searcher, calculateTopDocsRetrievalSize() );
+ int first = first();
+ int max = max( first, queryHits.totalHits );
+ DocumentExtractor extractor = new DocumentExtractor(
+ queryHits, searchFactoryImplementor, indexProjection, idFieldNames, allowFieldSelectionInProjection
+ );
+ Loader loader = getLoader();
+ return new ScrollableResultsImpl(
+ searcher, first, max, fetchSize, extractor, loader, searchFactoryImplementor, this.session
+ );
+ }
+ catch ( IOException e ) {
+ //close only in case of exception
+ try {
+ closeSearcher( searcher, searchFactoryImplementor.getReaderProvider() );
+ }
+ catch ( SearchException ee ) {
+ //we have the initial issue already
+ }
+ throw new HibernateException( "Unable to query Lucene index", e );
+ }
+ }
+
+ public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException {
+ //TODO think about this scrollmode
+ return scroll();
+ }
+
+ public List list() throws HibernateException {
+ //find the directories
+ IndexSearcher searcher = buildSearcher( searchFactoryImplementor );
+ if ( searcher == null ) {
+ return Collections.EMPTY_LIST;
+ }
+ try {
+ QueryHits queryHits = getQueryHits( searcher, calculateTopDocsRetrievalSize() );
+ int first = first();
+ int max = max( first, queryHits.totalHits );
+
+ int size = max - first + 1 < 0 ? 0 : max - first + 1;
+ List<EntityInfo> infos = new ArrayList<EntityInfo>( size );
+ DocumentExtractor extractor = new DocumentExtractor(
+ queryHits, searchFactoryImplementor, indexProjection, idFieldNames, allowFieldSelectionInProjection
+ );
+ for ( int index = first; index <= max; index++ ) {
+ infos.add( extractor.extract( index ) );
+ }
+ Loader loader = getLoader();
+ List list = loader.load( infos.toArray( new EntityInfo[infos.size()] ) );
+ if ( resultTransformer == null || loader instanceof ProjectionLoader ) {
+ //stay consistent with transformTuple which can only be executed during a projection
+ return list;
+ }
+ else {
+ return resultTransformer.transformList( list );
+ }
+ }
+ catch ( IOException e ) {
+ throw new HibernateException( "Unable to query Lucene index", e );
+ }
+ finally {
+ try {
+ closeSearcher( searcher, searchFactoryImplementor.getReaderProvider() );
+ }
+ catch ( SearchException e ) {
+ log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
+ }
+ }
+ }
+
+ public Explanation explain(int documentId) {
+ Explanation explanation = null;
+ Searcher searcher = buildSearcher( searchFactoryImplementor );
+ if ( searcher == null ) {
+ throw new SearchException(
+ "Unable to build explanation for document id:"
+ + documentId + ". no index found"
+ );
+ }
+ try {
+ org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
+ buildFilters();
+ explanation = searcher.explain( query, documentId );
+ }
+ catch ( IOException e ) {
+ throw new HibernateException( "Unable to query Lucene index and build explanation", e );
+ }
+ finally {
+ //searcher cannot be null
+ try {
+ closeSearcher( searcher, searchFactoryImplementor.getReaderProvider() );
+ }
+ catch ( SearchException e ) {
+ log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
+ }
+ }
+ return explanation;
+ }
+
+ /**
+ * Execute the lucene search and return the matching hits.
+ *
+ * @param searcher The index searcher.
+ * @param n Numer of documents to retrieve
+ *
+ * @return An instance of <code>QueryHits</code> wrapping the Lucene query and the matching documents.
+ *
+ * @throws IOException in case there is an error executing the lucene search.
+ */
+ private QueryHits getQueryHits(Searcher searcher, Integer n) throws IOException {
+ org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
+ buildFilters();
+ QueryHits queryHits;
+ if ( n == null ) { // try to make sure that we get the right amount of top docs
+ queryHits = new QueryHits( searcher, query, filter, sort );
+ }
+ else {
+ queryHits = new QueryHits( searcher, query, filter, sort, n );
+ }
+ resultSize = queryHits.totalHits;
+ return queryHits;
+ }
+
+ /**
+ * @return Calculates the number of <code>TopDocs</code> which should be retrieved as part of the query. If Hibernate's
+ * pagination parameters are set returned value is <code>first + maxResults</code>. Otherwise <code>null</code> is
+ * returned.
+ */
+ private Integer calculateTopDocsRetrievalSize() {
+ if ( maxResults == null ) {
+ return null;
+ }
+ else {
+ long tmpMaxResult = ( long ) first() + maxResults;
+ if ( tmpMaxResult >= Integer.MAX_VALUE ) {
+ // don't return just Integer.MAX_VALUE due to a bug in Lucene - see HSEARCH-330
+ return Integer.MAX_VALUE - 1;
+ }
+ else {
+ return ( int ) tmpMaxResult;
+ }
+ }
+ }
+
+ private void buildFilters() {
+ ChainedFilter chainedFilter = null;
+ if ( ! filterDefinitions.isEmpty() ) {
+ chainedFilter = new ChainedFilter();
+ for ( FullTextFilterImpl fullTextFilter : filterDefinitions.values() ) {
+ Filter filter = buildLuceneFilter( fullTextFilter );
+ if (filter != null) chainedFilter.addFilter( filter );
+ }
+ }
+
+ if ( userFilter != null ) {
+ //chainedFilter is not always necessary here but the code is easier to read
+ if (chainedFilter == null) chainedFilter = new ChainedFilter();
+ chainedFilter.addFilter( userFilter );
+ }
+
+ if ( chainedFilter == null || chainedFilter.isEmpty() ) {
+ filter = null;
+ }
+ else {
+ filter = chainedFilter;
+ }
+ }
+
+ /**
+ * Builds a Lucene filter using the given <code>FullTextFilter</code>.
+ *
+ * @param fullTextFilter the Hibernate specific <code>FullTextFilter</code> used to create the
+ * Lucene <code>Filter</code>.
+ *
+ * @return the Lucene filter mapped to the filter definition
+ */
+ private Filter buildLuceneFilter(FullTextFilterImpl fullTextFilter) {
+
+ /*
+ * FilterKey implementations and Filter(Factory) do not have to be threadsafe wrt their parameter injection
+ * as FilterCachingStrategy ensure a memory barrier between concurrent thread calls
+ */
+ FilterDef def = searchFactoryImplementor.getFilterDefinition( fullTextFilter.getName() );
+ //def can never be null, ti's guarded by enableFullTextFilter(String)
+
+ if ( isPreQueryFilterOnly(def) ) return null;
+
+ Object instance = createFilterInstance( fullTextFilter, def );
+ FilterKey key = createFilterKey( def, instance );
+
+ // try to get the filter out of the cache
+ Filter filter = cacheInstance( def.getCacheMode() ) ?
+ searchFactoryImplementor.getFilterCachingStrategy().getCachedFilter( key ) :
+ null;
+
+ if ( filter == null ) {
+ filter = createFilter( def, instance );
+
+ // add filter to cache if we have to
+ if ( cacheInstance( def.getCacheMode() ) ) {
+ searchFactoryImplementor.getFilterCachingStrategy().addCachedFilter( key, filter );
+ }
+ }
+ return filter;
+ }
+
+ private boolean isPreQueryFilterOnly(FilterDef def) {
+ return def.getImpl().equals( ShardSensitiveOnlyFilter.class );
+ }
+
+ private Filter createFilter(FilterDef def, Object instance) {
+ Filter filter;
+ if ( def.getFactoryMethod() != null ) {
+ try {
+ filter = ( Filter ) def.getFactoryMethod().invoke( instance );
+ }
+ catch ( IllegalAccessException e ) {
+ throw new SearchException(
+ "Unable to access @Factory method: "
+ + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
+ );
+ }
+ catch ( InvocationTargetException e ) {
+ throw new SearchException(
+ "Unable to access @Factory method: "
+ + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
+ );
+ }
+ catch ( ClassCastException e ) {
+ throw new SearchException(
+ "@Key method does not return a org.apache.lucene.search.Filter class: "
+ + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
+ );
+ }
+ }
+ else {
+ try {
+ filter = ( Filter ) instance;
+ }
+ catch ( ClassCastException e ) {
+ throw new SearchException(
+ "Filter implementation does not implement the Filter interface: "
+ + def.getImpl().getName() + ". "
+ + ( def.getFactoryMethod() != null ? def.getFactoryMethod().getName() : "" ), e
+ );
+ }
+ }
+
+ filter = addCachingWrapperFilter( filter, def );
+ return filter;
+ }
+
+ /**
+ * Decides whether to wrap the given filter around a <code>CachingWrapperFilter<code>.
+ *
+ * @param filter the filter which maybe gets wrapped.
+ * @param def The filter definition used to decide whether wrapping should occur or not.
+ *
+ * @return The original filter or wrapped filter depending on the information extracted from
+ * <code>def</code>.
+ */
+ private Filter addCachingWrapperFilter(Filter filter, FilterDef def) {
+ if ( cacheResults( def.getCacheMode() ) ) {
+ int cachingWrapperFilterSize = searchFactoryImplementor.getFilterCacheBitResultsSize();
+ filter = new org.hibernate.search.filter.CachingWrapperFilter( filter, cachingWrapperFilterSize );
+ }
+
+ return filter;
+ }
+
+ private FilterKey createFilterKey(FilterDef def, Object instance) {
+ FilterKey key = null;
+ if ( !cacheInstance( def.getCacheMode() ) ) {
+ return key; // if the filter is not cached there is no key!
+ }
+
+ if ( def.getKeyMethod() == null ) {
+ key = new FilterKey() {
+ public int hashCode() {
+ return getImpl().hashCode();
+ }
+
+ public boolean equals(Object obj) {
+ if ( !( obj instanceof FilterKey ) ) {
+ return false;
+ }
+ FilterKey that = ( FilterKey ) obj;
+ return this.getImpl().equals( that.getImpl() );
+ }
+ };
+ }
+ else {
+ try {
+ key = ( FilterKey ) def.getKeyMethod().invoke( instance );
+ }
+ catch ( IllegalAccessException e ) {
+ throw new SearchException(
+ "Unable to access @Key method: "
+ + def.getImpl().getName() + "." + def.getKeyMethod().getName()
+ );
+ }
+ catch ( InvocationTargetException e ) {
+ throw new SearchException(
+ "Unable to access @Key method: "
+ + def.getImpl().getName() + "." + def.getKeyMethod().getName()
+ );
+ }
+ catch ( ClassCastException e ) {
+ throw new SearchException(
+ "@Key method does not return FilterKey: "
+ + def.getImpl().getName() + "." + def.getKeyMethod().getName()
+ );
+ }
+ }
+ key.setImpl( def.getImpl() );
+
+ //Make sure Filters are isolated by filter def name
+ StandardFilterKey wrapperKey = new StandardFilterKey();
+ wrapperKey.addParameter( def.getName() );
+ wrapperKey.addParameter( key );
+ return wrapperKey;
+ }
+
+ private Object createFilterInstance(FullTextFilterImpl fullTextFilter,
+ FilterDef def) {
+ Object instance;
+ try {
+ instance = def.getImpl().newInstance();
+ }
+ catch ( InstantiationException e ) {
+ throw new SearchException( "Unable to create @FullTextFilterDef: " + def.getImpl(), e );
+ }
+ catch ( IllegalAccessException e ) {
+ throw new SearchException( "Unable to create @FullTextFilterDef: " + def.getImpl(), e );
+ }
+ for ( Map.Entry<String, Object> entry : fullTextFilter.getParameters().entrySet() ) {
+ def.invoke( entry.getKey(), instance, entry.getValue() );
+ }
+ if ( cacheInstance( def.getCacheMode() ) && def.getKeyMethod() == null && fullTextFilter.getParameters()
+ .size() > 0 ) {
+ throw new SearchException( "Filter with parameters and no @Key method: " + fullTextFilter.getName() );
+ }
+ return instance;
+ }
+
+ private org.apache.lucene.search.Query filterQueryByClasses(org.apache.lucene.search.Query luceneQuery) {
+ if ( !needClassFilterClause ) {
+ return luceneQuery;
+ }
+ else {
+ //A query filter is more practical than a manual class filtering post query (esp on scrollable resultsets)
+ //it also probably minimise the memory footprint
+ BooleanQuery classFilter = new BooleanQuery();
+ //annihilate the scoring impact of DocumentBuilderIndexedEntity.CLASS_FIELDNAME
+ classFilter.setBoost( 0 );
+ for ( Class clazz : classesAndSubclasses ) {
+ Term t = new Term( DocumentBuilder.CLASS_FIELDNAME, clazz.getName() );
+ TermQuery termQuery = new TermQuery( t );
+ classFilter.add( termQuery, BooleanClause.Occur.SHOULD );
+ }
+ BooleanQuery filteredQuery = new BooleanQuery();
+ filteredQuery.add( luceneQuery, BooleanClause.Occur.MUST );
+ filteredQuery.add( classFilter, BooleanClause.Occur.MUST );
+ return filteredQuery;
+ }
+ }
+
+ private int max(int first, int totalHits) {
+ if ( maxResults == null ) {
+ return totalHits - 1;
+ }
+ else {
+ return maxResults + first < totalHits ?
+ first + maxResults - 1 :
+ totalHits - 1;
+ }
+ }
+
+ private int first() {
+ return firstResult != null ?
+ firstResult :
+ 0;
+ }
+
+ /**
+ * Build the index searcher for this fulltext query.
+ *
+ * @param searchFactoryImplementor the search factory.
+ *
+ * @return the <code>IndexSearcher</code> for this query (can be <code>null</code>.
+ * TODO change classesAndSubclasses by side effect, which is a mismatch with the Searcher return, fix that.
+ */
+ private IndexSearcher buildSearcher(SearchFactoryImplementor searchFactoryImplementor) {
+ Map<Class<?>, DocumentBuilderIndexedEntity<?>> builders = searchFactoryImplementor.getDocumentBuildersIndexedEntities();
+ List<DirectoryProvider> targetedDirectories = new ArrayList<DirectoryProvider>();
+ Set<String> idFieldNames = new HashSet<String>();
+
+ Similarity searcherSimilarity = null;
+ //TODO check if caching this work for the last n list of indexedTargetedEntities makes a perf boost
+ if ( indexedTargetedEntities.size() == 0 ) {
+ // empty indexedTargetedEntities array means search over all indexed enities,
+ // but we have to make sure there is at least one
+ if ( builders.isEmpty() ) {
+ throw new HibernateException(
+ "There are no mapped entities. Don't forget to add @Indexed to at least one class."
+ );
+ }
+
+ for ( DocumentBuilderIndexedEntity builder : builders.values() ) {
+ searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
+ if ( builder.getIdKeywordName() != null ) {
+ idFieldNames.add( builder.getIdKeywordName() );
+ allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
+ }
+ populateDirectories( targetedDirectories, builder );
+ }
+ classesAndSubclasses = null;
+ }
+ else {
+ Set<Class<?>> involvedClasses = new HashSet<Class<?>>( indexedTargetedEntities.size() );
+ involvedClasses.addAll( indexedTargetedEntities );
+ for ( Class<?> clazz : indexedTargetedEntities ) {
+ DocumentBuilderIndexedEntity<?> builder = builders.get( clazz );
+ if ( builder != null ) {
+ involvedClasses.addAll( builder.getMappedSubclasses() );
+ }
+ }
+
+ for ( Class clazz : involvedClasses ) {
+ DocumentBuilderIndexedEntity builder = builders.get( clazz );
+ //TODO should we rather choose a polymorphic path and allow non mapped entities
+ if ( builder == null ) {
+ throw new HibernateException( "Not a mapped entity (don't forget to add @Indexed): " + clazz );
+ }
+ if ( builder.getIdKeywordName() != null ) {
+ idFieldNames.add( builder.getIdKeywordName() );
+ allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
+ }
+ searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
+ populateDirectories( targetedDirectories, builder );
+ }
+ this.classesAndSubclasses = involvedClasses;
+ }
+ this.idFieldNames = idFieldNames;
+
+ //compute optimization needClassFilterClause
+ //if at least one DP contains one class that is not part of the targeted classesAndSubclasses we can't optimize
+ if ( classesAndSubclasses != null ) {
+ for ( DirectoryProvider dp : targetedDirectories ) {
+ final Set<Class<?>> classesInDirectoryProvider = searchFactoryImplementor.getClassesInDirectoryProvider(
+ dp
+ );
+ // if a DP contains only one class, we know for sure it's part of classesAndSubclasses
+ if ( classesInDirectoryProvider.size() > 1 ) {
+ //risk of needClassFilterClause
+ for ( Class clazz : classesInDirectoryProvider ) {
+ if ( !classesAndSubclasses.contains( clazz ) ) {
+ this.needClassFilterClause = true;
+ break;
+ }
+ }
+ }
+ if ( this.needClassFilterClause ) {
+ break;
+ }
+ }
+ }
+
+ //set up the searcher
+ final DirectoryProvider[] directoryProviders = targetedDirectories.toArray( new DirectoryProvider[targetedDirectories.size()] );
+ IndexSearcher is = new IndexSearcher(
+ searchFactoryImplementor.getReaderProvider().openReader(
+ directoryProviders
+ )
+ );
+ is.setSimilarity( searcherSimilarity );
+ return is;
+ }
+
+ private void populateDirectories(List<DirectoryProvider> directories, DocumentBuilderIndexedEntity builder) {
+ final IndexShardingStrategy indexShardingStrategy = builder.getDirectoryProviderSelectionStrategy();
+ final DirectoryProvider[] directoryProviders;
+ if ( filterDefinitions != null && !filterDefinitions.isEmpty() ) {
+ directoryProviders = indexShardingStrategy.getDirectoryProvidersForQuery(
+ filterDefinitions.values().toArray( new FullTextFilterImplementor[filterDefinitions.size()] )
+ );
+ }
+ else {
+ //no filter get all shards
+ directoryProviders = indexShardingStrategy.getDirectoryProvidersForQuery( EMPTY_FULL_TEXT_FILTER_IMPLEMENTOR );
+ }
+
+ for ( DirectoryProvider provider : directoryProviders ) {
+ if ( !directories.contains( provider ) ) {
+ directories.add( provider );
+ }
+ }
+ }
+
+ private Similarity checkSimilarity(Similarity similarity, DocumentBuilderIndexedEntity builder) {
+ if ( similarity == null ) {
+ similarity = builder.getSimilarity();
+ }
+ else if ( !similarity.getClass().equals( builder.getSimilarity().getClass() ) ) {
+ throw new HibernateException(
+ "Cannot perform search on two entities with differing Similarity implementations (" + similarity.getClass()
+ .getName() + " & " + builder.getSimilarity().getClass().getName() + ")"
+ );
+ }
+
+ return similarity;
+ }
+
+ private void closeSearcher(Searcher searcher, ReaderProvider readerProvider) {
+ Set<IndexReader> indexReaders = getIndexReaders( searcher );
+
+ for ( IndexReader indexReader : indexReaders ) {
+ readerProvider.closeReader( indexReader );
+ }
+ }
+
+ public int getResultSize() {
+ if ( resultSize == null ) {
+ //get result size without object initialization
+ IndexSearcher searcher = buildSearcher( searchFactoryImplementor );
+ if ( searcher == null ) {
+ resultSize = 0;
+ }
+ else {
+ TopDocs hits;
+ try {
+ hits = getQueryHits(
+ searcher, 1
+ ).topDocs; // Lucene enforces that at least one top doc will be retrieved.
+ resultSize = hits.totalHits;
+ }
+ catch ( IOException e ) {
+ throw new HibernateException( "Unable to query Lucene index", e );
+ }
+ finally {
+ //searcher cannot be null
+ try {
+ closeSearcher( searcher, searchFactoryImplementor.getReaderProvider() );
+ //searchFactoryImplementor.getReaderProvider().closeReader( searcher.getIndexReader() );
+ }
+ catch ( SearchException e ) {
+ log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
+ }
+ }
+ }
+ }
+ return this.resultSize;
+ }
+
+ public FullTextQuery setCriteriaQuery(Criteria criteria) {
+ this.criteria = criteria;
+ return this;
+ }
+
+ public FullTextQuery setProjection(String... fields) {
+ if ( fields == null || fields.length == 0 ) {
+ this.indexProjection = null;
+ }
+ else {
+ this.indexProjection = fields;
+ }
+ return this;
+ }
+
+ public FullTextQuery setFirstResult(int firstResult) {
+ if ( firstResult < 0 ) {
+ throw new IllegalArgumentException( "'first' pagination parameter less than 0" );
+ }
+ this.firstResult = firstResult;
+ return this;
+ }
+
+ public FullTextQuery setMaxResults(int maxResults) {
+ if ( maxResults < 0 ) {
+ throw new IllegalArgumentException( "'max' pagination parameter less than 0" );
+ }
+ this.maxResults = maxResults;
+ return this;
+ }
+
+ public FullTextQuery setFetchSize(int fetchSize) {
+ super.setFetchSize( fetchSize );
+ if ( fetchSize <= 0 ) {
+ throw new IllegalArgumentException( "'fetch size' parameter less than or equals to 0" );
+ }
+ this.fetchSize = fetchSize;
+ return this;
+ }
+
+ @Override
+ public FullTextQuery setResultTransformer(ResultTransformer transformer) {
+ super.setResultTransformer( transformer );
+ this.resultTransformer = transformer;
+ return this;
+ }
+
+ public int executeUpdate() throws HibernateException {
+ throw new HibernateException( "Not supported operation" );
+ }
+
+ public Query setLockMode(String alias, LockMode lockMode) {
+ return null;
+ }
+
+ protected Map getLockModes() {
+ return null;
+ }
+
+ public FullTextFilter enableFullTextFilter(String name) {
+ FullTextFilterImpl filterDefinition = filterDefinitions.get( name );
+ if ( filterDefinition != null ) {
+ return filterDefinition;
+ }
+
+ filterDefinition = new FullTextFilterImpl();
+ filterDefinition.setName( name );
+ FilterDef filterDef = searchFactoryImplementor.getFilterDefinition( name );
+ if ( filterDef == null ) {
+ throw new SearchException( "Unkown @FullTextFilter: " + name );
+ }
+ filterDefinitions.put( name, filterDefinition );
+ return filterDefinition;
+ }
+
+ public void disableFullTextFilter(String name) {
+ filterDefinitions.remove( name );
+ }
+
+ private SearchFactoryImplementor getSearchFactoryImplementor() {
+ if ( searchFactoryImplementor == null ) {
+ searchFactoryImplementor = ContextHelper.getSearchFactoryBySFI( session );
+ }
+ return searchFactoryImplementor;
+ }
+
+ private static Loader noLoader = new Loader() {
+ public void init(Session session, SearchFactoryImplementor searchFactoryImplementor) {
+ }
+
+ public Object load(EntityInfo entityInfo) {
+ throw new UnsupportedOperationException( "noLoader should not be used" );
+ }
+
+ public List load(EntityInfo... entityInfos) {
+ throw new UnsupportedOperationException( "noLoader should not be used" );
+ }
+ };
+}
Modified: search/trunk/src/main/java/org/hibernate/search/query/IteratorImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/query/IteratorImpl.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/query/IteratorImpl.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,64 +1,87 @@
-//$Id$
-package org.hibernate.search.query;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import org.hibernate.search.engine.Loader;
-import org.hibernate.search.engine.EntityInfo;
-
-/**
- * @author Emmanuel Bernard
- */
-//TODO load the next batch-size elements to benefit from batch-size
-public class IteratorImpl implements Iterator {
-
- private final List<EntityInfo> entityInfos;
- private int index = 0;
- private final int size;
- private Object next;
- private int nextObjectIndex = -1;
- private final Loader loader;
-
- public IteratorImpl(List<EntityInfo> entityInfos, Loader loader) {
- this.entityInfos = entityInfos;
- this.size = entityInfos.size();
- this.loader = loader;
- }
-
- //side effect is to set up next
- public boolean hasNext() {
- if ( nextObjectIndex == index ) return next != null;
- next = null;
- nextObjectIndex = -1;
- do {
- if ( index >= size ) {
- nextObjectIndex = index;
- next = null;
- return false;
- }
- next = loader.load( entityInfos.get( index ) );
- if ( next == null ) {
- index++;
- }
- else {
- nextObjectIndex = index;
- }
- }
- while ( next == null );
- return true;
- }
-
- public Object next() {
- //hasNext() has side effect
- if ( !hasNext() ) throw new NoSuchElementException( "Out of boundaries" );
- index++;
- return next;
- }
-
- public void remove() {
- //TODO this is theoretically doable
- throw new UnsupportedOperationException( "Cannot remove from a lucene query iterator" );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.query;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.hibernate.search.engine.Loader;
+import org.hibernate.search.engine.EntityInfo;
+
+/**
+ * @author Emmanuel Bernard
+ */
+//TODO load the next batch-size elements to benefit from batch-size
+public class IteratorImpl implements Iterator {
+
+ private final List<EntityInfo> entityInfos;
+ private int index = 0;
+ private final int size;
+ private Object next;
+ private int nextObjectIndex = -1;
+ private final Loader loader;
+
+ public IteratorImpl(List<EntityInfo> entityInfos, Loader loader) {
+ this.entityInfos = entityInfos;
+ this.size = entityInfos.size();
+ this.loader = loader;
+ }
+
+ //side effect is to set up next
+ public boolean hasNext() {
+ if ( nextObjectIndex == index ) return next != null;
+ next = null;
+ nextObjectIndex = -1;
+ do {
+ if ( index >= size ) {
+ nextObjectIndex = index;
+ next = null;
+ return false;
+ }
+ next = loader.load( entityInfos.get( index ) );
+ if ( next == null ) {
+ index++;
+ }
+ else {
+ nextObjectIndex = index;
+ }
+ }
+ while ( next == null );
+ return true;
+ }
+
+ public Object next() {
+ //hasNext() has side effect
+ if ( !hasNext() ) throw new NoSuchElementException( "Out of boundaries" );
+ index++;
+ return next;
+ }
+
+ public void remove() {
+ //TODO this is theoretically doable
+ throw new UnsupportedOperationException( "Cannot remove from a lucene query iterator" );
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/query/QueryHits.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/query/QueryHits.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/query/QueryHits.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.query;
import java.io.IOException;
Modified: search/trunk/src/main/java/org/hibernate/search/query/ScrollableResultsImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/query/ScrollableResultsImpl.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/query/ScrollableResultsImpl.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,471 +1,494 @@
-//$Id$
-package org.hibernate.search.query;
-
-import java.io.IOException;
-import java.lang.ref.Reference;
-import java.lang.ref.SoftReference;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.TimeZone;
-
-import org.apache.lucene.search.IndexSearcher;
-import org.slf4j.Logger;
-
-import org.hibernate.HibernateException;
-import org.hibernate.ScrollableResults;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.search.SearchException;
-import org.hibernate.search.SearchFactory;
-import org.hibernate.search.engine.DocumentExtractor;
-import org.hibernate.search.engine.EntityInfo;
-import org.hibernate.search.engine.Loader;
-import org.hibernate.search.util.LoggerFactory;
-import org.hibernate.type.Type;
-
-/**
- * Implements scrollable and paginated resultsets.
- * Contrary to Query#iterate() or Query#list(), this implementation is
- * exposed to returned null objects (if the index is out of date).
- * <p/>
- * <p/>
- * The following methods that change the value of 'current' will check
- * and set its value to either 'afterLast' or 'beforeFirst' depending
- * on direction. This is to prevent rogue values from setting it outside
- * the boundaries of the results.
- * <ul>
- * <li>next()</li>
- * <li>previous()</li>
- * <li>scroll(i)</li>
- * <li>last()</li>
- * <li>first()</li>
- * </ul>
- *
- * @see org.hibernate.Query
- *
- * @author Emmanuel Bernard
- * @author John Griffin
- * @author Sanne Grinovero
- */
-public class ScrollableResultsImpl implements ScrollableResults {
-
- private static final Logger log = LoggerFactory.make();
-
- private final SearchFactory searchFactory;
- private final IndexSearcher searcher;
- private final int first;
- private final int max;
- private final int fetchSize;
- private final Loader loader;
- private final DocumentExtractor documentExtractor;
- private final SessionImplementor session;
-
- /**
- * Caches result rows and EntityInfo from
- * <code>first</code> to <code>max</code>
- */
- private final LoadedObject[] resultsContext;
-
- private int current;
-
- public ScrollableResultsImpl( IndexSearcher searcher, int first, int max, int fetchSize, DocumentExtractor extractor,
- Loader loader, SearchFactory searchFactory, SessionImplementor sessionImplementor
- ) {
- this.searchFactory = searchFactory;
- this.searcher = searcher;
- this.first = first;
- this.max = max;
- this.loader = loader;
- this.documentExtractor = extractor;
- this.fetchSize = fetchSize;
- this.session = sessionImplementor;
- int size = Math.max( max - first + 1, 0 );
- this.resultsContext = new LoadedObject[size];
- beforeFirst();
- }
-
- private LoadedObject ensureCurrentLoaded() {
- LoadedObject currentCacheRef = resultsContext[current - first];
- if ( currentCacheRef != null ) {
- return currentCacheRef;
- }
- // the loading window is optimized for scrolling in both directions:
- int windowStop = Math.min( max + 1 , current + fetchSize );
- int windowStart = Math.max( first, current - fetchSize + 1 );
- List<EntityInfo> entityInfosToLoad = new ArrayList<EntityInfo>( fetchSize );
- int sizeToLoad = 0;
- for (int x = windowStart; x < windowStop; x++) {
- int arrayIdx = x - first;
- LoadedObject lo = resultsContext[arrayIdx];
- if ( lo == null ) {
- lo = new LoadedObject();
- // makes hard references and extract EntityInfos:
- entityInfosToLoad.add( lo.getEntityInfo( x ) );
- resultsContext[arrayIdx] = lo;
- sizeToLoad++;
- if ( sizeToLoad >= fetchSize )
- break;
- }
- }
- //preload efficiently by batches:
- if ( sizeToLoad > 1 ) {
- loader.load( entityInfosToLoad.toArray( new EntityInfo[sizeToLoad] ) );
- //(no references stored at this point: they still need to be loaded one by one to inject null results)
- }
- return resultsContext[ current - first ];
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean next() {
- // Increases cursor pointer by one. If this places it >
- // max + 1 (afterLast) then set it to afterLast and return
- // false.
- if ( ++current > max ) {
- afterLast();
- return false;
- }
- return true;
- }
-
- public boolean previous() {
- // Decreases cursor pointer by one. If this places it <
- // first - 1 (beforeFirst) then set it to beforeFirst and
- // return false.
- if ( --current < first ) {
- beforeFirst();
- return false;
- }
- return true;
- }
-
- public boolean scroll(int i) {
- // Since we have to take into account that we can scroll any
- // amount positive or negative, we perform the same tests that
- // we performed in next() and previous().
- current = current + i;
- if ( current > max ) {
- afterLast();
- return false;
- }
- else if ( current < first ) {
- beforeFirst();
- return false;
- }
- else {
- return true;
- }
- }
-
- public boolean last() {
- current = max;
- if ( current < first ) {
- beforeFirst();
- return false;
- }
- return max >= first;
- }
-
- public boolean first() {
- current = first;
- if ( current > max ) {
- afterLast();
- return false;
- }
- return max >= first;
- }
-
- public void beforeFirst() {
- current = first - 1;
- }
-
- public void afterLast() {
- current = max + 1;
- //TODO help gc by clearing all structures when using forwardonly scrollmode.
- }
-
- public boolean isFirst() {
- return current == first;
- }
-
- public boolean isLast() {
- return current == max;
- }
-
- public void close() {
- try {
- searchFactory.getReaderProvider().closeReader( searcher.getIndexReader() );
- }
- catch (SearchException e) {
- log.warn( "Unable to properly close searcher in ScrollableResults", e );
- }
- }
-
- public Object[] get() throws HibernateException {
- // don't throw an exception here just
- // return 'null' this is similar to the
- // RowSet spec in JDBC. It returns false
- // (or 0 I can't remember) but we can't
- // do that since we have to make up for
- // an Object[]. J.G
- if ( current < first || current > max ) return null;
- LoadedObject cacheEntry = ensureCurrentLoaded();
- return cacheEntry.getManagedResult( current );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Object get(int i) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Type getType(int i) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Integer getInteger(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Long getLong(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Float getFloat(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Boolean getBoolean(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Double getDouble(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Short getShort(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Byte getByte(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Character getCharacter(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public byte[] getBinary(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public String getText(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Blob getBlob(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Clob getClob(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public String getString(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public BigDecimal getBigDecimal(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public BigInteger getBigInteger(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Date getDate(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Locale getLocale(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public Calendar getCalendar(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- /**
- * This method is not supported on Lucene based queries
- * @throws UnsupportedOperationException always thrown
- */
- public TimeZone getTimeZone(int col) {
- throw new UnsupportedOperationException( "Lucene does not work on columns" );
- }
-
- public int getRowNumber() {
- if ( max < first ) return -1;
- return current - first;
- }
-
- public boolean setRowNumber(int rowNumber) {
- if ( rowNumber >= 0 ) {
- current = first + rowNumber;
- }
- else {
- current = max + rowNumber + 1; //max row start at -1
- }
- return current >= first && current <= max;
- }
-
- private final class LoadedObject {
-
- private Reference<Object[]> entity; //never==null but Reference.get can return null
- private Reference<EntityInfo> einfo; //never==null but Reference.get can return null
-
- /**
- * Gets the objects from cache if it is available and attached to session,
- * or reload them and update the cache entry.
- * @param x absolute position in fulltext result.
- * @return the managed objects
- */
- private Object[] getManagedResult(int x) {
- EntityInfo entityInfo = getEntityInfo( x );
- Object[] objects = entity==null ? null : entity.get();
- if ( objects!=null && areAllEntitiesManaged( objects, entityInfo ) ) {
- return objects;
- }
- else {
- Object loaded = loader.load( entityInfo );
- if ( ! loaded.getClass().isArray() ) loaded = new Object[] { loaded };
- objects = (Object[]) loaded;
- this.entity = new SoftReference<Object[]>( objects );
- return objects;
- }
- }
-
- /**
- * Extract an entityInfo, either from cache or from the index.
- * @param x the position in the index.
- * @return
- */
- private EntityInfo getEntityInfo(int x) {
- EntityInfo entityInfo = einfo==null ? null : einfo.get();
- if ( entityInfo==null ) {
- try {
- entityInfo = documentExtractor.extract( x );
- }
- catch (IOException e) {
- throw new SearchException( "Unable to read Lucene topDocs[" + x + "]", e );
- }
- einfo = new SoftReference<EntityInfo>( entityInfo );
- }
- return entityInfo;
- }
-
- }
-
- private boolean areAllEntitiesManaged(Object[] objects, EntityInfo entityInfo) {
- //check if all entities are session-managed and skip the check on projected values
- org.hibernate.Session hibSession = (org.hibernate.Session) session;
- if ( entityInfo.projection != null ) {
- // using projection: test only for entities
- for ( int idx : entityInfo.indexesOfThis ) {
- Object o = objects[idx];
- //TODO improve: is it useful to check for proxies and have them reassociated to persistence context?
- if ( ! hibSession.contains( o ) )
- return false;
- }
- return true;
- }
- else {
- return hibSession.contains( objects[0] );
- }
- }
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.query;
+
+import java.io.IOException;
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import org.apache.lucene.search.IndexSearcher;
+import org.slf4j.Logger;
+
+import org.hibernate.HibernateException;
+import org.hibernate.ScrollableResults;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.SearchFactory;
+import org.hibernate.search.engine.DocumentExtractor;
+import org.hibernate.search.engine.EntityInfo;
+import org.hibernate.search.engine.Loader;
+import org.hibernate.search.util.LoggerFactory;
+import org.hibernate.type.Type;
+
+/**
+ * Implements scrollable and paginated resultsets.
+ * Contrary to Query#iterate() or Query#list(), this implementation is
+ * exposed to returned null objects (if the index is out of date).
+ * <p/>
+ * <p/>
+ * The following methods that change the value of 'current' will check
+ * and set its value to either 'afterLast' or 'beforeFirst' depending
+ * on direction. This is to prevent rogue values from setting it outside
+ * the boundaries of the results.
+ * <ul>
+ * <li>next()</li>
+ * <li>previous()</li>
+ * <li>scroll(i)</li>
+ * <li>last()</li>
+ * <li>first()</li>
+ * </ul>
+ *
+ * @see org.hibernate.Query
+ *
+ * @author Emmanuel Bernard
+ * @author John Griffin
+ * @author Sanne Grinovero
+ */
+public class ScrollableResultsImpl implements ScrollableResults {
+
+ private static final Logger log = LoggerFactory.make();
+
+ private final SearchFactory searchFactory;
+ private final IndexSearcher searcher;
+ private final int first;
+ private final int max;
+ private final int fetchSize;
+ private final Loader loader;
+ private final DocumentExtractor documentExtractor;
+ private final SessionImplementor session;
+
+ /**
+ * Caches result rows and EntityInfo from
+ * <code>first</code> to <code>max</code>
+ */
+ private final LoadedObject[] resultsContext;
+
+ private int current;
+
+ public ScrollableResultsImpl( IndexSearcher searcher, int first, int max, int fetchSize, DocumentExtractor extractor,
+ Loader loader, SearchFactory searchFactory, SessionImplementor sessionImplementor
+ ) {
+ this.searchFactory = searchFactory;
+ this.searcher = searcher;
+ this.first = first;
+ this.max = max;
+ this.loader = loader;
+ this.documentExtractor = extractor;
+ this.fetchSize = fetchSize;
+ this.session = sessionImplementor;
+ int size = Math.max( max - first + 1, 0 );
+ this.resultsContext = new LoadedObject[size];
+ beforeFirst();
+ }
+
+ private LoadedObject ensureCurrentLoaded() {
+ LoadedObject currentCacheRef = resultsContext[current - first];
+ if ( currentCacheRef != null ) {
+ return currentCacheRef;
+ }
+ // the loading window is optimized for scrolling in both directions:
+ int windowStop = Math.min( max + 1 , current + fetchSize );
+ int windowStart = Math.max( first, current - fetchSize + 1 );
+ List<EntityInfo> entityInfosToLoad = new ArrayList<EntityInfo>( fetchSize );
+ int sizeToLoad = 0;
+ for (int x = windowStart; x < windowStop; x++) {
+ int arrayIdx = x - first;
+ LoadedObject lo = resultsContext[arrayIdx];
+ if ( lo == null ) {
+ lo = new LoadedObject();
+ // makes hard references and extract EntityInfos:
+ entityInfosToLoad.add( lo.getEntityInfo( x ) );
+ resultsContext[arrayIdx] = lo;
+ sizeToLoad++;
+ if ( sizeToLoad >= fetchSize )
+ break;
+ }
+ }
+ //preload efficiently by batches:
+ if ( sizeToLoad > 1 ) {
+ loader.load( entityInfosToLoad.toArray( new EntityInfo[sizeToLoad] ) );
+ //(no references stored at this point: they still need to be loaded one by one to inject null results)
+ }
+ return resultsContext[ current - first ];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean next() {
+ // Increases cursor pointer by one. If this places it >
+ // max + 1 (afterLast) then set it to afterLast and return
+ // false.
+ if ( ++current > max ) {
+ afterLast();
+ return false;
+ }
+ return true;
+ }
+
+ public boolean previous() {
+ // Decreases cursor pointer by one. If this places it <
+ // first - 1 (beforeFirst) then set it to beforeFirst and
+ // return false.
+ if ( --current < first ) {
+ beforeFirst();
+ return false;
+ }
+ return true;
+ }
+
+ public boolean scroll(int i) {
+ // Since we have to take into account that we can scroll any
+ // amount positive or negative, we perform the same tests that
+ // we performed in next() and previous().
+ current = current + i;
+ if ( current > max ) {
+ afterLast();
+ return false;
+ }
+ else if ( current < first ) {
+ beforeFirst();
+ return false;
+ }
+ else {
+ return true;
+ }
+ }
+
+ public boolean last() {
+ current = max;
+ if ( current < first ) {
+ beforeFirst();
+ return false;
+ }
+ return max >= first;
+ }
+
+ public boolean first() {
+ current = first;
+ if ( current > max ) {
+ afterLast();
+ return false;
+ }
+ return max >= first;
+ }
+
+ public void beforeFirst() {
+ current = first - 1;
+ }
+
+ public void afterLast() {
+ current = max + 1;
+ //TODO help gc by clearing all structures when using forwardonly scrollmode.
+ }
+
+ public boolean isFirst() {
+ return current == first;
+ }
+
+ public boolean isLast() {
+ return current == max;
+ }
+
+ public void close() {
+ try {
+ searchFactory.getReaderProvider().closeReader( searcher.getIndexReader() );
+ }
+ catch (SearchException e) {
+ log.warn( "Unable to properly close searcher in ScrollableResults", e );
+ }
+ }
+
+ public Object[] get() throws HibernateException {
+ // don't throw an exception here just
+ // return 'null' this is similar to the
+ // RowSet spec in JDBC. It returns false
+ // (or 0 I can't remember) but we can't
+ // do that since we have to make up for
+ // an Object[]. J.G
+ if ( current < first || current > max ) return null;
+ LoadedObject cacheEntry = ensureCurrentLoaded();
+ return cacheEntry.getManagedResult( current );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Object get(int i) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Type getType(int i) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Integer getInteger(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Long getLong(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Float getFloat(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Boolean getBoolean(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Double getDouble(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Short getShort(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Byte getByte(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Character getCharacter(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public byte[] getBinary(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public String getText(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Blob getBlob(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Clob getClob(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public String getString(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public BigDecimal getBigDecimal(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public BigInteger getBigInteger(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Date getDate(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Locale getLocale(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public Calendar getCalendar(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ /**
+ * This method is not supported on Lucene based queries
+ * @throws UnsupportedOperationException always thrown
+ */
+ public TimeZone getTimeZone(int col) {
+ throw new UnsupportedOperationException( "Lucene does not work on columns" );
+ }
+
+ public int getRowNumber() {
+ if ( max < first ) return -1;
+ return current - first;
+ }
+
+ public boolean setRowNumber(int rowNumber) {
+ if ( rowNumber >= 0 ) {
+ current = first + rowNumber;
+ }
+ else {
+ current = max + rowNumber + 1; //max row start at -1
+ }
+ return current >= first && current <= max;
+ }
+
+ private final class LoadedObject {
+
+ private Reference<Object[]> entity; //never==null but Reference.get can return null
+ private Reference<EntityInfo> einfo; //never==null but Reference.get can return null
+
+ /**
+ * Gets the objects from cache if it is available and attached to session,
+ * or reload them and update the cache entry.
+ * @param x absolute position in fulltext result.
+ * @return the managed objects
+ */
+ private Object[] getManagedResult(int x) {
+ EntityInfo entityInfo = getEntityInfo( x );
+ Object[] objects = entity==null ? null : entity.get();
+ if ( objects!=null && areAllEntitiesManaged( objects, entityInfo ) ) {
+ return objects;
+ }
+ else {
+ Object loaded = loader.load( entityInfo );
+ if ( ! loaded.getClass().isArray() ) loaded = new Object[] { loaded };
+ objects = (Object[]) loaded;
+ this.entity = new SoftReference<Object[]>( objects );
+ return objects;
+ }
+ }
+
+ /**
+ * Extract an entityInfo, either from cache or from the index.
+ * @param x the position in the index.
+ * @return
+ */
+ private EntityInfo getEntityInfo(int x) {
+ EntityInfo entityInfo = einfo==null ? null : einfo.get();
+ if ( entityInfo==null ) {
+ try {
+ entityInfo = documentExtractor.extract( x );
+ }
+ catch (IOException e) {
+ throw new SearchException( "Unable to read Lucene topDocs[" + x + "]", e );
+ }
+ einfo = new SoftReference<EntityInfo>( entityInfo );
+ }
+ return entityInfo;
+ }
+
+ }
+
+ private boolean areAllEntitiesManaged(Object[] objects, EntityInfo entityInfo) {
+ //check if all entities are session-managed and skip the check on projected values
+ org.hibernate.Session hibSession = (org.hibernate.Session) session;
+ if ( entityInfo.projection != null ) {
+ // using projection: test only for entities
+ for ( int idx : entityInfo.indexesOfThis ) {
+ Object o = objects[idx];
+ //TODO improve: is it useful to check for proxies and have them reassociated to persistence context?
+ if ( ! hibSession.contains( o ) )
+ return false;
+ }
+ return true;
+ }
+ else {
+ return hibSession.contains( objects[0] );
+ }
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/reader/CacheableMultiReader.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/reader/CacheableMultiReader.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/reader/CacheableMultiReader.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.reader;
import java.io.IOException;
Modified: search/trunk/src/main/java/org/hibernate/search/reader/NotSharedReaderProvider.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/reader/NotSharedReaderProvider.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/reader/NotSharedReaderProvider.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.reader;
import java.io.IOException;
Modified: search/trunk/src/main/java/org/hibernate/search/reader/ReaderProvider.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/reader/ReaderProvider.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/reader/ReaderProvider.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.reader;
import java.util.Properties;
Modified: search/trunk/src/main/java/org/hibernate/search/reader/ReaderProviderFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/reader/ReaderProviderFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/reader/ReaderProviderFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.reader;
import java.util.Map;
Modified: search/trunk/src/main/java/org/hibernate/search/reader/ReaderProviderHelper.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/reader/ReaderProviderHelper.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/reader/ReaderProviderHelper.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.reader;
import java.io.IOException;
Modified: search/trunk/src/main/java/org/hibernate/search/reader/SharedReaderProvider.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/reader/SharedReaderProvider.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/reader/SharedReaderProvider.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.reader;
import java.io.IOException;
Modified: search/trunk/src/main/java/org/hibernate/search/reader/SharingBufferReaderProvider.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/reader/SharingBufferReaderProvider.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/reader/SharingBufferReaderProvider.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.reader;
import java.io.IOException;
Modified: search/trunk/src/main/java/org/hibernate/search/store/DirectoryProvider.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/store/DirectoryProvider.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/store/DirectoryProvider.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,46 +1,69 @@
-//$Id$
-package org.hibernate.search.store;
-
-import java.util.Properties;
-
-import org.apache.lucene.store.Directory;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-
-
-/**
- * Set up and provide a Lucene <code>Directory</code>
- * <code>equals()</code> and <code>hashCode()</code> must guaranty equality
- * between two providers pointing to the same underlying Lucene Store.
- * Besides that, hashCode ordering is used to avoid deadlock when locking a directory provider.
- *
- * This class must be thread safe regarding <code>getDirectory()</code> calls
- *
- * @author Emmanuel Bernard
- * @author Sylvain Vieujot
- */
-public interface DirectoryProvider<TDirectory extends Directory> {
- /**
- * get the information to initialize the directory and build its hashCode/equals method
- */
- void initialize(String directoryProviderName, Properties properties, SearchFactoryImplementor searchFactoryImplementor);
-
- /**
- * Executed after initialize, this method set up the heavy process of starting up the DirectoryProvider
- * IO processing as well as background processing are expected to be set up here
- *
- */
- void start();
-
- /**
- * Executed when the search factory is closed. This method should stop any background process as well as
- * releasing any resource.
- * This method should avoid raising exceptions and log potential errors instead
- */
- void stop();
-
- /**
- * Returns an initialized Lucene Directory. This method call <b>must</b> be threadsafe
- */
- TDirectory getDirectory();
-}
-
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.store;
+
+import java.util.Properties;
+
+import org.apache.lucene.store.Directory;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+
+
+/**
+ * Set up and provide a Lucene <code>Directory</code>
+ * <code>equals()</code> and <code>hashCode()</code> must guaranty equality
+ * between two providers pointing to the same underlying Lucene Store.
+ * Besides that, hashCode ordering is used to avoid deadlock when locking a directory provider.
+ *
+ * This class must be thread safe regarding <code>getDirectory()</code> calls
+ *
+ * @author Emmanuel Bernard
+ * @author Sylvain Vieujot
+ */
+public interface DirectoryProvider<TDirectory extends Directory> {
+ /**
+ * get the information to initialize the directory and build its hashCode/equals method
+ */
+ void initialize(String directoryProviderName, Properties properties, SearchFactoryImplementor searchFactoryImplementor);
+
+ /**
+ * Executed after initialize, this method set up the heavy process of starting up the DirectoryProvider
+ * IO processing as well as background processing are expected to be set up here
+ *
+ */
+ void start();
+
+ /**
+ * Executed when the search factory is closed. This method should stop any background process as well as
+ * releasing any resource.
+ * This method should avoid raising exceptions and log potential errors instead
+ */
+ void stop();
+
+ /**
+ * Returns an initialized Lucene Directory. This method call <b>must</b> be threadsafe
+ */
+ TDirectory getDirectory();
+}
+
Modified: search/trunk/src/main/java/org/hibernate/search/store/DirectoryProviderFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/store/DirectoryProviderFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/store/DirectoryProviderFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.store;
import java.util.ArrayList;
Modified: search/trunk/src/main/java/org/hibernate/search/store/DirectoryProviderHelper.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/store/DirectoryProviderHelper.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/store/DirectoryProviderHelper.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.store;
import java.io.File;
Modified: search/trunk/src/main/java/org/hibernate/search/store/FSDirectoryProvider.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/store/FSDirectoryProvider.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/store/FSDirectoryProvider.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,86 +1,109 @@
-//$Id$
-package org.hibernate.search.store;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-
-import org.apache.lucene.store.FSDirectory;
-import org.slf4j.Logger;
-
-import org.hibernate.search.SearchException;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.util.LoggerFactory;
-
-/**
- * Use a Lucene {@link FSDirectory}. The base directory is represented by the property <i>hibernate.search.default.indexBase</i>
- * or <i>hibernate.search.<index>.indexBase</i>. The former defines the default base directory for all indexes whereas the
- * latter allows to override the base directory on a per index basis.<i> <index></i> has to be replaced with the fully qualified
- * classname of the indexed class or the value of the <i>index</i> property of the <code>@Indexed</code> annotation.
- * <p>
- * The actual index files are then created in <i><indexBase>/<index name></i>, <i><index name></i> is
- * per default the name of the indexed entity, or the value of the <i>index</i> property of the <code>@Indexed</code> or can be specified
- * as property in the configuration file using <i>hibernate.search.<index>.indexName</i>.
- * </p>
- *
- * @author Emmanuel Bernard
- * @author Sylvain Vieujot
- * @author Sanne Grinovero
- */
-public class FSDirectoryProvider implements DirectoryProvider<FSDirectory> {
-
- private static final Logger log = LoggerFactory.make();
-
- private FSDirectory directory;
- private String indexName;
-
- public void initialize(String directoryProviderName, Properties properties, SearchFactoryImplementor searchFactoryImplementor) {
- // on "manual" indexing skip read-write check on index directory
- boolean manual = searchFactoryImplementor.getIndexingStrategy().equals( "manual" );
- File indexDir = DirectoryProviderHelper.getVerifiedIndexDir( directoryProviderName, properties, ! manual );
- try {
- indexName = indexDir.getCanonicalPath();
- //this is cheap so it's not done in start()
- directory = DirectoryProviderHelper.createFSIndex( indexDir, properties );
- }
- catch (IOException e) {
- throw new SearchException( "Unable to initialize index: " + directoryProviderName, e );
- }
- }
-
- public void start() {
- //all the process is done in initialize
- }
-
- public void stop() {
- try {
- directory.close();
- }
- catch (Exception e) {
- log.error( "Unable to properly close Lucene directory {}" + directory.getFile(), e );
- }
- }
-
- public FSDirectory getDirectory() {
- return directory;
- }
-
- @Override
- public boolean equals(Object obj) {
- // 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 );
- }
-
- @Override
- public int hashCode() {
- // 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
- int hash = 11;
- return 37 * hash + indexName.hashCode();
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.store;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.lucene.store.FSDirectory;
+import org.slf4j.Logger;
+
+import org.hibernate.search.SearchException;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.util.LoggerFactory;
+
+/**
+ * Use a Lucene {@link FSDirectory}. The base directory is represented by the property <i>hibernate.search.default.indexBase</i>
+ * or <i>hibernate.search.<index>.indexBase</i>. The former defines the default base directory for all indexes whereas the
+ * latter allows to override the base directory on a per index basis.<i> <index></i> has to be replaced with the fully qualified
+ * classname of the indexed class or the value of the <i>index</i> property of the <code>@Indexed</code> annotation.
+ * <p>
+ * The actual index files are then created in <i><indexBase>/<index name></i>, <i><index name></i> is
+ * per default the name of the indexed entity, or the value of the <i>index</i> property of the <code>@Indexed</code> or can be specified
+ * as property in the configuration file using <i>hibernate.search.<index>.indexName</i>.
+ * </p>
+ *
+ * @author Emmanuel Bernard
+ * @author Sylvain Vieujot
+ * @author Sanne Grinovero
+ */
+public class FSDirectoryProvider implements DirectoryProvider<FSDirectory> {
+
+ private static final Logger log = LoggerFactory.make();
+
+ private FSDirectory directory;
+ private String indexName;
+
+ public void initialize(String directoryProviderName, Properties properties, SearchFactoryImplementor searchFactoryImplementor) {
+ // on "manual" indexing skip read-write check on index directory
+ boolean manual = searchFactoryImplementor.getIndexingStrategy().equals( "manual" );
+ File indexDir = DirectoryProviderHelper.getVerifiedIndexDir( directoryProviderName, properties, ! manual );
+ try {
+ indexName = indexDir.getCanonicalPath();
+ //this is cheap so it's not done in start()
+ directory = DirectoryProviderHelper.createFSIndex( indexDir, properties );
+ }
+ catch (IOException e) {
+ throw new SearchException( "Unable to initialize index: " + directoryProviderName, e );
+ }
+ }
+
+ public void start() {
+ //all the process is done in initialize
+ }
+
+ public void stop() {
+ try {
+ directory.close();
+ }
+ catch (Exception e) {
+ log.error( "Unable to properly close Lucene directory {}" + directory.getFile(), e );
+ }
+ }
+
+ public FSDirectory getDirectory() {
+ return directory;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ // 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 );
+ }
+
+ @Override
+ public int hashCode() {
+ // 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
+ int hash = 11;
+ return 37 * hash + indexName.hashCode();
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/store/FSMasterDirectoryProvider.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/store/FSMasterDirectoryProvider.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/store/FSMasterDirectoryProvider.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,216 +1,239 @@
-//$Id$
-package org.hibernate.search.store;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.locks.Lock;
-
-import org.apache.lucene.store.FSDirectory;
-import org.slf4j.Logger;
-
-import org.hibernate.search.SearchException;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.util.FileHelper;
-import org.hibernate.search.util.LoggerFactory;
-
-/**
- * File based DirectoryProvider that takes care of index copy
- * The base directory is represented by hibernate.search.<index>.indexBase
- * The index is created in <base directory>/<index name>
- * The source (aka copy) directory is built from <sourceBase>/<index name>
- *
- * A copy is triggered every refresh seconds
- *
- * @author Emmanuel Bernard
- * @author Sanne Grinovero
- */
-//TODO rename copy?
-public class FSMasterDirectoryProvider implements DirectoryProvider<FSDirectory> {
-
- private static final Logger log = LoggerFactory.make();
- private final Timer timer = new Timer( true ); //daemon thread, the copy algorithm is robust
-
- private volatile int current;
-
- //variables having visibility granted by a read of "current"
- private FSDirectory directory;
- private String indexName;
- private SearchFactoryImplementor searchFactory;
- private long copyChunkSize;
-
- //variables needed between initialize and start (used by same thread: no special care needed)
- private File sourceDir;
- private File indexDir;
- private String directoryProviderName;
- private Properties properties;
-
- public void initialize(String directoryProviderName, Properties properties, SearchFactoryImplementor searchFactoryImplementor) {
- this.properties = properties;
- this.directoryProviderName = directoryProviderName;
- //source guessing
- sourceDir = DirectoryProviderHelper.getSourceDirectory( directoryProviderName, properties, true );
- log.debug( "Source directory: {}", sourceDir.getPath() );
- indexDir = DirectoryProviderHelper.getVerifiedIndexDir( directoryProviderName, properties, true );
- log.debug( "Index directory: {}", indexDir.getPath() );
- try {
- indexName = indexDir.getCanonicalPath();
- directory = DirectoryProviderHelper.createFSIndex( indexDir, properties );
- }
- catch (IOException e) {
- throw new SearchException( "Unable to initialize index: " + directoryProviderName, e );
- }
- copyChunkSize = DirectoryProviderHelper.getCopyBufferSize( directoryProviderName, properties );
- this.searchFactory = searchFactoryImplementor;
- current = 0; //write to volatile to publish all state
- }
-
- public void start() {
- int currentLocal = 0;
- try {
- //copy to source
- if ( new File( sourceDir, "current1").exists() ) {
- currentLocal = 2;
- }
- else if ( new File( sourceDir, "current2").exists() ) {
- currentLocal = 1;
- }
- else {
- log.debug( "Source directory for '{}' will be initialized", indexName);
- currentLocal = 1;
- }
- String currentString = Integer.valueOf( currentLocal ).toString();
- File subDir = new File( sourceDir, currentString );
- FileHelper.synchronize( indexDir, subDir, true, copyChunkSize );
- new File( sourceDir, "current1 ").delete();
- new File( sourceDir, "current2" ).delete();
- //TODO small hole, no file can be found here
- new File( sourceDir, "current" + currentString ).createNewFile();
- log.debug( "Current directory: {}", currentLocal );
- }
- catch (IOException e) {
- throw new SearchException( "Unable to initialize index: " + directoryProviderName, e );
- }
- TimerTask task = new FSMasterDirectoryProvider.TriggerTask( indexDir, sourceDir, this );
- long period = DirectoryProviderHelper.getRefreshPeriod( properties, directoryProviderName );
- timer.scheduleAtFixedRate( task, period, period );
- this.current = currentLocal; //write to volatile to publish all state
- }
-
- public FSDirectory getDirectory() {
- @SuppressWarnings("unused")
- int readCurrentState = current; //Unneeded value, needed to ensure visibility of state protected by memory barrier
- return directory;
- }
-
- @Override
- public boolean equals(Object obj) {
- // 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 FSMasterDirectoryProvider ) ) return false;
- FSMasterDirectoryProvider other = (FSMasterDirectoryProvider)obj;
- //break both memory barriers by reading volatile variables:
- @SuppressWarnings("unused")
- int readCurrentState = other.current;
- readCurrentState = this.current;
- return indexName.equals( other.indexName );
- }
-
- @Override
- public int hashCode() {
- // 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
- @SuppressWarnings("unused")
- int readCurrentState = current; //Unneeded value, to ensure visibility of state protected by memory barrier
- int hash = 11;
- return 37 * hash + indexName.hashCode();
- }
-
- public void stop() {
- @SuppressWarnings("unused")
- int readCurrentState = current; //Another unneeded value, to ensure visibility of state protected by memory barrier
- timer.cancel();
- try {
- directory.close();
- }
- catch (Exception e) {
- log.error( "Unable to properly close Lucene directory {}" + directory.getFile(), e );
- }
- }
-
- private class TriggerTask extends TimerTask {
-
- private final Executor executor;
- private final FSMasterDirectoryProvider.CopyDirectory copyTask;
-
- public TriggerTask(File source, File destination, DirectoryProvider<FSDirectory> directoryProvider) {
- executor = Executors.newSingleThreadExecutor();
- copyTask = new FSMasterDirectoryProvider.CopyDirectory( source, destination, directoryProvider );
- }
-
- public void run() {
- if ( copyTask.inProgress.compareAndSet( false, true ) ) {
- executor.execute( copyTask );
- }
- else {
- log.info( "Skipping directory synchronization, previous work still in progress: {}", indexName );
- }
- }
- }
-
- private class CopyDirectory implements Runnable {
- private final File source;
- private final File destination;
- private final AtomicBoolean inProgress = new AtomicBoolean( false );
- private final Lock directoryProviderLock;
-
- public CopyDirectory(File source, File destination, DirectoryProvider<FSDirectory> directoryProvider) {
- this.source = source;
- this.destination = destination;
- this.directoryProviderLock = searchFactory.getDirectoryProviderLock( directoryProvider );
- }
-
- public void run() {
- //TODO get rid of current and use the marker file instead?
- directoryProviderLock.lock();
- try {
- long start = System.currentTimeMillis();//keep time after lock is acquired for correct measure
- int oldIndex = current;
- int index = oldIndex == 1 ? 2 : 1;
- File destinationFile = new File( destination, Integer.valueOf(index).toString() );
- try {
- log.trace( "Copying {} into {}", source, destinationFile );
- FileHelper.synchronize( source, destinationFile, true, copyChunkSize );
- current = index;
- }
- catch (IOException e) {
- //don't change current
- log.error( "Unable to synchronize source of " + indexName, e );
- return;
- }
- if ( ! new File( destination, "current" + oldIndex ).delete() ) {
- log.warn( "Unable to remove previous marker file from source of {}", indexName );
- }
- try {
- new File( destination, "current" + index ).createNewFile();
- }
- catch( IOException e ) {
- log.warn( "Unable to create current marker in source of " + indexName, e );
- }
- log.trace( "Copy for {} took {} ms", indexName, (System.currentTimeMillis() - start) );
- }
- finally {
- directoryProviderLock.unlock();
- inProgress.set( false );
- }
- }
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.store;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.Lock;
+
+import org.apache.lucene.store.FSDirectory;
+import org.slf4j.Logger;
+
+import org.hibernate.search.SearchException;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.util.FileHelper;
+import org.hibernate.search.util.LoggerFactory;
+
+/**
+ * File based DirectoryProvider that takes care of index copy
+ * The base directory is represented by hibernate.search.<index>.indexBase
+ * The index is created in <base directory>/<index name>
+ * The source (aka copy) directory is built from <sourceBase>/<index name>
+ *
+ * A copy is triggered every refresh seconds
+ *
+ * @author Emmanuel Bernard
+ * @author Sanne Grinovero
+ */
+//TODO rename copy?
+public class FSMasterDirectoryProvider implements DirectoryProvider<FSDirectory> {
+
+ private static final Logger log = LoggerFactory.make();
+ private final Timer timer = new Timer( true ); //daemon thread, the copy algorithm is robust
+
+ private volatile int current;
+
+ //variables having visibility granted by a read of "current"
+ private FSDirectory directory;
+ private String indexName;
+ private SearchFactoryImplementor searchFactory;
+ private long copyChunkSize;
+
+ //variables needed between initialize and start (used by same thread: no special care needed)
+ private File sourceDir;
+ private File indexDir;
+ private String directoryProviderName;
+ private Properties properties;
+
+ public void initialize(String directoryProviderName, Properties properties, SearchFactoryImplementor searchFactoryImplementor) {
+ this.properties = properties;
+ this.directoryProviderName = directoryProviderName;
+ //source guessing
+ sourceDir = DirectoryProviderHelper.getSourceDirectory( directoryProviderName, properties, true );
+ log.debug( "Source directory: {}", sourceDir.getPath() );
+ indexDir = DirectoryProviderHelper.getVerifiedIndexDir( directoryProviderName, properties, true );
+ log.debug( "Index directory: {}", indexDir.getPath() );
+ try {
+ indexName = indexDir.getCanonicalPath();
+ directory = DirectoryProviderHelper.createFSIndex( indexDir, properties );
+ }
+ catch (IOException e) {
+ throw new SearchException( "Unable to initialize index: " + directoryProviderName, e );
+ }
+ copyChunkSize = DirectoryProviderHelper.getCopyBufferSize( directoryProviderName, properties );
+ this.searchFactory = searchFactoryImplementor;
+ current = 0; //write to volatile to publish all state
+ }
+
+ public void start() {
+ int currentLocal = 0;
+ try {
+ //copy to source
+ if ( new File( sourceDir, "current1").exists() ) {
+ currentLocal = 2;
+ }
+ else if ( new File( sourceDir, "current2").exists() ) {
+ currentLocal = 1;
+ }
+ else {
+ log.debug( "Source directory for '{}' will be initialized", indexName);
+ currentLocal = 1;
+ }
+ String currentString = Integer.valueOf( currentLocal ).toString();
+ File subDir = new File( sourceDir, currentString );
+ FileHelper.synchronize( indexDir, subDir, true, copyChunkSize );
+ new File( sourceDir, "current1 ").delete();
+ new File( sourceDir, "current2" ).delete();
+ //TODO small hole, no file can be found here
+ new File( sourceDir, "current" + currentString ).createNewFile();
+ log.debug( "Current directory: {}", currentLocal );
+ }
+ catch (IOException e) {
+ throw new SearchException( "Unable to initialize index: " + directoryProviderName, e );
+ }
+ TimerTask task = new FSMasterDirectoryProvider.TriggerTask( indexDir, sourceDir, this );
+ long period = DirectoryProviderHelper.getRefreshPeriod( properties, directoryProviderName );
+ timer.scheduleAtFixedRate( task, period, period );
+ this.current = currentLocal; //write to volatile to publish all state
+ }
+
+ public FSDirectory getDirectory() {
+ @SuppressWarnings("unused")
+ int readCurrentState = current; //Unneeded value, needed to ensure visibility of state protected by memory barrier
+ return directory;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ // 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 FSMasterDirectoryProvider ) ) return false;
+ FSMasterDirectoryProvider other = (FSMasterDirectoryProvider)obj;
+ //break both memory barriers by reading volatile variables:
+ @SuppressWarnings("unused")
+ int readCurrentState = other.current;
+ readCurrentState = this.current;
+ return indexName.equals( other.indexName );
+ }
+
+ @Override
+ public int hashCode() {
+ // 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
+ @SuppressWarnings("unused")
+ int readCurrentState = current; //Unneeded value, to ensure visibility of state protected by memory barrier
+ int hash = 11;
+ return 37 * hash + indexName.hashCode();
+ }
+
+ public void stop() {
+ @SuppressWarnings("unused")
+ int readCurrentState = current; //Another unneeded value, to ensure visibility of state protected by memory barrier
+ timer.cancel();
+ try {
+ directory.close();
+ }
+ catch (Exception e) {
+ log.error( "Unable to properly close Lucene directory {}" + directory.getFile(), e );
+ }
+ }
+
+ private class TriggerTask extends TimerTask {
+
+ private final Executor executor;
+ private final FSMasterDirectoryProvider.CopyDirectory copyTask;
+
+ public TriggerTask(File source, File destination, DirectoryProvider<FSDirectory> directoryProvider) {
+ executor = Executors.newSingleThreadExecutor();
+ copyTask = new FSMasterDirectoryProvider.CopyDirectory( source, destination, directoryProvider );
+ }
+
+ public void run() {
+ if ( copyTask.inProgress.compareAndSet( false, true ) ) {
+ executor.execute( copyTask );
+ }
+ else {
+ log.info( "Skipping directory synchronization, previous work still in progress: {}", indexName );
+ }
+ }
+ }
+
+ private class CopyDirectory implements Runnable {
+ private final File source;
+ private final File destination;
+ private final AtomicBoolean inProgress = new AtomicBoolean( false );
+ private final Lock directoryProviderLock;
+
+ public CopyDirectory(File source, File destination, DirectoryProvider<FSDirectory> directoryProvider) {
+ this.source = source;
+ this.destination = destination;
+ this.directoryProviderLock = searchFactory.getDirectoryProviderLock( directoryProvider );
+ }
+
+ public void run() {
+ //TODO get rid of current and use the marker file instead?
+ directoryProviderLock.lock();
+ try {
+ long start = System.currentTimeMillis();//keep time after lock is acquired for correct measure
+ int oldIndex = current;
+ int index = oldIndex == 1 ? 2 : 1;
+ File destinationFile = new File( destination, Integer.valueOf(index).toString() );
+ try {
+ log.trace( "Copying {} into {}", source, destinationFile );
+ FileHelper.synchronize( source, destinationFile, true, copyChunkSize );
+ current = index;
+ }
+ catch (IOException e) {
+ //don't change current
+ log.error( "Unable to synchronize source of " + indexName, e );
+ return;
+ }
+ if ( ! new File( destination, "current" + oldIndex ).delete() ) {
+ log.warn( "Unable to remove previous marker file from source of {}", indexName );
+ }
+ try {
+ new File( destination, "current" + index ).createNewFile();
+ }
+ catch( IOException e ) {
+ log.warn( "Unable to create current marker in source of " + indexName, e );
+ }
+ log.trace( "Copy for {} took {} ms", indexName, (System.currentTimeMillis() - start) );
+ }
+ finally {
+ directoryProviderLock.unlock();
+ inProgress.set( false );
+ }
+ }
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/store/FSSlaveDirectoryProvider.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/store/FSSlaveDirectoryProvider.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/store/FSSlaveDirectoryProvider.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,294 +1,317 @@
-//$Id$
-package org.hibernate.search.store;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.lucene.store.FSDirectory;
-import org.slf4j.Logger;
-
-import org.hibernate.AssertionFailure;
-import org.hibernate.search.SearchException;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.util.FileHelper;
-import org.hibernate.search.util.LoggerFactory;
-
-/**
- * File based directory provider that takes care of getting a version of the index
- * from a given source.
- * The base directory is represented by hibernate.search.<index>.indexBase
- * The index is created in <base directory>/<index name>
- * The source (aka copy) directory is built from <sourceBase>/<index name>
- * <p/>
- * A copy is triggered every refresh seconds
- *
- * @author Emmanuel Bernard
- * @author Sanne Grinovero
- */
-public class FSSlaveDirectoryProvider implements DirectoryProvider<FSDirectory> {
-
- private static final Logger log = LoggerFactory.make();
- private final Timer timer = new Timer( true ); //daemon thread, the copy algorithm is robust
-
- private volatile int current; //used also as memory barrier of all other values, which are set once.
-
- //variables having visibility granted by a read of "current"
- private FSDirectory directory1;
- private FSDirectory directory2;
- private String indexName;
- private long copyChunkSize;
-
- //variables needed between initialize and start (used by same thread: no special care needed)
- private File sourceIndexDir;
- private File indexDir;
- private String directoryProviderName;
- private Properties properties;
-
- public void initialize(String directoryProviderName, Properties properties, SearchFactoryImplementor searchFactoryImplementor) {
- this.properties = properties;
- this.directoryProviderName = directoryProviderName;
- //source guessing
- sourceIndexDir = DirectoryProviderHelper.getSourceDirectory( directoryProviderName, properties, false );
- if ( !new File( sourceIndexDir, "current1" ).exists() && !new File( sourceIndexDir, "current2" ).exists() ) {
- throw new IllegalStateException( "No current marker in source directory" );
- }
- log.debug( "Source directory: {}", sourceIndexDir.getPath() );
- indexDir = DirectoryProviderHelper.getVerifiedIndexDir( directoryProviderName, properties, true );
- log.debug( "Index directory: {}", indexDir.getPath() );
- try {
- indexName = indexDir.getCanonicalPath();
- }
- catch ( IOException e ) {
- throw new SearchException( "Unable to initialize index: " + directoryProviderName, e );
- }
- copyChunkSize = DirectoryProviderHelper.getCopyBufferSize( directoryProviderName, properties );
- current = 0; //publish all state to other threads
- }
-
- public void start() {
- int readCurrentState = current; //Unneeded value, but ensure visibility of state protected by memory barrier
- int currentToBe = 0;
- try {
- directory1 = DirectoryProviderHelper.createFSIndex( new File( indexDir, "1" ), properties );
- directory2 = DirectoryProviderHelper.createFSIndex( new File( indexDir, "2" ), properties );
- File currentMarker = new File( indexDir, "current1" );
- File current2Marker = new File( indexDir, "current2" );
- if ( currentMarker.exists() ) {
- currentToBe = 1;
- if ( current2Marker.exists() ) {
- current2Marker.delete(); //TODO or throw an exception?
- }
- }
- else if ( current2Marker.exists() ) {
- currentToBe = 2;
- }
- else {
- //no default
- log.debug( "Setting directory 1 as current" );
- currentToBe = 1;
- File destinationFile = new File( indexDir, Integer.valueOf( readCurrentState ).toString() );
- int sourceCurrent;
- if ( new File( sourceIndexDir, "current1" ).exists() ) {
- sourceCurrent = 1;
- }
- else if ( new File( sourceIndexDir, "current2" ).exists() ) {
- sourceCurrent = 2;
- }
- else {
- throw new AssertionFailure( "No current file marker found in source directory: " + sourceIndexDir.getPath() );
- }
- try {
- FileHelper.synchronize(
- new File( sourceIndexDir, String.valueOf( sourceCurrent ) ),
- destinationFile, true, copyChunkSize
- );
- }
- catch ( IOException e ) {
- throw new SearchException( "Unable to synchronize directory: " + indexName, e );
- }
- if ( !currentMarker.createNewFile() ) {
- throw new SearchException( "Unable to create the directory marker file: " + indexName );
- }
- }
- log.debug( "Current directory: {}", currentToBe );
- }
- catch ( IOException e ) {
- throw new SearchException( "Unable to initialize index: " + directoryProviderName, e );
- }
- TimerTask task = new TriggerTask( sourceIndexDir, indexDir );
- long period = DirectoryProviderHelper.getRefreshPeriod( properties, directoryProviderName );
- timer.scheduleAtFixedRate( task, period, period );
- this.current = currentToBe;
- }
-
- public FSDirectory getDirectory() {
- int readState = current;// to have the read consistent in the next two "if"s.
- if ( readState == 1 ) {
- return directory1;
- }
- else if ( readState == 2 ) {
- return directory2;
- }
- else {
- throw new AssertionFailure( "Illegal current directory: " + readState );
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- // 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 FSSlaveDirectoryProvider ) ) {
- return false;
- }
- FSSlaveDirectoryProvider other = ( FSSlaveDirectoryProvider ) obj;
- //need to break memory barriers on both instances:
- @SuppressWarnings("unused")
- int readCurrentState = this.current; //unneded value, but ensure visibility of indexName
- readCurrentState = other.current; //another unneded value, but ensure visibility of indexName
- return indexName.equals( other.indexName );
- }
-
- @Override
- public int hashCode() {
- // 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
- @SuppressWarnings("unused")
- int readCurrentState = current; //unneded value, but ensure visibility of indexName
- int hash = 11;
- return 37 * hash + indexName.hashCode();
- }
-
- class TriggerTask extends TimerTask {
-
- private final Executor executor;
- private final CopyDirectory copyTask;
-
- public TriggerTask(File sourceIndexDir, File destination) {
- executor = Executors.newSingleThreadExecutor();
- copyTask = new CopyDirectory( sourceIndexDir, destination );
- }
-
- public void run() {
- if ( copyTask.inProgress.compareAndSet( false, true ) ) {
- executor.execute( copyTask );
- }
- else {
- if ( log.isTraceEnabled() ) {
- @SuppressWarnings("unused")
- int unneeded = current;//ensure visibility of indexName in Timer threads.
- log.trace( "Skipping directory synchronization, previous work still in progress: {}", indexName );
- }
- }
- }
- }
-
- class CopyDirectory implements Runnable {
- private final File source;
- private final File destination;
- private final AtomicBoolean inProgress = new AtomicBoolean( false );
-
- public CopyDirectory(File sourceIndexDir, File destination) {
- this.source = sourceIndexDir;
- this.destination = destination;
- }
-
- public void run() {
- long start = System.currentTimeMillis();
- try {
- File sourceFile = determineCurrentSourceFile();
- if ( sourceFile == null ) {
- log.error( "Unable to determine current in source directory" );
- return;
- }
-
- // check whether a copy is needed at all
- File currentDestinationFile = new File( destination, Integer.valueOf( current ).toString() );
- try {
- if ( FileHelper.areInSync( sourceFile, currentDestinationFile ) ) {
- if ( log.isTraceEnabled() ) {
- log.trace( "Source and destination directory are in sync. No copying required." );
- }
- return;
- }
- }
- catch ( IOException ioe ) {
- log.warn( "Unable to compare {} with {}.", sourceFile.getName(), currentDestinationFile.getName() );
- }
-
- // copy is required
- int oldIndex = current;
- int index = oldIndex == 1 ? 2 : 1;
- File destinationFile = new File( destination, Integer.valueOf( index ).toString() );
- try {
- log.trace( "Copying {} into {}", sourceFile, destinationFile );
- FileHelper.synchronize( sourceFile, destinationFile, true, copyChunkSize );
- current = index;
- log.trace( "Copy for {} took {} ms", indexName, ( System.currentTimeMillis() - start ) );
- }
- catch ( IOException e ) {
- //don't change current
- log.error( "Unable to synchronize " + indexName, e );
- return;
- }
- if ( !new File( indexName, "current" + oldIndex ).delete() ) {
- log.warn( "Unable to remove previous marker file in " + indexName );
- }
- try {
- new File( indexName, "current" + index ).createNewFile();
- }
- catch ( IOException e ) {
- log.warn( "Unable to create current marker file in " + indexName, e );
- }
- }
- finally {
- inProgress.set( false );
- }
- }
-
- /**
- * @return Return a file to the currently active source directory. Tests for the files "current1" and
- * "current2" in order to determine which is the current directory. If there marker file does not exists
- * <code>null</code> is returned.
- */
- private File determineCurrentSourceFile() {
- File sourceFile = null;
- if ( new File( source, "current1" ).exists() ) {
- sourceFile = new File( source, "1" );
- }
- else if ( new File( source, "current2" ).exists() ) {
- sourceFile = new File( source, "2" );
- }
- return sourceFile;
- }
- }
-
- public void stop() {
- @SuppressWarnings("unused")
- int readCurrentState = current; //unneded value, but ensure visibility of state protected by memory barrier
- timer.cancel();
- try {
- directory1.close();
- }
- catch ( Exception e ) {
- log.error( "Unable to properly close Lucene directory {}" + directory1.getFile(), e );
- }
- try {
- directory2.close();
- }
- catch ( Exception e ) {
- log.error( "Unable to properly close Lucene directory {}" + directory2.getFile(), e );
- }
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.store;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.lucene.store.FSDirectory;
+import org.slf4j.Logger;
+
+import org.hibernate.AssertionFailure;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.util.FileHelper;
+import org.hibernate.search.util.LoggerFactory;
+
+/**
+ * File based directory provider that takes care of getting a version of the index
+ * from a given source.
+ * The base directory is represented by hibernate.search.<index>.indexBase
+ * The index is created in <base directory>/<index name>
+ * The source (aka copy) directory is built from <sourceBase>/<index name>
+ * <p/>
+ * A copy is triggered every refresh seconds
+ *
+ * @author Emmanuel Bernard
+ * @author Sanne Grinovero
+ */
+public class FSSlaveDirectoryProvider implements DirectoryProvider<FSDirectory> {
+
+ private static final Logger log = LoggerFactory.make();
+ private final Timer timer = new Timer( true ); //daemon thread, the copy algorithm is robust
+
+ private volatile int current; //used also as memory barrier of all other values, which are set once.
+
+ //variables having visibility granted by a read of "current"
+ private FSDirectory directory1;
+ private FSDirectory directory2;
+ private String indexName;
+ private long copyChunkSize;
+
+ //variables needed between initialize and start (used by same thread: no special care needed)
+ private File sourceIndexDir;
+ private File indexDir;
+ private String directoryProviderName;
+ private Properties properties;
+
+ public void initialize(String directoryProviderName, Properties properties, SearchFactoryImplementor searchFactoryImplementor) {
+ this.properties = properties;
+ this.directoryProviderName = directoryProviderName;
+ //source guessing
+ sourceIndexDir = DirectoryProviderHelper.getSourceDirectory( directoryProviderName, properties, false );
+ if ( !new File( sourceIndexDir, "current1" ).exists() && !new File( sourceIndexDir, "current2" ).exists() ) {
+ throw new IllegalStateException( "No current marker in source directory" );
+ }
+ log.debug( "Source directory: {}", sourceIndexDir.getPath() );
+ indexDir = DirectoryProviderHelper.getVerifiedIndexDir( directoryProviderName, properties, true );
+ log.debug( "Index directory: {}", indexDir.getPath() );
+ try {
+ indexName = indexDir.getCanonicalPath();
+ }
+ catch ( IOException e ) {
+ throw new SearchException( "Unable to initialize index: " + directoryProviderName, e );
+ }
+ copyChunkSize = DirectoryProviderHelper.getCopyBufferSize( directoryProviderName, properties );
+ current = 0; //publish all state to other threads
+ }
+
+ public void start() {
+ int readCurrentState = current; //Unneeded value, but ensure visibility of state protected by memory barrier
+ int currentToBe = 0;
+ try {
+ directory1 = DirectoryProviderHelper.createFSIndex( new File( indexDir, "1" ), properties );
+ directory2 = DirectoryProviderHelper.createFSIndex( new File( indexDir, "2" ), properties );
+ File currentMarker = new File( indexDir, "current1" );
+ File current2Marker = new File( indexDir, "current2" );
+ if ( currentMarker.exists() ) {
+ currentToBe = 1;
+ if ( current2Marker.exists() ) {
+ current2Marker.delete(); //TODO or throw an exception?
+ }
+ }
+ else if ( current2Marker.exists() ) {
+ currentToBe = 2;
+ }
+ else {
+ //no default
+ log.debug( "Setting directory 1 as current" );
+ currentToBe = 1;
+ File destinationFile = new File( indexDir, Integer.valueOf( readCurrentState ).toString() );
+ int sourceCurrent;
+ if ( new File( sourceIndexDir, "current1" ).exists() ) {
+ sourceCurrent = 1;
+ }
+ else if ( new File( sourceIndexDir, "current2" ).exists() ) {
+ sourceCurrent = 2;
+ }
+ else {
+ throw new AssertionFailure( "No current file marker found in source directory: " + sourceIndexDir.getPath() );
+ }
+ try {
+ FileHelper.synchronize(
+ new File( sourceIndexDir, String.valueOf( sourceCurrent ) ),
+ destinationFile, true, copyChunkSize
+ );
+ }
+ catch ( IOException e ) {
+ throw new SearchException( "Unable to synchronize directory: " + indexName, e );
+ }
+ if ( !currentMarker.createNewFile() ) {
+ throw new SearchException( "Unable to create the directory marker file: " + indexName );
+ }
+ }
+ log.debug( "Current directory: {}", currentToBe );
+ }
+ catch ( IOException e ) {
+ throw new SearchException( "Unable to initialize index: " + directoryProviderName, e );
+ }
+ TimerTask task = new TriggerTask( sourceIndexDir, indexDir );
+ long period = DirectoryProviderHelper.getRefreshPeriod( properties, directoryProviderName );
+ timer.scheduleAtFixedRate( task, period, period );
+ this.current = currentToBe;
+ }
+
+ public FSDirectory getDirectory() {
+ int readState = current;// to have the read consistent in the next two "if"s.
+ if ( readState == 1 ) {
+ return directory1;
+ }
+ else if ( readState == 2 ) {
+ return directory2;
+ }
+ else {
+ throw new AssertionFailure( "Illegal current directory: " + readState );
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ // 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 FSSlaveDirectoryProvider ) ) {
+ return false;
+ }
+ FSSlaveDirectoryProvider other = ( FSSlaveDirectoryProvider ) obj;
+ //need to break memory barriers on both instances:
+ @SuppressWarnings("unused")
+ int readCurrentState = this.current; //unneded value, but ensure visibility of indexName
+ readCurrentState = other.current; //another unneded value, but ensure visibility of indexName
+ return indexName.equals( other.indexName );
+ }
+
+ @Override
+ public int hashCode() {
+ // 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
+ @SuppressWarnings("unused")
+ int readCurrentState = current; //unneded value, but ensure visibility of indexName
+ int hash = 11;
+ return 37 * hash + indexName.hashCode();
+ }
+
+ class TriggerTask extends TimerTask {
+
+ private final Executor executor;
+ private final CopyDirectory copyTask;
+
+ public TriggerTask(File sourceIndexDir, File destination) {
+ executor = Executors.newSingleThreadExecutor();
+ copyTask = new CopyDirectory( sourceIndexDir, destination );
+ }
+
+ public void run() {
+ if ( copyTask.inProgress.compareAndSet( false, true ) ) {
+ executor.execute( copyTask );
+ }
+ else {
+ if ( log.isTraceEnabled() ) {
+ @SuppressWarnings("unused")
+ int unneeded = current;//ensure visibility of indexName in Timer threads.
+ log.trace( "Skipping directory synchronization, previous work still in progress: {}", indexName );
+ }
+ }
+ }
+ }
+
+ class CopyDirectory implements Runnable {
+ private final File source;
+ private final File destination;
+ private final AtomicBoolean inProgress = new AtomicBoolean( false );
+
+ public CopyDirectory(File sourceIndexDir, File destination) {
+ this.source = sourceIndexDir;
+ this.destination = destination;
+ }
+
+ public void run() {
+ long start = System.currentTimeMillis();
+ try {
+ File sourceFile = determineCurrentSourceFile();
+ if ( sourceFile == null ) {
+ log.error( "Unable to determine current in source directory" );
+ return;
+ }
+
+ // check whether a copy is needed at all
+ File currentDestinationFile = new File( destination, Integer.valueOf( current ).toString() );
+ try {
+ if ( FileHelper.areInSync( sourceFile, currentDestinationFile ) ) {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "Source and destination directory are in sync. No copying required." );
+ }
+ return;
+ }
+ }
+ catch ( IOException ioe ) {
+ log.warn( "Unable to compare {} with {}.", sourceFile.getName(), currentDestinationFile.getName() );
+ }
+
+ // copy is required
+ int oldIndex = current;
+ int index = oldIndex == 1 ? 2 : 1;
+ File destinationFile = new File( destination, Integer.valueOf( index ).toString() );
+ try {
+ log.trace( "Copying {} into {}", sourceFile, destinationFile );
+ FileHelper.synchronize( sourceFile, destinationFile, true, copyChunkSize );
+ current = index;
+ log.trace( "Copy for {} took {} ms", indexName, ( System.currentTimeMillis() - start ) );
+ }
+ catch ( IOException e ) {
+ //don't change current
+ log.error( "Unable to synchronize " + indexName, e );
+ return;
+ }
+ if ( !new File( indexName, "current" + oldIndex ).delete() ) {
+ log.warn( "Unable to remove previous marker file in " + indexName );
+ }
+ try {
+ new File( indexName, "current" + index ).createNewFile();
+ }
+ catch ( IOException e ) {
+ log.warn( "Unable to create current marker file in " + indexName, e );
+ }
+ }
+ finally {
+ inProgress.set( false );
+ }
+ }
+
+ /**
+ * @return Return a file to the currently active source directory. Tests for the files "current1" and
+ * "current2" in order to determine which is the current directory. If there marker file does not exists
+ * <code>null</code> is returned.
+ */
+ private File determineCurrentSourceFile() {
+ File sourceFile = null;
+ if ( new File( source, "current1" ).exists() ) {
+ sourceFile = new File( source, "1" );
+ }
+ else if ( new File( source, "current2" ).exists() ) {
+ sourceFile = new File( source, "2" );
+ }
+ return sourceFile;
+ }
+ }
+
+ public void stop() {
+ @SuppressWarnings("unused")
+ int readCurrentState = current; //unneded value, but ensure visibility of state protected by memory barrier
+ timer.cancel();
+ try {
+ directory1.close();
+ }
+ catch ( Exception e ) {
+ log.error( "Unable to properly close Lucene directory {}" + directory1.getFile(), e );
+ }
+ try {
+ directory2.close();
+ }
+ catch ( Exception e ) {
+ log.error( "Unable to properly close Lucene directory {}" + directory2.getFile(), e );
+ }
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/store/IdHashShardingStrategy.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/store/IdHashShardingStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/store/IdHashShardingStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.store;
import java.util.Properties;
Modified: search/trunk/src/main/java/org/hibernate/search/store/IndexShardingStrategy.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/store/IndexShardingStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/store/IndexShardingStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.store;
import java.io.Serializable;
Modified: search/trunk/src/main/java/org/hibernate/search/store/LockFactoryFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/store/LockFactoryFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/store/LockFactoryFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.store;
import java.io.File;
Modified: search/trunk/src/main/java/org/hibernate/search/store/NotShardedStrategy.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/store/NotShardedStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/store/NotShardedStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.store;
import java.util.Properties;
Modified: search/trunk/src/main/java/org/hibernate/search/store/RAMDirectoryProvider.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/store/RAMDirectoryProvider.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/store/RAMDirectoryProvider.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,68 +1,91 @@
-//$Id$
-package org.hibernate.search.store;
-
-import java.io.IOException;
-import java.util.Properties;
-
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.store.RAMDirectory;
-import org.hibernate.HibernateException;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-
-/**
- * Use a Lucene RAMDirectory
- *
- * @author Emmanuel Bernard
- * @author Sylvain Vieujot
- */
-public class RAMDirectoryProvider implements DirectoryProvider<RAMDirectory> {
-
- private final RAMDirectory directory = new RAMDirectory();
- private String indexName;
-
- public void initialize(String directoryProviderName, Properties properties, SearchFactoryImplementor searchFactoryImplementor) {
- indexName = directoryProviderName;
- directory.setLockFactory( DirectoryProviderHelper.createLockFactory( null, properties ) );
- }
-
- public void start() {
- try {
- IndexWriter.MaxFieldLength fieldLength = new IndexWriter.MaxFieldLength( IndexWriter.DEFAULT_MAX_FIELD_LENGTH );
- IndexWriter iw = new IndexWriter( directory, new StandardAnalyzer(), true, fieldLength );
- iw.close();
- }
- catch (IOException e) {
- throw new HibernateException( "Unable to initialize index: " + indexName, e );
- }
- }
-
-
- public RAMDirectory getDirectory() {
- return directory;
- }
-
- public void stop() {
- directory.close();
- }
-
- @Override
- public boolean equals(Object obj) {
- // 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 );
- }
-
- @Override
- public int hashCode() {
- // 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
- int hash = 7;
- return 29 * hash + indexName.hashCode();
- }
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.store;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.store.RAMDirectory;
+import org.hibernate.HibernateException;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+
+/**
+ * Use a Lucene RAMDirectory
+ *
+ * @author Emmanuel Bernard
+ * @author Sylvain Vieujot
+ */
+public class RAMDirectoryProvider implements DirectoryProvider<RAMDirectory> {
+
+ private final RAMDirectory directory = new RAMDirectory();
+ private String indexName;
+
+ public void initialize(String directoryProviderName, Properties properties, SearchFactoryImplementor searchFactoryImplementor) {
+ indexName = directoryProviderName;
+ directory.setLockFactory( DirectoryProviderHelper.createLockFactory( null, properties ) );
+ }
+
+ public void start() {
+ try {
+ IndexWriter.MaxFieldLength fieldLength = new IndexWriter.MaxFieldLength( IndexWriter.DEFAULT_MAX_FIELD_LENGTH );
+ IndexWriter iw = new IndexWriter( directory, new StandardAnalyzer(), true, fieldLength );
+ iw.close();
+ }
+ catch (IOException e) {
+ throw new HibernateException( "Unable to initialize index: " + indexName, e );
+ }
+ }
+
+
+ public RAMDirectory getDirectory() {
+ return directory;
+ }
+
+ public void stop() {
+ directory.close();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ // 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 );
+ }
+
+ @Override
+ public int hashCode() {
+ // 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
+ int hash = 7;
+ return 29 * hash + indexName.hashCode();
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/store/optimization/IncrementalOptimizerStrategy.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/store/optimization/IncrementalOptimizerStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/store/optimization/IncrementalOptimizerStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.store.optimization;
import java.io.IOException;
Modified: search/trunk/src/main/java/org/hibernate/search/store/optimization/NoOpOptimizerStrategy.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/store/optimization/NoOpOptimizerStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/store/optimization/NoOpOptimizerStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.store.optimization;
import java.util.Properties;
Modified: search/trunk/src/main/java/org/hibernate/search/store/optimization/OptimizerStrategy.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/store/optimization/OptimizerStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/store/optimization/OptimizerStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.store.optimization;
import java.util.Properties;
Modified: search/trunk/src/main/java/org/hibernate/search/util/ContextHelper.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/util/ContextHelper.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/util/ContextHelper.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,37 +1,60 @@
-//$Id$
-package org.hibernate.search.util;
-
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.search.event.FullTextIndexEventListener;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-
-/**
- * @author Emmanuel Bernard
- * @deprecated Use {@link org.hibernate.search.FullTextSession#getSearchFactory()} instead.
- */
-public abstract class ContextHelper {
-
- public static SearchFactoryImplementor getSearchFactory(Session session) {
- return getSearchFactoryBySFI( (SessionImplementor) session );
- }
-
-
- public static SearchFactoryImplementor getSearchFactoryBySFI(SessionImplementor session) {
- PostInsertEventListener[] listeners = session.getListeners().getPostInsertEventListeners();
- FullTextIndexEventListener listener = null;
- //FIXME this sucks since we mandante the event listener use
- for ( PostInsertEventListener candidate : listeners ) {
- if ( candidate instanceof FullTextIndexEventListener ) {
- listener = (FullTextIndexEventListener) candidate;
- break;
- }
- }
- if ( listener == null ) throw new HibernateException(
- "Hibernate Search Event listeners not configured, please check the reference documentation and the " +
- "application's hibernate.cfg.xml" );
- return listener.getSearchFactoryImplementor();
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.util;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.event.PostInsertEventListener;
+import org.hibernate.search.event.FullTextIndexEventListener;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+
+/**
+ * @author Emmanuel Bernard
+ * @deprecated Use {@link org.hibernate.search.FullTextSession#getSearchFactory()} instead.
+ */
+public abstract class ContextHelper {
+
+ public static SearchFactoryImplementor getSearchFactory(Session session) {
+ return getSearchFactoryBySFI( (SessionImplementor) session );
+ }
+
+
+ public static SearchFactoryImplementor getSearchFactoryBySFI(SessionImplementor session) {
+ PostInsertEventListener[] listeners = session.getListeners().getPostInsertEventListeners();
+ FullTextIndexEventListener listener = null;
+ //FIXME this sucks since we mandante the event listener use
+ for ( PostInsertEventListener candidate : listeners ) {
+ if ( candidate instanceof FullTextIndexEventListener ) {
+ listener = (FullTextIndexEventListener) candidate;
+ break;
+ }
+ }
+ if ( listener == null ) throw new HibernateException(
+ "Hibernate Search Event listeners not configured, please check the reference documentation and the " +
+ "application's hibernate.cfg.xml" );
+ return listener.getSearchFactoryImplementor();
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/util/DelegateNamedAnalyzer.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/util/DelegateNamedAnalyzer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/util/DelegateNamedAnalyzer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.util;
import java.io.IOException;
Modified: search/trunk/src/main/java/org/hibernate/search/util/FileHelper.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/util/FileHelper.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/util/FileHelper.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,179 +1,202 @@
-//$Id$
-package org.hibernate.search.util;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.channels.FileChannel;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.slf4j.Logger;
-
-/**
- * Utility class for synchronizing files/directories.
- *
- * @author Emmanuel Bernard
- * @author Sanne Grinovero
- * @author Hardy Ferentschik
- */
-public abstract class FileHelper {
-
- private static final Logger log = LoggerFactory.make();
- private static final int FAT_PRECISION = 2000;
- public static final long DEFAULT_COPY_BUFFER_SIZE = 16 * 1024 * 1024; // 16 MB
-
-
- public static boolean areInSync(File source, File destination) throws IOException {
- if ( source.isDirectory() ) {
- if ( !destination.exists() ) {
- return false;
- }
- else if ( !destination.isDirectory() ) {
- throw new IOException(
- "Source and Destination not of the same type:"
- + source.getCanonicalPath() + " , " + destination.getCanonicalPath()
- );
- }
- String[] sources = source.list();
- Set<String> srcNames = new HashSet<String>( Arrays.asList( sources ) );
- String[] dests = destination.list();
-
- // check for files in destination and not in source
- for ( String fileName : dests ) {
- if ( !srcNames.contains( fileName ) ) {
- return false;
- }
- }
-
- boolean inSync = true;
- for ( String fileName : sources ) {
- File srcFile = new File( source, fileName );
- File destFile = new File( destination, fileName );
- if ( !areInSync( srcFile, destFile ) ) {
- inSync = false;
- break;
- }
- }
- return inSync;
- }
- else {
- if ( destination.exists() && destination.isFile() ) {
- long sts = source.lastModified() / FAT_PRECISION;
- long dts = destination.lastModified() / FAT_PRECISION;
- return sts == dts;
- }
- else {
- return false;
- }
- }
- }
-
- public static void synchronize(File source, File destination, boolean smart) throws IOException {
- synchronize( source, destination, smart, DEFAULT_COPY_BUFFER_SIZE );
- }
-
- public static void synchronize(File source, File destination, boolean smart, long chunkSize) throws IOException {
- if ( chunkSize <= 0 ) {
- log.warn( "Chunk size must be positive: using default value." );
- chunkSize = DEFAULT_COPY_BUFFER_SIZE;
- }
- if ( source.isDirectory() ) {
- if ( !destination.exists() ) {
- if ( !destination.mkdirs() ) {
- throw new IOException( "Could not create path " + destination );
- }
- }
- else if ( !destination.isDirectory() ) {
- throw new IOException(
- "Source and Destination not of the same type:"
- + source.getCanonicalPath() + " , " + destination.getCanonicalPath()
- );
- }
- String[] sources = source.list();
- Set<String> srcNames = new HashSet<String>( Arrays.asList( sources ) );
- String[] dests = destination.list();
-
- //delete files not present in source
- for ( String fileName : dests ) {
- if ( !srcNames.contains( fileName ) ) {
- delete( new File( destination, fileName ) );
- }
- }
- //copy each file from source
- for ( String fileName : sources ) {
- File srcFile = new File( source, fileName );
- File destFile = new File( destination, fileName );
- synchronize( srcFile, destFile, smart, chunkSize );
- }
- }
- else {
- if ( destination.exists() && destination.isDirectory() ) {
- delete( destination );
- }
- if ( destination.exists() ) {
- long sts = source.lastModified() / FAT_PRECISION;
- long dts = destination.lastModified() / FAT_PRECISION;
- //do not copy if smart and same timestamp and same length
- if ( !smart || sts == 0 || sts != dts || source.length() != destination.length() ) {
- copyFile( source, destination, chunkSize );
- }
- }
- else {
- copyFile( source, destination, chunkSize );
- }
- }
- }
-
- private static void copyFile(File srcFile, File destFile, long chunkSize) throws IOException {
- FileInputStream is = null;
- FileOutputStream os = null;
- try {
- is = new FileInputStream( srcFile );
- FileChannel iChannel = is.getChannel();
- os = new FileOutputStream( destFile, false );
- FileChannel oChannel = os.getChannel();
- long doneBytes = 0L;
- long todoBytes = srcFile.length();
- while ( todoBytes != 0L ) {
- long iterationBytes = Math.min( todoBytes, chunkSize );
- long transferredLength = oChannel.transferFrom( iChannel, doneBytes, iterationBytes );
- if ( iterationBytes != transferredLength ) {
- throw new IOException(
- "Error during file transfer: expected "
- + iterationBytes + " bytes, only " + transferredLength + " bytes copied."
- );
- }
- doneBytes += transferredLength;
- todoBytes -= transferredLength;
- }
- }
- finally {
- if ( is != null ) {
- is.close();
- }
- if ( os != null ) {
- os.close();
- }
- }
- boolean successTimestampOp = destFile.setLastModified( srcFile.lastModified() );
- if ( !successTimestampOp ) {
- log.warn( "Could not change timestamp for {}. Index synchronization may be slow.", destFile );
- }
- }
-
- public static void delete(File file) {
- if ( file.isDirectory() ) {
- for ( File subFile : file.listFiles() ) {
- delete( subFile );
- }
- }
- if ( file.exists() ) {
- if ( !file.delete() ) {
- log.error( "Could not delete {}", file );
- }
- }
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.slf4j.Logger;
+
+/**
+ * Utility class for synchronizing files/directories.
+ *
+ * @author Emmanuel Bernard
+ * @author Sanne Grinovero
+ * @author Hardy Ferentschik
+ */
+public abstract class FileHelper {
+
+ private static final Logger log = LoggerFactory.make();
+ private static final int FAT_PRECISION = 2000;
+ public static final long DEFAULT_COPY_BUFFER_SIZE = 16 * 1024 * 1024; // 16 MB
+
+
+ public static boolean areInSync(File source, File destination) throws IOException {
+ if ( source.isDirectory() ) {
+ if ( !destination.exists() ) {
+ return false;
+ }
+ else if ( !destination.isDirectory() ) {
+ throw new IOException(
+ "Source and Destination not of the same type:"
+ + source.getCanonicalPath() + " , " + destination.getCanonicalPath()
+ );
+ }
+ String[] sources = source.list();
+ Set<String> srcNames = new HashSet<String>( Arrays.asList( sources ) );
+ String[] dests = destination.list();
+
+ // check for files in destination and not in source
+ for ( String fileName : dests ) {
+ if ( !srcNames.contains( fileName ) ) {
+ return false;
+ }
+ }
+
+ boolean inSync = true;
+ for ( String fileName : sources ) {
+ File srcFile = new File( source, fileName );
+ File destFile = new File( destination, fileName );
+ if ( !areInSync( srcFile, destFile ) ) {
+ inSync = false;
+ break;
+ }
+ }
+ return inSync;
+ }
+ else {
+ if ( destination.exists() && destination.isFile() ) {
+ long sts = source.lastModified() / FAT_PRECISION;
+ long dts = destination.lastModified() / FAT_PRECISION;
+ return sts == dts;
+ }
+ else {
+ return false;
+ }
+ }
+ }
+
+ public static void synchronize(File source, File destination, boolean smart) throws IOException {
+ synchronize( source, destination, smart, DEFAULT_COPY_BUFFER_SIZE );
+ }
+
+ public static void synchronize(File source, File destination, boolean smart, long chunkSize) throws IOException {
+ if ( chunkSize <= 0 ) {
+ log.warn( "Chunk size must be positive: using default value." );
+ chunkSize = DEFAULT_COPY_BUFFER_SIZE;
+ }
+ if ( source.isDirectory() ) {
+ if ( !destination.exists() ) {
+ if ( !destination.mkdirs() ) {
+ throw new IOException( "Could not create path " + destination );
+ }
+ }
+ else if ( !destination.isDirectory() ) {
+ throw new IOException(
+ "Source and Destination not of the same type:"
+ + source.getCanonicalPath() + " , " + destination.getCanonicalPath()
+ );
+ }
+ String[] sources = source.list();
+ Set<String> srcNames = new HashSet<String>( Arrays.asList( sources ) );
+ String[] dests = destination.list();
+
+ //delete files not present in source
+ for ( String fileName : dests ) {
+ if ( !srcNames.contains( fileName ) ) {
+ delete( new File( destination, fileName ) );
+ }
+ }
+ //copy each file from source
+ for ( String fileName : sources ) {
+ File srcFile = new File( source, fileName );
+ File destFile = new File( destination, fileName );
+ synchronize( srcFile, destFile, smart, chunkSize );
+ }
+ }
+ else {
+ if ( destination.exists() && destination.isDirectory() ) {
+ delete( destination );
+ }
+ if ( destination.exists() ) {
+ long sts = source.lastModified() / FAT_PRECISION;
+ long dts = destination.lastModified() / FAT_PRECISION;
+ //do not copy if smart and same timestamp and same length
+ if ( !smart || sts == 0 || sts != dts || source.length() != destination.length() ) {
+ copyFile( source, destination, chunkSize );
+ }
+ }
+ else {
+ copyFile( source, destination, chunkSize );
+ }
+ }
+ }
+
+ private static void copyFile(File srcFile, File destFile, long chunkSize) throws IOException {
+ FileInputStream is = null;
+ FileOutputStream os = null;
+ try {
+ is = new FileInputStream( srcFile );
+ FileChannel iChannel = is.getChannel();
+ os = new FileOutputStream( destFile, false );
+ FileChannel oChannel = os.getChannel();
+ long doneBytes = 0L;
+ long todoBytes = srcFile.length();
+ while ( todoBytes != 0L ) {
+ long iterationBytes = Math.min( todoBytes, chunkSize );
+ long transferredLength = oChannel.transferFrom( iChannel, doneBytes, iterationBytes );
+ if ( iterationBytes != transferredLength ) {
+ throw new IOException(
+ "Error during file transfer: expected "
+ + iterationBytes + " bytes, only " + transferredLength + " bytes copied."
+ );
+ }
+ doneBytes += transferredLength;
+ todoBytes -= transferredLength;
+ }
+ }
+ finally {
+ if ( is != null ) {
+ is.close();
+ }
+ if ( os != null ) {
+ os.close();
+ }
+ }
+ boolean successTimestampOp = destFile.setLastModified( srcFile.lastModified() );
+ if ( !successTimestampOp ) {
+ log.warn( "Could not change timestamp for {}. Index synchronization may be slow.", destFile );
+ }
+ }
+
+ public static void delete(File file) {
+ if ( file.isDirectory() ) {
+ for ( File subFile : file.listFiles() ) {
+ delete( subFile );
+ }
+ }
+ if ( file.exists() ) {
+ if ( !file.delete() ) {
+ log.error( "Could not delete {}", file );
+ }
+ }
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/util/FilterCacheModeTypeHelper.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/util/FilterCacheModeTypeHelper.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/util/FilterCacheModeTypeHelper.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.util;
import org.hibernate.search.annotations.FilterCacheModeType;
Modified: search/trunk/src/main/java/org/hibernate/search/util/HibernateSearchResourceLoader.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/util/HibernateSearchResourceLoader.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/util/HibernateSearchResourceLoader.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.util;
import java.io.InputStream;
Modified: search/trunk/src/main/java/org/hibernate/search/util/LoggerFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/util/LoggerFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/util/LoggerFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.util;
import org.slf4j.Logger;
Modified: search/trunk/src/main/java/org/hibernate/search/util/PluginLoader.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/util/PluginLoader.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/util/PluginLoader.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.util;
import org.hibernate.search.SearchException;
Modified: search/trunk/src/main/java/org/hibernate/search/util/ReflectionHelper.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/util/ReflectionHelper.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/util/ReflectionHelper.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,48 +1,71 @@
-//$Id$
-package org.hibernate.search.util;
-
-import java.lang.reflect.Modifier;
-
-import org.hibernate.annotations.common.reflection.XMember;
-import org.hibernate.annotations.common.util.StringHelper;
-
-/**
- * @author Emmanuel Bernard
- * @author Hardy Ferentschik
- */
-public abstract class ReflectionHelper {
-
- private ReflectionHelper() {
- }
-
- /**
- * Get attribute name out of member unless overriden by <code>name</code>.
- *
- * @param member <code>XMember</code> from which to extract the name.
- * @param name Override value which will be returned in case it is not empty.
- *
- * @return 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
- }
-
- public static void setAccessible(XMember member) {
- if ( !Modifier.isPublic( member.getModifiers() ) ) {
- member.setAccessible( true );
- }
- }
-
- public static Object getMemberValue(Object bean, XMember getter) {
- Object value;
- try {
- value = getter.invoke( bean );
- }
- catch ( Exception e ) {
- throw new IllegalStateException( "Could not get property value", e );
- }
- return value;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.util;
+
+import java.lang.reflect.Modifier;
+
+import org.hibernate.annotations.common.reflection.XMember;
+import org.hibernate.annotations.common.util.StringHelper;
+
+/**
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+public abstract class ReflectionHelper {
+
+ private ReflectionHelper() {
+ }
+
+ /**
+ * Get attribute name out of member unless overriden by <code>name</code>.
+ *
+ * @param member <code>XMember</code> from which to extract the name.
+ * @param name Override value which will be returned in case it is not empty.
+ *
+ * @return 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
+ }
+
+ public static void setAccessible(XMember member) {
+ if ( !Modifier.isPublic( member.getModifiers() ) ) {
+ member.setAccessible( true );
+ }
+ }
+
+ public static Object getMemberValue(Object bean, XMember getter) {
+ Object value;
+ try {
+ value = getter.invoke( bean );
+ }
+ catch ( Exception e ) {
+ throw new IllegalStateException( "Could not get property value", e );
+ }
+ return value;
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/util/ScopedAnalyzer.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/util/ScopedAnalyzer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/util/ScopedAnalyzer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.util;
import java.io.Reader;
Modified: search/trunk/src/main/java/org/hibernate/search/util/WeakIdentityHashMap.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/util/WeakIdentityHashMap.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/util/WeakIdentityHashMap.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,1019 +1,1042 @@
-//$Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.hibernate.search.util;
-
-
-import java.lang.ref.ReferenceQueue;
-import java.lang.ref.WeakReference;
-import java.util.AbstractCollection;
-import java.util.AbstractSet;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.ConcurrentModificationException;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * A hashtable-based <tt>Map</tt> implementation with <em>weak keys</em> and
- * using reference-equality in place of object-equality when comparing keys
- * (and values). In an <tt>WeakIdentityHashMap</tt>, two keys <tt>k1</tt> and
- * <tt>k2</tt> are considered equal if and only if <tt>(k1==k2)</tt>.
- * An entry in a <tt>WeakIdentityHashMap</tt> will automatically be removed when
- * its key is no longer in ordinary use. More precisely, the presence of a
- * mapping for a given key will not prevent the key from being discarded by the
- * garbage collector, that is, made finalizable, finalized, and then reclaimed.
- * When a key has been discarded its entry is effectively removed from the map.
- * <p/>
- * <p>Based on java.util.WeakHashMap</p>
- * <p>Based on org.jboss.common.collection.WeakIdentityHashMap</p>
- *
- * @author Dawid Kurzyniec
- * @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
- * @author Emmanuel Bernard
-
- * @see java.util.IdentityHashMap
- * @see java.util.WeakHashMap
- */
-public class WeakIdentityHashMap<K,V> /*extends AbstractMap*/ implements Map<K,V> {
-
- /**
- * The default initial capacity -- MUST be a power of two.
- */
- private static final int DEFAULT_INITIAL_CAPACITY = 16;
-
- /**
- * The maximum capacity, used if a higher value is implicitly specified
- * by either of the constructors with arguments.
- * MUST be a power of two <= 1<<30.
- */
- private static final int MAXIMUM_CAPACITY = 1 << 30;
-
- /**
- * The load fast used when none specified in constructor.
- */
- private static final float DEFAULT_LOAD_FACTOR = 0.75f;
-
- /**
- * The table, resized as necessary. Length MUST Always be a power of two.
- */
- private Entry<K,V>[] table;
-
- /**
- * The number of key-value mappings contained in this weak hash map.
- */
- private int size;
-
- /**
- * The next size value at which to resize (capacity * load factor).
- */
- private int threshold;
-
- /**
- * The load factor for the hash table.
- */
- private final float loadFactor;
-
- /**
- * Reference queue for cleared WeakEntries
- */
- private final ReferenceQueue queue = new ReferenceQueue();
-
- /**
- * The number of times this HashMap has been structurally modified
- * Structural modifications are those that change the number of mappings in
- * the HashMap or otherwise modify its internal structure (e.g.,
- * rehash). This field is used to make iterators on Collection-views of
- * the HashMap fail-fast. (See ConcurrentModificationException).
- */
- private volatile int modCount;
-
- /**
- * Each of these fields are initialized to contain an instance of the
- * appropriate view the first time this view is requested. The views are
- * stateless, so there's no reason to create more than one of each.
- */
- transient volatile Set keySet = null;
- transient volatile Collection values = null;
-
- /**
- * Constructs a new, empty <tt>WeakIdentityHashMap</tt> with the given
- * initial capacity and the given load factor.
- *
- * @param initialCapacity The initial capacity of the
- * <tt>WeakIdentityHashMap</tt>
- * @param loadFactor The load factor of the
- * <tt>WeakIdentityHashMap</tt>
- * @throws IllegalArgumentException If the initial capacity is negative,
- * or if the load factor is nonpositive.
- */
- public WeakIdentityHashMap(int initialCapacity, float loadFactor) {
- if ( initialCapacity < 0 )
- throw new IllegalArgumentException( "Illegal Initial Capacity: " +
- initialCapacity );
- if ( initialCapacity > MAXIMUM_CAPACITY )
- initialCapacity = MAXIMUM_CAPACITY;
-
- if ( loadFactor <= 0 || Float.isNaN( loadFactor ) )
- throw new IllegalArgumentException( "Illegal Load factor: " +
- loadFactor );
- int capacity = 1;
- while ( capacity < initialCapacity )
- capacity <<= 1;
- table = new Entry[capacity];
- this.loadFactor = loadFactor;
- threshold = (int) ( capacity * loadFactor );
- }
-
- /**
- * Constructs a new, empty <tt>WeakIdentityHashMap</tt> with the given
- * initial capacity and the default load factor, which is <tt>0.75</tt>.
- *
- * @param initialCapacity The initial capacity of the
- * <tt>WeakIdentityHashMap</tt>
- * @throws IllegalArgumentException If the initial capacity is negative.
- */
- public WeakIdentityHashMap(int initialCapacity) {
- this( initialCapacity, DEFAULT_LOAD_FACTOR );
- }
-
- /**
- * Constructs a new, empty <tt>WeakIdentityHashMap</tt> with the default
- * initial capacity (16) and the default load factor (0.75).
- */
- public WeakIdentityHashMap() {
- this.loadFactor = DEFAULT_LOAD_FACTOR;
- threshold = DEFAULT_INITIAL_CAPACITY;
- table = new Entry[DEFAULT_INITIAL_CAPACITY];
- }
-
- /**
- * Constructs a new <tt>WeakIdentityHashMap</tt> with the same mappings as
- * the specified <tt>Map</tt>. The <tt>WeakIdentityHashMap</tt> is created
- * with default load factor, which is <tt>0.75</tt> and an initial capacity
- * sufficient to hold the mappings in the specified <tt>Map</tt>.
- *
- * @param t the map whose mappings are to be placed in this map.
- * @throws NullPointerException if the specified map is null.
- */
- public WeakIdentityHashMap(Map t) {
- this( Math.max( (int) ( t.size() / DEFAULT_LOAD_FACTOR ) + 1, 16 ),
- DEFAULT_LOAD_FACTOR );
- putAll( t );
- }
-
- // internal utilities
-
- /**
- * Value representing null keys inside tables.
- */
- private static final Object NULL_KEY = new Object();
-
- /**
- * Use NULL_KEY for key if it is null.
- */
- private static <T> T maskNull(T key) {
- return ( key == null ?
- (T) NULL_KEY : //i don't think there is a better way
- key );
- }
-
- /**
- * Return internal representation of null key back to caller as null
- */
- private static <T> T unmaskNull(T key) {
- return ( key == NULL_KEY ?
- null :
- key );
- }
-
- /**
- * Return a hash code for non-null Object x.
- */
- int hash(Object x) {
- int h = System.identityHashCode( x );
- return h - ( h << 7 ); // that is,, -127 * h
- }
-
- /**
- * Return index for hash code h.
- */
- static int indexFor(int h, int length) {
- return h & ( length - 1 );
- }
-
- /**
- * Expunge stale entries from the table.
- */
- private void expungeStaleEntries() {
- Object r;
- while ( ( r = queue.poll() ) != null ) {
- Entry e = (Entry) r;
- int h = e.hash;
- int i = indexFor( h, table.length );
-
- Entry prev = table[i];
- Entry p = prev;
- while ( p != null ) {
- Entry next = p.next;
- if ( p == e ) {
- if ( prev == e )
- table[i] = next;
- else
- prev.next = next;
- e.next = null; // Help GC
- e.value = null; // " "
- size--;
- break;
- }
- prev = p;
- p = next;
- }
- }
- }
-
- /**
- * Return the table after first expunging stale entries
- */
- private Entry<K,V>[] getTable() {
- expungeStaleEntries();
- return table;
- }
-
- /**
- * Returns the number of key-value mappings in this map.
- * This result is a snapshot, and may not reflect unprocessed
- * entries that will be removed before next attempted access
- * because they are no longer referenced.
- */
- public int size() {
- if ( size == 0 )
- return 0;
- expungeStaleEntries();
- return size;
- }
-
- /**
- * Returns <tt>true</tt> if this map contains no key-value mappings.
- * This result is a snapshot, and may not reflect unprocessed
- * entries that will be removed before next attempted access
- * because they are no longer referenced.
- */
- public boolean isEmpty() {
- return size() == 0;
- }
-
- /**
- * Returns the value to which the specified key is mapped in this weak
- * hash map, or <tt>null</tt> if the map contains no mapping for
- * this key. A return value of <tt>null</tt> does not <i>necessarily</i>
- * indicate that the map contains no mapping for the key; it is also
- * possible that the map explicitly maps the key to <tt>null</tt>. The
- * <tt>containsKey</tt> method may be used to distinguish these two
- * cases.
- *
- * @param key the key whose associated value is to be returned.
- * @return the value to which this map maps the specified key, or
- * <tt>null</tt> if the map contains no mapping for this key.
- * @see #put(Object,Object)
- */
- public V get(Object key) {
- Object k = maskNull( key );
- int h = hash( k );
- Entry<K,V>[] tab = getTable();
- int index = indexFor( h, tab.length );
- Entry<K,V> e = tab[index];
- while ( e != null ) {
- if ( e.hash == h && k == e.get() )
- return e.value;
- e = e.next;
- }
- return null;
- }
-
- /**
- * Returns <tt>true</tt> if this map contains a mapping for the
- * specified key.
- *
- * @param key The key whose presence in this map is to be tested
- * @return <tt>true</tt> if there is a mapping for <tt>key</tt>;
- * <tt>false</tt> otherwise
- */
- public boolean containsKey(Object key) {
- return getEntry( key ) != null;
- }
-
- /**
- * Returns the entry associated with the specified key in the HashMap.
- * Returns null if the HashMap contains no mapping for this key.
- */
- Entry<K,V> getEntry(Object key) {
- Object k = maskNull( key );
- int h = hash( k );
- Entry<K,V>[] tab = getTable();
- int index = indexFor( h, tab.length );
- Entry<K,V> e = tab[index];
- while ( e != null && !( e.hash == h && k == e.get() ) )
- e = e.next;
- return e;
- }
-
- /**
- * Associates the specified value with the specified key in this map.
- * If the map previously contained a mapping for this key, the old
- * value is replaced.
- *
- * @param key key with which the specified value is to be associated.
- * @param value value to be associated with the specified key.
- * @return previous value associated with specified key, or <tt>null</tt>
- * if there was no mapping for key. A <tt>null</tt> return can
- * also indicate that the HashMap previously associated
- * <tt>null</tt> with the specified key.
- */
- public V put(K key, V value) {
- K k = maskNull( key );
- int h = hash( k );
- Entry<K,V>[] tab = getTable();
- int i = indexFor( h, tab.length );
-
- for ( Entry<K,V> e = tab[i]; e != null; e = e.next ) {
- if ( h == e.hash && k == e.get() ) {
- V oldValue = e.value;
- if ( value != oldValue )
- e.value = value;
- return oldValue;
- }
- }
-
- modCount++;
- tab[i] = new Entry<K,V>( k, value, queue, h, tab[i] );
- if ( ++size >= threshold )
- resize( tab.length * 2 );
- return null;
- }
-
- /**
- * Rehashes the contents of this map into a new <tt>HashMap</tt> instance
- * with a larger capacity. This method is called automatically when the
- * number of keys in this map exceeds its capacity and load factor.
- * <p/>
- * Note that this method is a no-op if it's called with newCapacity ==
- * 2*MAXIMUM_CAPACITY (which is Integer.MIN_VALUE).
- *
- * @param newCapacity the new capacity, MUST be a power of two.
- */
- void resize(int newCapacity) {
- // assert (newCapacity & -newCapacity) == newCapacity; // power of 2
-
- Entry<K,V>[] oldTable = getTable();
- int oldCapacity = oldTable.length;
-
- // check if needed
- if ( size < threshold || oldCapacity > newCapacity )
- return;
-
- Entry<K,V>[] newTable = new Entry[newCapacity];
-
- transfer( oldTable, newTable );
- table = newTable;
-
- /*
- * If ignoring null elements and processing ref queue caused massive
- * shrinkage, then restore old table. This should be rare, but avoids
- * unbounded expansion of garbage-filled tables.
- */
- if ( size >= threshold / 2 ) {
- threshold = (int) ( newCapacity * loadFactor );
- }
- else {
- expungeStaleEntries();
- transfer( newTable, oldTable );
- table = oldTable;
- }
- }
-
- /**
- * Transfer all entries from src to dest tables
- */
- private void transfer(Entry<K,V>[] src, Entry<K,V>[] dest) {
- for ( int j = 0; j < src.length; ++j ) {
- Entry<K,V> e = src[j];
- src[j] = null;
- while ( e != null ) {
- Entry<K,V> next = e.next;
- K key = e.get();
- if ( key == null ) {
- e.next = null; // Help GC
- e.value = null; // " "
- size--;
- }
- else {
- int i = indexFor( e.hash, dest.length );
- e.next = dest[i];
- dest[i] = e;
- }
- e = next;
- }
- }
- }
-
- /**
- * Copies all of the mappings from the specified map to this map These
- * mappings will replace any mappings that this map had for any of the
- * keys currently in the specified map.<p>
- *
- * @param t mappings to be stored in this map.
- * @throws NullPointerException if the specified map is null.
- */
- public void putAll(Map<? extends K, ? extends V> t) {
- // Expand enough to hold t's elements without resizing.
- int n = t.size();
- if ( n == 0 )
- return;
- if ( n >= threshold ) {
- n = (int) ( n / loadFactor + 1 );
- if ( n > MAXIMUM_CAPACITY )
- n = MAXIMUM_CAPACITY;
- int capacity = table.length;
- while ( capacity < n )
- capacity <<= 1;
- resize( capacity );
- }
-
- for ( Iterator i = t.entrySet().iterator(); i.hasNext(); ) {
- Map.Entry<K,V> e = (Map.Entry<K,V>) i.next(); //FIXME should not have to cast
- put( e.getKey(), e.getValue() );
- }
- }
-
- /**
- * Removes the mapping for this key from this map if present.
- *
- * @param key key whose mapping is to be removed from the map.
- * @return previous value associated with specified key, or <tt>null</tt>
- * if there was no mapping for key. A <tt>null</tt> return can
- * also indicate that the map previously associated <tt>null</tt>
- * with the specified key.
- */
- public V remove(Object key) {
- Object k = maskNull( key );
- int h = hash( k );
- Entry<K,V>[] tab = getTable();
- int i = indexFor( h, tab.length );
- Entry<K,V> prev = tab[i];
- Entry<K,V> e = prev;
-
- while ( e != null ) {
- Entry<K,V> next = e.next;
- if ( h == e.hash && k == e.get() ) {
- modCount++;
- size--;
- if ( prev == e )
- tab[i] = next;
- else
- prev.next = next;
- return e.value;
- }
- prev = e;
- e = next;
- }
-
- return null;
- }
-
-
- /**
- * Special version of remove needed by Entry set
- */
- Entry removeMapping(Object o) {
- if ( !( o instanceof Map.Entry ) )
- return null;
- Entry[] tab = getTable();
- Map.Entry entry = (Map.Entry) o;
- Object k = maskNull( entry.getKey() );
- int h = hash( k );
- int i = indexFor( h, tab.length );
- Entry prev = tab[i];
- Entry e = prev;
-
- while ( e != null ) {
- Entry next = e.next;
- if ( h == e.hash && e.equals( entry ) ) {
- modCount++;
- size--;
- if ( prev == e )
- tab[i] = next;
- else
- prev.next = next;
- return e;
- }
- prev = e;
- e = next;
- }
-
- return null;
- }
-
- /**
- * Removes all mappings from this map.
- */
- public void clear() {
- // clear out ref queue. We don't need to expunge entries
- // since table is getting cleared.
- while ( queue.poll() != null )
- ;
-
- modCount++;
- Entry tab[] = table;
- for ( int i = 0; i < tab.length; ++i )
- tab[i] = null;
- size = 0;
-
- // Allocation of array may have caused GC, which may have caused
- // additional entries to go stale. Removing these entries from the
- // reference queue will make them eligible for reclamation.
- while ( queue.poll() != null )
- ;
- }
-
- /**
- * Returns <tt>true</tt> if this map maps one or more keys to the
- * specified value.
- *
- * @param value value whose presence in this map is to be tested.
- * @return <tt>true</tt> if this map maps one or more keys to the
- * specified value.
- */
- public boolean containsValue(Object value) {
- if ( value == null )
- return containsNullValue();
-
- Entry tab[] = getTable();
- for ( int i = tab.length; i-- > 0; )
- for ( Entry e = tab[i]; e != null; e = e.next )
- if ( value.equals( e.value ) )
- return true;
- return false;
- }
-
- /**
- * Special-case code for containsValue with null argument
- */
- private boolean containsNullValue() {
- Entry tab[] = getTable();
- for ( int i = tab.length; i-- > 0; )
- for ( Entry e = tab[i]; e != null; e = e.next )
- if ( e.value == null )
- return true;
- return false;
- }
-
- /**
- * Remove elements having the according value.
- * Intended to avoid concurrent access exceptions
- * It is expected that nobody add a key being removed by value
- *
- * @param value value whose presence in this map is to be removed.
- * @return <tt>true</tt> if this map maps one or more keys to the
- * specified value.
- */
- public boolean removeValue(Object value) {
- if ( value == null )
- return removeNullValue();
-
- Entry tab[] = getTable();
- Set keys = new HashSet();
- for ( int i = tab.length; i-- > 0; )
- for ( Entry e = tab[i]; e != null; e = e.next )
- if ( value.equals( e.value ) )
- keys.add( e.getKey() );
- for ( Object key : keys ) remove( key );
- return !keys.isEmpty();
- }
-
- /**
- * Special-case code for removeValue with null argument
- */
- private boolean removeNullValue() {
- Entry tab[] = getTable();
- Set keys = new HashSet();
- for ( int i = tab.length; i-- > 0; )
- for ( Entry e = tab[i]; e != null; e = e.next )
- if ( e.value == null )
- keys.add( e.getKey() );
- for ( Object key : keys ) remove( key );
- return !keys.isEmpty();
- }
-
- /**
- * The entries in this hash table extend WeakReference, using its main ref
- * field as the key.
- */
- private static class Entry<K,V> extends WeakReference<K> implements Map.Entry<K,V> {
- private V value;
- private final int hash;
- private Entry<K,V> next;
-
- /**
- * Create new entry.
- */
- Entry(K key, V value, ReferenceQueue queue,
- int hash, Entry<K,V> next) {
- super( key, queue );
- this.value = value;
- this.hash = hash;
- this.next = next;
- }
-
- public K getKey() {
- return WeakIdentityHashMap.unmaskNull( this.get() );
- }
-
- public V getValue() {
- return value;
- }
-
- public V setValue(V newValue) {
- V oldValue = value;
- value = newValue;
- return oldValue;
- }
-
- public boolean equals(Object o) {
- if ( !( o instanceof Map.Entry ) )
- return false;
- Map.Entry e = (Map.Entry) o;
- Object k1 = getKey();
- Object k2 = e.getKey();
- if ( k1 == k2 ) {
- Object v1 = getValue();
- Object v2 = e.getValue();
- if ( v1 == v2 || ( v1 != null && v1.equals( v2 ) ) )
- return true;
- }
- return false;
- }
-
- public int hashCode() {
- Object k = getKey();
- Object v = getValue();
- return ( ( k == null ?
- 0 :
- System.identityHashCode( k ) ) ^
- ( v == null ?
- 0 :
- v.hashCode() ) );
- }
-
- public String toString() {
- return getKey() + "=" + getValue();
- }
- }
-
- private abstract class HashIterator<E> implements Iterator<E> {
- int index;
- Entry<K,V> entry = null;
- Entry<K,V> lastReturned = null;
- int expectedModCount = modCount;
-
- /**
- * Strong reference needed to avoid disappearance of key
- * between hasNext and next
- */
- Object nextKey = null;
-
- /**
- * Strong reference needed to avoid disappearance of key
- * between nextEntry() and any use of the entry
- */
- Object currentKey = null;
-
- HashIterator() {
- index = ( size() != 0 ?
- table.length :
- 0 );
- }
-
- public boolean hasNext() {
- Entry[] t = table;
-
- while ( nextKey == null ) {
- Entry e = entry;
- int i = index;
- while ( e == null && i > 0 )
- e = t[--i];
- entry = e;
- index = i;
- if ( e == null ) {
- currentKey = null;
- return false;
- }
- nextKey = e.get(); // hold on to key in strong ref
- if ( nextKey == null )
- entry = entry.next;
- }
- return true;
- }
-
- /**
- * The common parts of next() across different types of iterators
- */
- protected Entry<K,V> nextEntry() {
- if ( modCount != expectedModCount )
- throw new ConcurrentModificationException();
- if ( nextKey == null && !hasNext() )
- throw new NoSuchElementException();
-
- lastReturned = entry;
- entry = entry.next;
- currentKey = nextKey;
- nextKey = null;
- return lastReturned;
- }
-
- public void remove() {
- if ( lastReturned == null )
- throw new IllegalStateException();
- if ( modCount != expectedModCount )
- throw new ConcurrentModificationException();
-
- WeakIdentityHashMap.this.remove( currentKey );
- expectedModCount = modCount;
- lastReturned = null;
- currentKey = null;
- }
-
- }
-
- private class ValueIterator extends HashIterator {
- public Object next() {
- return nextEntry().value;
- }
- }
-
- private class KeyIterator extends HashIterator {
- public Object next() {
- return nextEntry().getKey();
- }
- }
-
- private class EntryIterator extends HashIterator<Map.Entry<K,V>> {
- public Map.Entry<K,V> next() {
- return nextEntry();
- }
- }
-
- // Views
-
- private transient Set<Map.Entry<K,V>> entrySet = null;
-
- /**
- * Returns a set view of the keys contained in this map. The set is
- * backed by the map, so changes to the map are reflected in the set, and
- * vice-versa. The set supports element removal, which removes the
- * corresponding mapping from this map, via the <tt>Iterator.remove</tt>,
- * <tt>Set.remove</tt>, <tt>removeAll</tt>, <tt>retainAll</tt>, and
- * <tt>clear</tt> operations. It does not support the <tt>add</tt> or
- * <tt>addAll</tt> operations.
- *
- * @return a set view of the keys contained in this map.
- */
- public Set keySet() {
- Set ks = keySet;
- return ( ks != null ?
- ks :
- ( keySet = new KeySet() ) );
- }
-
- private class KeySet extends AbstractSet {
- public Iterator iterator() {
- return new KeyIterator();
- }
-
- public int size() {
- return WeakIdentityHashMap.this.size();
- }
-
- public boolean contains(Object o) {
- return containsKey( o );
- }
-
- public boolean remove(Object o) {
- if ( containsKey( o ) ) {
- WeakIdentityHashMap.this.remove( o );
- return true;
- }
- else
- return false;
- }
-
- public void clear() {
- WeakIdentityHashMap.this.clear();
- }
-
- public Object[] toArray() {
- Collection c = new ArrayList( size() );
- for ( Iterator i = iterator(); i.hasNext(); )
- c.add( i.next() );
- return c.toArray();
- }
-
- public Object[] toArray(Object a[]) {
- Collection c = new ArrayList( size() );
- for ( Iterator i = iterator(); i.hasNext(); )
- c.add( i.next() );
- return c.toArray( a );
- }
- }
-
- /**
- * Returns a collection view of the values contained in this map. The
- * collection is backed by the map, so changes to the map are reflected in
- * the collection, and vice-versa. The collection supports element
- * removal, which removes the corresponding mapping from this map, via the
- * <tt>Iterator.remove</tt>, <tt>Collection.remove</tt>,
- * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt> operations.
- * It does not support the <tt>add</tt> or <tt>addAll</tt> operations.
- *
- * @return a collection view of the values contained in this map.
- */
- public Collection values() {
- Collection vs = values;
- return ( vs != null ?
- vs :
- ( values = new Values() ) );
- }
-
- private class Values extends AbstractCollection {
- public Iterator iterator() {
- return new ValueIterator();
- }
-
- public int size() {
- return WeakIdentityHashMap.this.size();
- }
-
- public boolean contains(Object o) {
- return containsValue( o );
- }
-
- public void clear() {
- WeakIdentityHashMap.this.clear();
- }
-
- public Object[] toArray() {
- Collection c = new ArrayList( size() );
- for ( Iterator i = iterator(); i.hasNext(); )
- c.add( i.next() );
- return c.toArray();
- }
-
- public Object[] toArray(Object a[]) {
- Collection c = new ArrayList( size() );
- for ( Iterator i = iterator(); i.hasNext(); )
- c.add( i.next() );
- return c.toArray( a );
- }
- }
-
- /**
- * Returns a collection view of the mappings contained in this map. Each
- * element in the returned collection is a <tt>Map.Entry</tt>. The
- * collection is backed by the map, so changes to the map are reflected in
- * the collection, and vice-versa. The collection supports element
- * removal, which removes the corresponding mapping from the map, via the
- * <tt>Iterator.remove</tt>, <tt>Collection.remove</tt>,
- * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt> operations.
- * It does not support the <tt>add</tt> or <tt>addAll</tt> operations.
- *
- * @return a collection view of the mappings contained in this map.
- * @see java.util.Map.Entry
- */
- public Set<Map.Entry<K,V>> entrySet() {
- Set<Map.Entry<K,V>> es = entrySet;
- return ( es != null ?
- es :
- ( entrySet = new EntrySet() ) );
- }
-
- private class EntrySet extends AbstractSet<Map.Entry<K,V>> {
- public Iterator<Map.Entry<K,V>> iterator() {
- return new EntryIterator();
- }
-
- public boolean contains(Object o) {
- if ( !( o instanceof Map.Entry ) )
- return false;
- Map.Entry e = (Map.Entry) o;
- Object k = e.getKey();
- Entry candidate = getEntry( e.getKey() );
- return candidate != null && candidate.equals( e );
- }
-
- public boolean remove(Object o) {
- return removeMapping( o ) != null;
- }
-
- public int size() {
- return WeakIdentityHashMap.this.size();
- }
-
- public void clear() {
- WeakIdentityHashMap.this.clear();
- }
-
- public Object[] toArray() {
- Collection c = new ArrayList( size() );
- for ( Iterator i = iterator(); i.hasNext(); )
- c.add( new SimpleEntry( (Map.Entry) i.next() ) );
- return c.toArray();
- }
-
- public Object[] toArray(Object a[]) {
- Collection c = new ArrayList( size() );
- for ( Iterator i = iterator(); i.hasNext(); )
- c.add( new SimpleEntry( (Map.Entry) i.next() ) );
- return c.toArray( a );
- }
- }
-
- static class SimpleEntry implements Map.Entry {
- Object key;
- Object value;
-
- public SimpleEntry(Object key, Object value) {
- this.key = key;
- this.value = value;
- }
-
- public SimpleEntry(Map.Entry e) {
- this.key = e.getKey();
- this.value = e.getValue();
- }
-
- public Object getKey() {
- return key;
- }
-
- public Object getValue() {
- return value;
- }
-
- public Object setValue(Object value) {
- Object oldValue = this.value;
- this.value = value;
- return oldValue;
- }
-
- public boolean equals(Object o) {
- if ( !( o instanceof Map.Entry ) )
- return false;
- Map.Entry e = (Map.Entry) o;
- return eq( key, e.getKey() ) && eq( value, e.getValue() );
- }
-
- public int hashCode() {
- Object v;
- return ( ( key == null ) ?
- 0 :
- key.hashCode() ) ^
- ( ( value == null ) ?
- 0 :
- value.hashCode() );
- }
-
- public String toString() {
- return key + "=" + value;
- }
-
- private static boolean eq(Object o1, Object o2) {
- return ( o1 == null ?
- o2 == null :
- o1.equals( o2 ) );
- }
- }
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.hibernate.search.util;
+
+
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.util.AbstractCollection;
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.ConcurrentModificationException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+/**
+ * A hashtable-based <tt>Map</tt> implementation with <em>weak keys</em> and
+ * using reference-equality in place of object-equality when comparing keys
+ * (and values). In an <tt>WeakIdentityHashMap</tt>, two keys <tt>k1</tt> and
+ * <tt>k2</tt> are considered equal if and only if <tt>(k1==k2)</tt>.
+ * An entry in a <tt>WeakIdentityHashMap</tt> will automatically be removed when
+ * its key is no longer in ordinary use. More precisely, the presence of a
+ * mapping for a given key will not prevent the key from being discarded by the
+ * garbage collector, that is, made finalizable, finalized, and then reclaimed.
+ * When a key has been discarded its entry is effectively removed from the map.
+ * <p/>
+ * <p>Based on java.util.WeakHashMap</p>
+ * <p>Based on org.jboss.common.collection.WeakIdentityHashMap</p>
+ *
+ * @author Dawid Kurzyniec
+ * @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
+ * @author Emmanuel Bernard
+
+ * @see java.util.IdentityHashMap
+ * @see java.util.WeakHashMap
+ */
+public class WeakIdentityHashMap<K,V> /*extends AbstractMap*/ implements Map<K,V> {
+
+ /**
+ * The default initial capacity -- MUST be a power of two.
+ */
+ private static final int DEFAULT_INITIAL_CAPACITY = 16;
+
+ /**
+ * The maximum capacity, used if a higher value is implicitly specified
+ * by either of the constructors with arguments.
+ * MUST be a power of two <= 1<<30.
+ */
+ private static final int MAXIMUM_CAPACITY = 1 << 30;
+
+ /**
+ * The load fast used when none specified in constructor.
+ */
+ private static final float DEFAULT_LOAD_FACTOR = 0.75f;
+
+ /**
+ * The table, resized as necessary. Length MUST Always be a power of two.
+ */
+ private Entry<K,V>[] table;
+
+ /**
+ * The number of key-value mappings contained in this weak hash map.
+ */
+ private int size;
+
+ /**
+ * The next size value at which to resize (capacity * load factor).
+ */
+ private int threshold;
+
+ /**
+ * The load factor for the hash table.
+ */
+ private final float loadFactor;
+
+ /**
+ * Reference queue for cleared WeakEntries
+ */
+ private final ReferenceQueue queue = new ReferenceQueue();
+
+ /**
+ * The number of times this HashMap has been structurally modified
+ * Structural modifications are those that change the number of mappings in
+ * the HashMap or otherwise modify its internal structure (e.g.,
+ * rehash). This field is used to make iterators on Collection-views of
+ * the HashMap fail-fast. (See ConcurrentModificationException).
+ */
+ private volatile int modCount;
+
+ /**
+ * Each of these fields are initialized to contain an instance of the
+ * appropriate view the first time this view is requested. The views are
+ * stateless, so there's no reason to create more than one of each.
+ */
+ transient volatile Set keySet = null;
+ transient volatile Collection values = null;
+
+ /**
+ * Constructs a new, empty <tt>WeakIdentityHashMap</tt> with the given
+ * initial capacity and the given load factor.
+ *
+ * @param initialCapacity The initial capacity of the
+ * <tt>WeakIdentityHashMap</tt>
+ * @param loadFactor The load factor of the
+ * <tt>WeakIdentityHashMap</tt>
+ * @throws IllegalArgumentException If the initial capacity is negative,
+ * or if the load factor is nonpositive.
+ */
+ public WeakIdentityHashMap(int initialCapacity, float loadFactor) {
+ if ( initialCapacity < 0 )
+ throw new IllegalArgumentException( "Illegal Initial Capacity: " +
+ initialCapacity );
+ if ( initialCapacity > MAXIMUM_CAPACITY )
+ initialCapacity = MAXIMUM_CAPACITY;
+
+ if ( loadFactor <= 0 || Float.isNaN( loadFactor ) )
+ throw new IllegalArgumentException( "Illegal Load factor: " +
+ loadFactor );
+ int capacity = 1;
+ while ( capacity < initialCapacity )
+ capacity <<= 1;
+ table = new Entry[capacity];
+ this.loadFactor = loadFactor;
+ threshold = (int) ( capacity * loadFactor );
+ }
+
+ /**
+ * Constructs a new, empty <tt>WeakIdentityHashMap</tt> with the given
+ * initial capacity and the default load factor, which is <tt>0.75</tt>.
+ *
+ * @param initialCapacity The initial capacity of the
+ * <tt>WeakIdentityHashMap</tt>
+ * @throws IllegalArgumentException If the initial capacity is negative.
+ */
+ public WeakIdentityHashMap(int initialCapacity) {
+ this( initialCapacity, DEFAULT_LOAD_FACTOR );
+ }
+
+ /**
+ * Constructs a new, empty <tt>WeakIdentityHashMap</tt> with the default
+ * initial capacity (16) and the default load factor (0.75).
+ */
+ public WeakIdentityHashMap() {
+ this.loadFactor = DEFAULT_LOAD_FACTOR;
+ threshold = DEFAULT_INITIAL_CAPACITY;
+ table = new Entry[DEFAULT_INITIAL_CAPACITY];
+ }
+
+ /**
+ * Constructs a new <tt>WeakIdentityHashMap</tt> with the same mappings as
+ * the specified <tt>Map</tt>. The <tt>WeakIdentityHashMap</tt> is created
+ * with default load factor, which is <tt>0.75</tt> and an initial capacity
+ * sufficient to hold the mappings in the specified <tt>Map</tt>.
+ *
+ * @param t the map whose mappings are to be placed in this map.
+ * @throws NullPointerException if the specified map is null.
+ */
+ public WeakIdentityHashMap(Map t) {
+ this( Math.max( (int) ( t.size() / DEFAULT_LOAD_FACTOR ) + 1, 16 ),
+ DEFAULT_LOAD_FACTOR );
+ putAll( t );
+ }
+
+ // internal utilities
+
+ /**
+ * Value representing null keys inside tables.
+ */
+ private static final Object NULL_KEY = new Object();
+
+ /**
+ * Use NULL_KEY for key if it is null.
+ */
+ private static <T> T maskNull(T key) {
+ return ( key == null ?
+ (T) NULL_KEY : //i don't think there is a better way
+ key );
+ }
+
+ /**
+ * Return internal representation of null key back to caller as null
+ */
+ private static <T> T unmaskNull(T key) {
+ return ( key == NULL_KEY ?
+ null :
+ key );
+ }
+
+ /**
+ * Return a hash code for non-null Object x.
+ */
+ int hash(Object x) {
+ int h = System.identityHashCode( x );
+ return h - ( h << 7 ); // that is,, -127 * h
+ }
+
+ /**
+ * Return index for hash code h.
+ */
+ static int indexFor(int h, int length) {
+ return h & ( length - 1 );
+ }
+
+ /**
+ * Expunge stale entries from the table.
+ */
+ private void expungeStaleEntries() {
+ Object r;
+ while ( ( r = queue.poll() ) != null ) {
+ Entry e = (Entry) r;
+ int h = e.hash;
+ int i = indexFor( h, table.length );
+
+ Entry prev = table[i];
+ Entry p = prev;
+ while ( p != null ) {
+ Entry next = p.next;
+ if ( p == e ) {
+ if ( prev == e )
+ table[i] = next;
+ else
+ prev.next = next;
+ e.next = null; // Help GC
+ e.value = null; // " "
+ size--;
+ break;
+ }
+ prev = p;
+ p = next;
+ }
+ }
+ }
+
+ /**
+ * Return the table after first expunging stale entries
+ */
+ private Entry<K,V>[] getTable() {
+ expungeStaleEntries();
+ return table;
+ }
+
+ /**
+ * Returns the number of key-value mappings in this map.
+ * This result is a snapshot, and may not reflect unprocessed
+ * entries that will be removed before next attempted access
+ * because they are no longer referenced.
+ */
+ public int size() {
+ if ( size == 0 )
+ return 0;
+ expungeStaleEntries();
+ return size;
+ }
+
+ /**
+ * Returns <tt>true</tt> if this map contains no key-value mappings.
+ * This result is a snapshot, and may not reflect unprocessed
+ * entries that will be removed before next attempted access
+ * because they are no longer referenced.
+ */
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Returns the value to which the specified key is mapped in this weak
+ * hash map, or <tt>null</tt> if the map contains no mapping for
+ * this key. A return value of <tt>null</tt> does not <i>necessarily</i>
+ * indicate that the map contains no mapping for the key; it is also
+ * possible that the map explicitly maps the key to <tt>null</tt>. The
+ * <tt>containsKey</tt> method may be used to distinguish these two
+ * cases.
+ *
+ * @param key the key whose associated value is to be returned.
+ * @return the value to which this map maps the specified key, or
+ * <tt>null</tt> if the map contains no mapping for this key.
+ * @see #put(Object,Object)
+ */
+ public V get(Object key) {
+ Object k = maskNull( key );
+ int h = hash( k );
+ Entry<K,V>[] tab = getTable();
+ int index = indexFor( h, tab.length );
+ Entry<K,V> e = tab[index];
+ while ( e != null ) {
+ if ( e.hash == h && k == e.get() )
+ return e.value;
+ e = e.next;
+ }
+ return null;
+ }
+
+ /**
+ * Returns <tt>true</tt> if this map contains a mapping for the
+ * specified key.
+ *
+ * @param key The key whose presence in this map is to be tested
+ * @return <tt>true</tt> if there is a mapping for <tt>key</tt>;
+ * <tt>false</tt> otherwise
+ */
+ public boolean containsKey(Object key) {
+ return getEntry( key ) != null;
+ }
+
+ /**
+ * Returns the entry associated with the specified key in the HashMap.
+ * Returns null if the HashMap contains no mapping for this key.
+ */
+ Entry<K,V> getEntry(Object key) {
+ Object k = maskNull( key );
+ int h = hash( k );
+ Entry<K,V>[] tab = getTable();
+ int index = indexFor( h, tab.length );
+ Entry<K,V> e = tab[index];
+ while ( e != null && !( e.hash == h && k == e.get() ) )
+ e = e.next;
+ return e;
+ }
+
+ /**
+ * Associates the specified value with the specified key in this map.
+ * If the map previously contained a mapping for this key, the old
+ * value is replaced.
+ *
+ * @param key key with which the specified value is to be associated.
+ * @param value value to be associated with the specified key.
+ * @return previous value associated with specified key, or <tt>null</tt>
+ * if there was no mapping for key. A <tt>null</tt> return can
+ * also indicate that the HashMap previously associated
+ * <tt>null</tt> with the specified key.
+ */
+ public V put(K key, V value) {
+ K k = maskNull( key );
+ int h = hash( k );
+ Entry<K,V>[] tab = getTable();
+ int i = indexFor( h, tab.length );
+
+ for ( Entry<K,V> e = tab[i]; e != null; e = e.next ) {
+ if ( h == e.hash && k == e.get() ) {
+ V oldValue = e.value;
+ if ( value != oldValue )
+ e.value = value;
+ return oldValue;
+ }
+ }
+
+ modCount++;
+ tab[i] = new Entry<K,V>( k, value, queue, h, tab[i] );
+ if ( ++size >= threshold )
+ resize( tab.length * 2 );
+ return null;
+ }
+
+ /**
+ * Rehashes the contents of this map into a new <tt>HashMap</tt> instance
+ * with a larger capacity. This method is called automatically when the
+ * number of keys in this map exceeds its capacity and load factor.
+ * <p/>
+ * Note that this method is a no-op if it's called with newCapacity ==
+ * 2*MAXIMUM_CAPACITY (which is Integer.MIN_VALUE).
+ *
+ * @param newCapacity the new capacity, MUST be a power of two.
+ */
+ void resize(int newCapacity) {
+ // assert (newCapacity & -newCapacity) == newCapacity; // power of 2
+
+ Entry<K,V>[] oldTable = getTable();
+ int oldCapacity = oldTable.length;
+
+ // check if needed
+ if ( size < threshold || oldCapacity > newCapacity )
+ return;
+
+ Entry<K,V>[] newTable = new Entry[newCapacity];
+
+ transfer( oldTable, newTable );
+ table = newTable;
+
+ /*
+ * If ignoring null elements and processing ref queue caused massive
+ * shrinkage, then restore old table. This should be rare, but avoids
+ * unbounded expansion of garbage-filled tables.
+ */
+ if ( size >= threshold / 2 ) {
+ threshold = (int) ( newCapacity * loadFactor );
+ }
+ else {
+ expungeStaleEntries();
+ transfer( newTable, oldTable );
+ table = oldTable;
+ }
+ }
+
+ /**
+ * Transfer all entries from src to dest tables
+ */
+ private void transfer(Entry<K,V>[] src, Entry<K,V>[] dest) {
+ for ( int j = 0; j < src.length; ++j ) {
+ Entry<K,V> e = src[j];
+ src[j] = null;
+ while ( e != null ) {
+ Entry<K,V> next = e.next;
+ K key = e.get();
+ if ( key == null ) {
+ e.next = null; // Help GC
+ e.value = null; // " "
+ size--;
+ }
+ else {
+ int i = indexFor( e.hash, dest.length );
+ e.next = dest[i];
+ dest[i] = e;
+ }
+ e = next;
+ }
+ }
+ }
+
+ /**
+ * Copies all of the mappings from the specified map to this map These
+ * mappings will replace any mappings that this map had for any of the
+ * keys currently in the specified map.<p>
+ *
+ * @param t mappings to be stored in this map.
+ * @throws NullPointerException if the specified map is null.
+ */
+ public void putAll(Map<? extends K, ? extends V> t) {
+ // Expand enough to hold t's elements without resizing.
+ int n = t.size();
+ if ( n == 0 )
+ return;
+ if ( n >= threshold ) {
+ n = (int) ( n / loadFactor + 1 );
+ if ( n > MAXIMUM_CAPACITY )
+ n = MAXIMUM_CAPACITY;
+ int capacity = table.length;
+ while ( capacity < n )
+ capacity <<= 1;
+ resize( capacity );
+ }
+
+ for ( Iterator i = t.entrySet().iterator(); i.hasNext(); ) {
+ Map.Entry<K,V> e = (Map.Entry<K,V>) i.next(); //FIXME should not have to cast
+ put( e.getKey(), e.getValue() );
+ }
+ }
+
+ /**
+ * Removes the mapping for this key from this map if present.
+ *
+ * @param key key whose mapping is to be removed from the map.
+ * @return previous value associated with specified key, or <tt>null</tt>
+ * if there was no mapping for key. A <tt>null</tt> return can
+ * also indicate that the map previously associated <tt>null</tt>
+ * with the specified key.
+ */
+ public V remove(Object key) {
+ Object k = maskNull( key );
+ int h = hash( k );
+ Entry<K,V>[] tab = getTable();
+ int i = indexFor( h, tab.length );
+ Entry<K,V> prev = tab[i];
+ Entry<K,V> e = prev;
+
+ while ( e != null ) {
+ Entry<K,V> next = e.next;
+ if ( h == e.hash && k == e.get() ) {
+ modCount++;
+ size--;
+ if ( prev == e )
+ tab[i] = next;
+ else
+ prev.next = next;
+ return e.value;
+ }
+ prev = e;
+ e = next;
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Special version of remove needed by Entry set
+ */
+ Entry removeMapping(Object o) {
+ if ( !( o instanceof Map.Entry ) )
+ return null;
+ Entry[] tab = getTable();
+ Map.Entry entry = (Map.Entry) o;
+ Object k = maskNull( entry.getKey() );
+ int h = hash( k );
+ int i = indexFor( h, tab.length );
+ Entry prev = tab[i];
+ Entry e = prev;
+
+ while ( e != null ) {
+ Entry next = e.next;
+ if ( h == e.hash && e.equals( entry ) ) {
+ modCount++;
+ size--;
+ if ( prev == e )
+ tab[i] = next;
+ else
+ prev.next = next;
+ return e;
+ }
+ prev = e;
+ e = next;
+ }
+
+ return null;
+ }
+
+ /**
+ * Removes all mappings from this map.
+ */
+ public void clear() {
+ // clear out ref queue. We don't need to expunge entries
+ // since table is getting cleared.
+ while ( queue.poll() != null )
+ ;
+
+ modCount++;
+ Entry tab[] = table;
+ for ( int i = 0; i < tab.length; ++i )
+ tab[i] = null;
+ size = 0;
+
+ // Allocation of array may have caused GC, which may have caused
+ // additional entries to go stale. Removing these entries from the
+ // reference queue will make them eligible for reclamation.
+ while ( queue.poll() != null )
+ ;
+ }
+
+ /**
+ * Returns <tt>true</tt> if this map maps one or more keys to the
+ * specified value.
+ *
+ * @param value value whose presence in this map is to be tested.
+ * @return <tt>true</tt> if this map maps one or more keys to the
+ * specified value.
+ */
+ public boolean containsValue(Object value) {
+ if ( value == null )
+ return containsNullValue();
+
+ Entry tab[] = getTable();
+ for ( int i = tab.length; i-- > 0; )
+ for ( Entry e = tab[i]; e != null; e = e.next )
+ if ( value.equals( e.value ) )
+ return true;
+ return false;
+ }
+
+ /**
+ * Special-case code for containsValue with null argument
+ */
+ private boolean containsNullValue() {
+ Entry tab[] = getTable();
+ for ( int i = tab.length; i-- > 0; )
+ for ( Entry e = tab[i]; e != null; e = e.next )
+ if ( e.value == null )
+ return true;
+ return false;
+ }
+
+ /**
+ * Remove elements having the according value.
+ * Intended to avoid concurrent access exceptions
+ * It is expected that nobody add a key being removed by value
+ *
+ * @param value value whose presence in this map is to be removed.
+ * @return <tt>true</tt> if this map maps one or more keys to the
+ * specified value.
+ */
+ public boolean removeValue(Object value) {
+ if ( value == null )
+ return removeNullValue();
+
+ Entry tab[] = getTable();
+ Set keys = new HashSet();
+ for ( int i = tab.length; i-- > 0; )
+ for ( Entry e = tab[i]; e != null; e = e.next )
+ if ( value.equals( e.value ) )
+ keys.add( e.getKey() );
+ for ( Object key : keys ) remove( key );
+ return !keys.isEmpty();
+ }
+
+ /**
+ * Special-case code for removeValue with null argument
+ */
+ private boolean removeNullValue() {
+ Entry tab[] = getTable();
+ Set keys = new HashSet();
+ for ( int i = tab.length; i-- > 0; )
+ for ( Entry e = tab[i]; e != null; e = e.next )
+ if ( e.value == null )
+ keys.add( e.getKey() );
+ for ( Object key : keys ) remove( key );
+ return !keys.isEmpty();
+ }
+
+ /**
+ * The entries in this hash table extend WeakReference, using its main ref
+ * field as the key.
+ */
+ private static class Entry<K,V> extends WeakReference<K> implements Map.Entry<K,V> {
+ private V value;
+ private final int hash;
+ private Entry<K,V> next;
+
+ /**
+ * Create new entry.
+ */
+ Entry(K key, V value, ReferenceQueue queue,
+ int hash, Entry<K,V> next) {
+ super( key, queue );
+ this.value = value;
+ this.hash = hash;
+ this.next = next;
+ }
+
+ public K getKey() {
+ return WeakIdentityHashMap.unmaskNull( this.get() );
+ }
+
+ public V getValue() {
+ return value;
+ }
+
+ public V setValue(V newValue) {
+ V oldValue = value;
+ value = newValue;
+ return oldValue;
+ }
+
+ public boolean equals(Object o) {
+ if ( !( o instanceof Map.Entry ) )
+ return false;
+ Map.Entry e = (Map.Entry) o;
+ Object k1 = getKey();
+ Object k2 = e.getKey();
+ if ( k1 == k2 ) {
+ Object v1 = getValue();
+ Object v2 = e.getValue();
+ if ( v1 == v2 || ( v1 != null && v1.equals( v2 ) ) )
+ return true;
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ Object k = getKey();
+ Object v = getValue();
+ return ( ( k == null ?
+ 0 :
+ System.identityHashCode( k ) ) ^
+ ( v == null ?
+ 0 :
+ v.hashCode() ) );
+ }
+
+ public String toString() {
+ return getKey() + "=" + getValue();
+ }
+ }
+
+ private abstract class HashIterator<E> implements Iterator<E> {
+ int index;
+ Entry<K,V> entry = null;
+ Entry<K,V> lastReturned = null;
+ int expectedModCount = modCount;
+
+ /**
+ * Strong reference needed to avoid disappearance of key
+ * between hasNext and next
+ */
+ Object nextKey = null;
+
+ /**
+ * Strong reference needed to avoid disappearance of key
+ * between nextEntry() and any use of the entry
+ */
+ Object currentKey = null;
+
+ HashIterator() {
+ index = ( size() != 0 ?
+ table.length :
+ 0 );
+ }
+
+ public boolean hasNext() {
+ Entry[] t = table;
+
+ while ( nextKey == null ) {
+ Entry e = entry;
+ int i = index;
+ while ( e == null && i > 0 )
+ e = t[--i];
+ entry = e;
+ index = i;
+ if ( e == null ) {
+ currentKey = null;
+ return false;
+ }
+ nextKey = e.get(); // hold on to key in strong ref
+ if ( nextKey == null )
+ entry = entry.next;
+ }
+ return true;
+ }
+
+ /**
+ * The common parts of next() across different types of iterators
+ */
+ protected Entry<K,V> nextEntry() {
+ if ( modCount != expectedModCount )
+ throw new ConcurrentModificationException();
+ if ( nextKey == null && !hasNext() )
+ throw new NoSuchElementException();
+
+ lastReturned = entry;
+ entry = entry.next;
+ currentKey = nextKey;
+ nextKey = null;
+ return lastReturned;
+ }
+
+ public void remove() {
+ if ( lastReturned == null )
+ throw new IllegalStateException();
+ if ( modCount != expectedModCount )
+ throw new ConcurrentModificationException();
+
+ WeakIdentityHashMap.this.remove( currentKey );
+ expectedModCount = modCount;
+ lastReturned = null;
+ currentKey = null;
+ }
+
+ }
+
+ private class ValueIterator extends HashIterator {
+ public Object next() {
+ return nextEntry().value;
+ }
+ }
+
+ private class KeyIterator extends HashIterator {
+ public Object next() {
+ return nextEntry().getKey();
+ }
+ }
+
+ private class EntryIterator extends HashIterator<Map.Entry<K,V>> {
+ public Map.Entry<K,V> next() {
+ return nextEntry();
+ }
+ }
+
+ // Views
+
+ private transient Set<Map.Entry<K,V>> entrySet = null;
+
+ /**
+ * Returns a set view of the keys contained in this map. The set is
+ * backed by the map, so changes to the map are reflected in the set, and
+ * vice-versa. The set supports element removal, which removes the
+ * corresponding mapping from this map, via the <tt>Iterator.remove</tt>,
+ * <tt>Set.remove</tt>, <tt>removeAll</tt>, <tt>retainAll</tt>, and
+ * <tt>clear</tt> operations. It does not support the <tt>add</tt> or
+ * <tt>addAll</tt> operations.
+ *
+ * @return a set view of the keys contained in this map.
+ */
+ public Set keySet() {
+ Set ks = keySet;
+ return ( ks != null ?
+ ks :
+ ( keySet = new KeySet() ) );
+ }
+
+ private class KeySet extends AbstractSet {
+ public Iterator iterator() {
+ return new KeyIterator();
+ }
+
+ public int size() {
+ return WeakIdentityHashMap.this.size();
+ }
+
+ public boolean contains(Object o) {
+ return containsKey( o );
+ }
+
+ public boolean remove(Object o) {
+ if ( containsKey( o ) ) {
+ WeakIdentityHashMap.this.remove( o );
+ return true;
+ }
+ else
+ return false;
+ }
+
+ public void clear() {
+ WeakIdentityHashMap.this.clear();
+ }
+
+ public Object[] toArray() {
+ Collection c = new ArrayList( size() );
+ for ( Iterator i = iterator(); i.hasNext(); )
+ c.add( i.next() );
+ return c.toArray();
+ }
+
+ public Object[] toArray(Object a[]) {
+ Collection c = new ArrayList( size() );
+ for ( Iterator i = iterator(); i.hasNext(); )
+ c.add( i.next() );
+ return c.toArray( a );
+ }
+ }
+
+ /**
+ * Returns a collection view of the values contained in this map. The
+ * collection is backed by the map, so changes to the map are reflected in
+ * the collection, and vice-versa. The collection supports element
+ * removal, which removes the corresponding mapping from this map, via the
+ * <tt>Iterator.remove</tt>, <tt>Collection.remove</tt>,
+ * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt> operations.
+ * It does not support the <tt>add</tt> or <tt>addAll</tt> operations.
+ *
+ * @return a collection view of the values contained in this map.
+ */
+ public Collection values() {
+ Collection vs = values;
+ return ( vs != null ?
+ vs :
+ ( values = new Values() ) );
+ }
+
+ private class Values extends AbstractCollection {
+ public Iterator iterator() {
+ return new ValueIterator();
+ }
+
+ public int size() {
+ return WeakIdentityHashMap.this.size();
+ }
+
+ public boolean contains(Object o) {
+ return containsValue( o );
+ }
+
+ public void clear() {
+ WeakIdentityHashMap.this.clear();
+ }
+
+ public Object[] toArray() {
+ Collection c = new ArrayList( size() );
+ for ( Iterator i = iterator(); i.hasNext(); )
+ c.add( i.next() );
+ return c.toArray();
+ }
+
+ public Object[] toArray(Object a[]) {
+ Collection c = new ArrayList( size() );
+ for ( Iterator i = iterator(); i.hasNext(); )
+ c.add( i.next() );
+ return c.toArray( a );
+ }
+ }
+
+ /**
+ * Returns a collection view of the mappings contained in this map. Each
+ * element in the returned collection is a <tt>Map.Entry</tt>. The
+ * collection is backed by the map, so changes to the map are reflected in
+ * the collection, and vice-versa. The collection supports element
+ * removal, which removes the corresponding mapping from the map, via the
+ * <tt>Iterator.remove</tt>, <tt>Collection.remove</tt>,
+ * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt> operations.
+ * It does not support the <tt>add</tt> or <tt>addAll</tt> operations.
+ *
+ * @return a collection view of the mappings contained in this map.
+ * @see java.util.Map.Entry
+ */
+ public Set<Map.Entry<K,V>> entrySet() {
+ Set<Map.Entry<K,V>> es = entrySet;
+ return ( es != null ?
+ es :
+ ( entrySet = new EntrySet() ) );
+ }
+
+ private class EntrySet extends AbstractSet<Map.Entry<K,V>> {
+ public Iterator<Map.Entry<K,V>> iterator() {
+ return new EntryIterator();
+ }
+
+ public boolean contains(Object o) {
+ if ( !( o instanceof Map.Entry ) )
+ return false;
+ Map.Entry e = (Map.Entry) o;
+ Object k = e.getKey();
+ Entry candidate = getEntry( e.getKey() );
+ return candidate != null && candidate.equals( e );
+ }
+
+ public boolean remove(Object o) {
+ return removeMapping( o ) != null;
+ }
+
+ public int size() {
+ return WeakIdentityHashMap.this.size();
+ }
+
+ public void clear() {
+ WeakIdentityHashMap.this.clear();
+ }
+
+ public Object[] toArray() {
+ Collection c = new ArrayList( size() );
+ for ( Iterator i = iterator(); i.hasNext(); )
+ c.add( new SimpleEntry( (Map.Entry) i.next() ) );
+ return c.toArray();
+ }
+
+ public Object[] toArray(Object a[]) {
+ Collection c = new ArrayList( size() );
+ for ( Iterator i = iterator(); i.hasNext(); )
+ c.add( new SimpleEntry( (Map.Entry) i.next() ) );
+ return c.toArray( a );
+ }
+ }
+
+ static class SimpleEntry implements Map.Entry {
+ Object key;
+ Object value;
+
+ public SimpleEntry(Object key, Object value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public SimpleEntry(Map.Entry e) {
+ this.key = e.getKey();
+ this.value = e.getValue();
+ }
+
+ public Object getKey() {
+ return key;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public Object setValue(Object value) {
+ Object oldValue = this.value;
+ this.value = value;
+ return oldValue;
+ }
+
+ public boolean equals(Object o) {
+ if ( !( o instanceof Map.Entry ) )
+ return false;
+ Map.Entry e = (Map.Entry) o;
+ return eq( key, e.getKey() ) && eq( value, e.getValue() );
+ }
+
+ public int hashCode() {
+ Object v;
+ return ( ( key == null ) ?
+ 0 :
+ key.hashCode() ) ^
+ ( ( value == null ) ?
+ 0 :
+ value.hashCode() );
+ }
+
+ public String toString() {
+ return key + "=" + value;
+ }
+
+ private static boolean eq(Object o1, Object o2) {
+ return ( o1 == null ?
+ o2 == null :
+ o1.equals( o2 ) );
+ }
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/util/XMLHelper.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/util/XMLHelper.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/main/java/org/hibernate/search/util/XMLHelper.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,35 +1,59 @@
-package org.hibernate.search.util;
-
-import java.io.ByteArrayInputStream;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * A utility class to help with xml parsing
- *
- * @author Lukasz Moren
- */
-public class XMLHelper {
-
-
- /**
- * Converts a String representing an XML snippet into an {@link org.w3c.dom.Element}.
- *
- * @param xml snippet as a string
- *
- * @return a DOM Element
- *
- * @throws Exception if unable to parse the String or if it doesn't contain valid XML.
- */
- public static Element elementFromString(String xml) throws Exception {
- ByteArrayInputStream bais = new ByteArrayInputStream( xml.getBytes( "UTF-8" ) );
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document document = builder.parse( bais );
- bais.close();
- return document.getDocumentElement();
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.util;
+
+import java.io.ByteArrayInputStream;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * A utility class to help with xml parsing
+ *
+ * @author Lukasz Moren
+ */
+public class XMLHelper {
+
+
+ /**
+ * Converts a String representing an XML snippet into an {@link org.w3c.dom.Element}.
+ *
+ * @param xml snippet as a string
+ *
+ * @return a DOM Element
+ *
+ * @throws Exception if unable to parse the String or if it doesn't contain valid XML.
+ */
+ public static Element elementFromString(String xml) throws Exception {
+ ByteArrayInputStream bais = new ByteArrayInputStream( xml.getBytes( "UTF-8" ) );
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document document = builder.parse( bais );
+ bais.close();
+ return document.getDocumentElement();
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/AlternateDocument.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/AlternateDocument.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/AlternateDocument.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,77 +1,100 @@
-//$Id$
-package org.hibernate.search.test;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Store;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Boost;
-
-/**
- * Example of 2 entities mapped in the same index
- * @author Emmanuel Bernard
- */
-@Entity
-@Indexed(index = "Documents")
-public class AlternateDocument {
- private Long id;
- private String title;
- private String summary;
- private String text;
-
- AlternateDocument() {
- }
-
- public AlternateDocument(Long id, String title, String summary, String text) {
- super();
- this.id = id;
- this.summary = summary;
- this.text = text;
- this.title = title;
- }
-
- @Id
- @DocumentId()
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- @Field( name = "alt_title", store = Store.YES, index = Index.TOKENIZED )
- @Boost(2)
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- @Field( name="Abstract", store = Store.NO, index = Index.TOKENIZED )
- public String getSummary() {
- return summary;
- }
-
- public void setSummary(String summary) {
- this.summary = summary;
- }
-
- @Lob
- @Field( store = Store.NO, index = Index.TOKENIZED )
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-}
-
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Store;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Boost;
+
+/**
+ * Example of 2 entities mapped in the same index
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed(index = "Documents")
+public class AlternateDocument {
+ private Long id;
+ private String title;
+ private String summary;
+ private String text;
+
+ AlternateDocument() {
+ }
+
+ public AlternateDocument(Long id, String title, String summary, String text) {
+ super();
+ this.id = id;
+ this.summary = summary;
+ this.text = text;
+ this.title = title;
+ }
+
+ @Id
+ @DocumentId()
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Field( name = "alt_title", store = Store.YES, index = Index.TOKENIZED )
+ @Boost(2)
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Field( name="Abstract", store = Store.NO, index = Index.TOKENIZED )
+ public String getSummary() {
+ return summary;
+ }
+
+ public void setSummary(String summary) {
+ this.summary = summary;
+ }
+
+ @Lob
+ @Field( store = Store.NO, index = Index.TOKENIZED )
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+}
+
Modified: search/trunk/src/test/java/org/hibernate/search/test/Clock.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/Clock.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/Clock.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,43 +1,66 @@
-//$Id$
-package org.hibernate.search.test;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.Store;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-@Indexed
-public class Clock {
- private Integer id;
- private String brand;
-
- public Clock(Integer id, String brand) {
- this.id = id;
- this.brand = brand;
- }
-
- @Field(index= Index.TOKENIZED, store= Store.YES) public String getBrand() {
- return brand;
- }
-
- public void setBrand(String brand) {
- this.brand = brand;
- }
-
- @Id @DocumentId
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed
+public class Clock {
+ private Integer id;
+ private String brand;
+
+ public Clock(Integer id, String brand) {
+ this.id = id;
+ this.brand = brand;
+ }
+
+ @Field(index= Index.TOKENIZED, store= Store.YES) public String getBrand() {
+ return brand;
+ }
+
+ public void setBrand(String brand) {
+ this.brand = brand;
+ }
+
+ @Id @DocumentId
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/Document.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/Document.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/Document.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,73 +1,96 @@
-//$Id$
-package org.hibernate.search.test;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.Boost;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Store;
-
-@Entity
-@Indexed(index = "Documents")
-public class Document {
- private Long id;
- private String title;
- private String summary;
- private String text;
-
- Document() {
- }
-
- public Document(String title, String summary, String text) {
- super();
- this.summary = summary;
- this.text = text;
- this.title = title;
- }
-
- @Id
- @GeneratedValue
- @DocumentId
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- @Field( store = Store.YES, index = Index.TOKENIZED )
- @Boost(2)
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- @Field( name="Abstract", store = Store.NO, index = Index.TOKENIZED )
- public String getSummary() {
- return summary;
- }
-
- public void setSummary(String summary) {
- this.summary = summary;
- }
-
- @Lob
- @Field( store = Store.NO, index = Index.TOKENIZED )
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Boost;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Store;
+
+@Entity
+@Indexed(index = "Documents")
+public class Document {
+ private Long id;
+ private String title;
+ private String summary;
+ private String text;
+
+ Document() {
+ }
+
+ public Document(String title, String summary, String text) {
+ super();
+ this.summary = summary;
+ this.text = text;
+ this.title = title;
+ }
+
+ @Id
+ @GeneratedValue
+ @DocumentId
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Field( store = Store.YES, index = Index.TOKENIZED )
+ @Boost(2)
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Field( name="Abstract", store = Store.NO, index = Index.TOKENIZED )
+ public String getSummary() {
+ return summary;
+ }
+
+ public void setSummary(String summary) {
+ this.summary = summary;
+ }
+
+ @Lob
+ @Field( store = Store.NO, index = Index.TOKENIZED )
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/FSDirectoryTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/FSDirectoryTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/FSDirectoryTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,191 +1,214 @@
-//$Id$
-package org.hibernate.search.test;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.lucene.analysis.StopAnalyzer;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermDocs;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.TopDocs;
-
-import org.hibernate.Session;
-import org.hibernate.search.Environment;
-import org.hibernate.search.store.FSDirectoryProvider;
-import org.hibernate.search.util.FileHelper;
-
-/**
- * @author Gavin King
- */
-public class FSDirectoryTest extends SearchTestCase {
-
- protected void setUp() throws Exception {
- File sub = getBaseIndexDir();
- sub.mkdir();
- File[] files = sub.listFiles();
- for (File file : files) {
- if ( file.isDirectory() ) {
- FileHelper.delete( file );
- }
- }
- //super.setUp(); //we need a fresh session factory each time for index set up
- buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFiles() );
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- File sub = getBaseIndexDir();
- FileHelper.delete( sub );
- }
-
- public void testEventIntegration() throws Exception {
-
- Session s = getSessions().openSession();
- s.getTransaction().begin();
- s.persist(
- new Document( "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" )
- );
- s.getTransaction().commit();
- s.close();
- IndexReader reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
- try {
- int num = reader.numDocs();
- assertEquals( 1, num );
- TermDocs docs = reader.termDocs( new Term( "Abstract", "Hibernate" ) );
- org.apache.lucene.document.Document doc = reader.document( docs.doc() );
- assertFalse( docs.next() );
- docs = reader.termDocs( new Term( "Title", "Action" ) );
- doc = reader.document( docs.doc() );
- assertFalse( docs.next() );
- assertEquals( "1", doc.getField( "id" ).stringValue() );
- }
- finally {
- reader.close();
- }
-
- s = getSessions().openSession();
- s.getTransaction().begin();
- Document entity = (Document) s.get( Document.class, Long.valueOf( 1 ) );
- entity.setSummary( "Object/relational mapping with EJB3" );
- s.persist( new Document( "Seam in Action", "", "blah blah blah blah" ) );
- s.getTransaction().commit();
- s.close();
-
- reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
- try {
- int num = reader.numDocs();
- assertEquals( 2, num );
- TermDocs docs = reader.termDocs( new Term( "Abstract", "ejb" ) );
- assertTrue( docs.next() );
- org.apache.lucene.document.Document doc = reader.document( docs.doc() );
- assertFalse( docs.next() );
- }
- finally {
- reader.close();
- }
-
- s = getSessions().openSession();
- s.getTransaction().begin();
- s.delete( entity );
- s.getTransaction().commit();
- s.close();
-
- reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
- try {
- int num = reader.numDocs();
- assertEquals( 1, num );
- TermDocs docs = reader.termDocs( new Term( "title", "seam" ) );
- assertTrue( docs.next() );
- org.apache.lucene.document.Document doc = reader.document( docs.doc() );
- assertFalse( docs.next() );
- assertEquals( "2", doc.getField( "id" ).stringValue() );
- }
- finally {
- reader.close();
- }
-
- s = getSessions().openSession();
- s.getTransaction().begin();
- s.delete( s.createCriteria( Document.class ).uniqueResult() );
- s.getTransaction().commit();
- s.close();
- }
-
- public void testBoost() throws Exception {
- Session s = getSessions().openSession();
- s.getTransaction().begin();
- s.persist(
- new Document( "Hibernate in Action", "Object and Relational", "blah blah blah" )
- );
- s.persist(
- new Document( "Object and Relational", "Hibernate in Action", "blah blah blah" )
- );
- s.getTransaction().commit();
- s.close();
-
- IndexSearcher searcher = new IndexSearcher( new File( getBaseIndexDir(), "Documents" ).getCanonicalPath() );
- try {
- QueryParser qp = new QueryParser( "id", new StandardAnalyzer() );
- Query query = qp.parse( "title:Action OR Abstract:Action" );
- TopDocs hits = searcher.search( query, 1000 );
- assertEquals( 2, hits.totalHits );
- assertTrue( hits.scoreDocs[0].score == 2 * hits.scoreDocs[1].score );
- org.apache.lucene.document.Document doc = searcher.doc( 0 );
- assertEquals( "Hibernate in Action", doc.get( "title" ) );
- }
- finally {
- searcher.close();
- }
-
- s = getSessions().openSession();
- s.getTransaction().begin();
- List list = s.createQuery( "from Document" ).list();
- for (Document document : (List<Document>) list) {
- s.delete( document );
- }
- s.getTransaction().commit();
- s.close();
- getSessions().close(); //run the searchfactory.close() operations
- }
-
- public void testSearchOnDeletedIndex() throws Exception {
- Session s = getSessions().openSession();
- s.getTransaction().begin();
- s.persist( new Document( "Hibernate Search in Action", "", "") );
- s.getTransaction().commit();
- s.close();
-
- IndexSearcher searcher = new IndexSearcher( new File( getBaseIndexDir(), "Documents" ).getCanonicalPath() );
- // deleting before search, but after IndexSearcher creation:
- // ( fails when deleting -concurrently- to IndexSearcher initialization! )
- FileHelper.delete(getBaseIndexDir());
- TermQuery query = new TermQuery( new Term("title","action") );
- TopDocs hits = searcher.search( query, 1000 );
- assertEquals( 1, hits.totalHits );
- org.apache.lucene.document.Document doc = searcher.doc( 0 );
- assertEquals( "Hibernate Search in Action", doc.get( "title" ) );
- searcher.close();
- }
-
- protected Class[] getMappings() {
- return new Class[] {
- Document.class
- };
- }
-
- protected void configure(org.hibernate.cfg.Configuration cfg) {
- super.configure( cfg );
- File sub = getBaseIndexDir();
- cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath() );
- cfg.setProperty( "hibernate.search.default.directory_provider", FSDirectoryProvider.class.getName() );
- cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
- }
-
-}
-
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermDocs;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopDocs;
+
+import org.hibernate.Session;
+import org.hibernate.search.Environment;
+import org.hibernate.search.store.FSDirectoryProvider;
+import org.hibernate.search.util.FileHelper;
+
+/**
+ * @author Gavin King
+ */
+public class FSDirectoryTest extends SearchTestCase {
+
+ protected void setUp() throws Exception {
+ File sub = getBaseIndexDir();
+ sub.mkdir();
+ File[] files = sub.listFiles();
+ for (File file : files) {
+ if ( file.isDirectory() ) {
+ FileHelper.delete( file );
+ }
+ }
+ //super.setUp(); //we need a fresh session factory each time for index set up
+ buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFiles() );
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ File sub = getBaseIndexDir();
+ FileHelper.delete( sub );
+ }
+
+ public void testEventIntegration() throws Exception {
+
+ Session s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.persist(
+ new Document( "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" )
+ );
+ s.getTransaction().commit();
+ s.close();
+ IndexReader reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
+ try {
+ int num = reader.numDocs();
+ assertEquals( 1, num );
+ TermDocs docs = reader.termDocs( new Term( "Abstract", "Hibernate" ) );
+ org.apache.lucene.document.Document doc = reader.document( docs.doc() );
+ assertFalse( docs.next() );
+ docs = reader.termDocs( new Term( "Title", "Action" ) );
+ doc = reader.document( docs.doc() );
+ assertFalse( docs.next() );
+ assertEquals( "1", doc.getField( "id" ).stringValue() );
+ }
+ finally {
+ reader.close();
+ }
+
+ s = getSessions().openSession();
+ s.getTransaction().begin();
+ Document entity = (Document) s.get( Document.class, Long.valueOf( 1 ) );
+ entity.setSummary( "Object/relational mapping with EJB3" );
+ s.persist( new Document( "Seam in Action", "", "blah blah blah blah" ) );
+ s.getTransaction().commit();
+ s.close();
+
+ reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
+ try {
+ int num = reader.numDocs();
+ assertEquals( 2, num );
+ TermDocs docs = reader.termDocs( new Term( "Abstract", "ejb" ) );
+ assertTrue( docs.next() );
+ org.apache.lucene.document.Document doc = reader.document( docs.doc() );
+ assertFalse( docs.next() );
+ }
+ finally {
+ reader.close();
+ }
+
+ s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.delete( entity );
+ s.getTransaction().commit();
+ s.close();
+
+ reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
+ try {
+ int num = reader.numDocs();
+ assertEquals( 1, num );
+ TermDocs docs = reader.termDocs( new Term( "title", "seam" ) );
+ assertTrue( docs.next() );
+ org.apache.lucene.document.Document doc = reader.document( docs.doc() );
+ assertFalse( docs.next() );
+ assertEquals( "2", doc.getField( "id" ).stringValue() );
+ }
+ finally {
+ reader.close();
+ }
+
+ s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.delete( s.createCriteria( Document.class ).uniqueResult() );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testBoost() throws Exception {
+ Session s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.persist(
+ new Document( "Hibernate in Action", "Object and Relational", "blah blah blah" )
+ );
+ s.persist(
+ new Document( "Object and Relational", "Hibernate in Action", "blah blah blah" )
+ );
+ s.getTransaction().commit();
+ s.close();
+
+ IndexSearcher searcher = new IndexSearcher( new File( getBaseIndexDir(), "Documents" ).getCanonicalPath() );
+ try {
+ QueryParser qp = new QueryParser( "id", new StandardAnalyzer() );
+ Query query = qp.parse( "title:Action OR Abstract:Action" );
+ TopDocs hits = searcher.search( query, 1000 );
+ assertEquals( 2, hits.totalHits );
+ assertTrue( hits.scoreDocs[0].score == 2 * hits.scoreDocs[1].score );
+ org.apache.lucene.document.Document doc = searcher.doc( 0 );
+ assertEquals( "Hibernate in Action", doc.get( "title" ) );
+ }
+ finally {
+ searcher.close();
+ }
+
+ s = getSessions().openSession();
+ s.getTransaction().begin();
+ List list = s.createQuery( "from Document" ).list();
+ for (Document document : (List<Document>) list) {
+ s.delete( document );
+ }
+ s.getTransaction().commit();
+ s.close();
+ getSessions().close(); //run the searchfactory.close() operations
+ }
+
+ public void testSearchOnDeletedIndex() throws Exception {
+ Session s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.persist( new Document( "Hibernate Search in Action", "", "") );
+ s.getTransaction().commit();
+ s.close();
+
+ IndexSearcher searcher = new IndexSearcher( new File( getBaseIndexDir(), "Documents" ).getCanonicalPath() );
+ // deleting before search, but after IndexSearcher creation:
+ // ( fails when deleting -concurrently- to IndexSearcher initialization! )
+ FileHelper.delete(getBaseIndexDir());
+ TermQuery query = new TermQuery( new Term("title","action") );
+ TopDocs hits = searcher.search( query, 1000 );
+ assertEquals( 1, hits.totalHits );
+ org.apache.lucene.document.Document doc = searcher.doc( 0 );
+ assertEquals( "Hibernate Search in Action", doc.get( "title" ) );
+ searcher.close();
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Document.class
+ };
+ }
+
+ protected void configure(org.hibernate.cfg.Configuration cfg) {
+ super.configure( cfg );
+ File sub = getBaseIndexDir();
+ cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath() );
+ cfg.setProperty( "hibernate.search.default.directory_provider", FSDirectoryProvider.class.getName() );
+ cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
+ }
+
+}
+
Modified: search/trunk/src/test/java/org/hibernate/search/test/PurgeTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/PurgeTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/PurgeTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,116 +1,139 @@
-// $Id$
-package org.hibernate.search.test;
-
-import java.util.List;
-
-import org.apache.lucene.analysis.StopAnalyzer;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Query;
-import org.hibernate.Transaction;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.test.query.AlternateBook;
-import org.hibernate.search.test.query.Author;
-import org.hibernate.search.test.query.Book;
-import org.hibernate.search.test.query.Clock;
-import org.hibernate.search.test.query.Employee;
-
-/**
- * Test the PURGE and PURGE_ALL functionality.
- *
- * @author John Griffin
- */
-public class PurgeTest extends SearchTestCase {
-
- public void testPurge() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
- org.hibernate.search.test.query.Clock clock = new Clock( 1, "Seiko" );
- s.save( clock );
- clock = new Clock( 2, "Festina" );
- s.save( clock );
- Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
- s.save( book );
- book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
- s.save( book );
- tx.commit();
- s.clear();
-
- tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "brand", new StopAnalyzer() );
-
- Query query = parser.parse( "brand:Seiko" );
- org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- List results = hibQuery.list();
- assertEquals("incorrect test record", 1, results.size());
- assertEquals("incorrect test record", 1, ((Clock)results.get( 0 )).getId().intValue());
-
- s.purge( Clock.class, ((Clock)results.get( 0 )).getId());
-
- tx.commit();
-
- tx = s.beginTransaction();
-
- query = parser.parse( "brand:Festina or brand:Seiko" );
- hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- results = hibQuery.list();
- assertEquals("incorrect test record count", 1, results.size());
- assertEquals("incorrect test record", 2, ((Clock)results.get( 0 )).getId().intValue());
-
- for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testPurgeAll() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
- org.hibernate.search.test.query.Clock clock = new Clock( 1, "Seiko" );
- s.save( clock );
- clock = new Clock( 2, "Festina" );
- s.save( clock );
- clock = new Clock( 3, "Longine" );
- s.save( clock );
- clock = new Clock( 4, "Rolex" );
- s.save( clock );
- Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
- s.save( book );
- book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
- s.save( book );
- tx.commit();
- s.clear();
-
- tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "brand", new StopAnalyzer() );
- tx = s.beginTransaction();
- s.purgeAll( Clock.class);
-
- tx.commit();
-
- tx = s.beginTransaction();
-
- Query query = parser.parse( "brand:Festina or brand:Seiko or brand:Longine or brand:Rolex" );
- org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- List results = hibQuery.list();
- assertEquals("class not completely purged", 0, results.size());
-
- query = parser.parse( "summary:Festina or summary:gloire" );
- hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- results = hibQuery.list();
- assertEquals("incorrect class purged", 2, results.size());
-
- for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- protected Class[] getMappings() {
- return new Class[] {
- Book.class,
- AlternateBook.class,
- Clock.class,
- Author.class,
- Employee.class
- };
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test;
+
+import java.util.List;
+
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.hibernate.Transaction;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.test.query.AlternateBook;
+import org.hibernate.search.test.query.Author;
+import org.hibernate.search.test.query.Book;
+import org.hibernate.search.test.query.Clock;
+import org.hibernate.search.test.query.Employee;
+
+/**
+ * Test the PURGE and PURGE_ALL functionality.
+ *
+ * @author John Griffin
+ */
+public class PurgeTest extends SearchTestCase {
+
+ public void testPurge() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ org.hibernate.search.test.query.Clock clock = new Clock( 1, "Seiko" );
+ s.save( clock );
+ clock = new Clock( 2, "Festina" );
+ s.save( clock );
+ Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
+ s.save( book );
+ book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
+ s.save( book );
+ tx.commit();
+ s.clear();
+
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "brand", new StopAnalyzer() );
+
+ Query query = parser.parse( "brand:Seiko" );
+ org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ List results = hibQuery.list();
+ assertEquals("incorrect test record", 1, results.size());
+ assertEquals("incorrect test record", 1, ((Clock)results.get( 0 )).getId().intValue());
+
+ s.purge( Clock.class, ((Clock)results.get( 0 )).getId());
+
+ tx.commit();
+
+ tx = s.beginTransaction();
+
+ query = parser.parse( "brand:Festina or brand:Seiko" );
+ hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ results = hibQuery.list();
+ assertEquals("incorrect test record count", 1, results.size());
+ assertEquals("incorrect test record", 2, ((Clock)results.get( 0 )).getId().intValue());
+
+ for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testPurgeAll() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ org.hibernate.search.test.query.Clock clock = new Clock( 1, "Seiko" );
+ s.save( clock );
+ clock = new Clock( 2, "Festina" );
+ s.save( clock );
+ clock = new Clock( 3, "Longine" );
+ s.save( clock );
+ clock = new Clock( 4, "Rolex" );
+ s.save( clock );
+ Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
+ s.save( book );
+ book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
+ s.save( book );
+ tx.commit();
+ s.clear();
+
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "brand", new StopAnalyzer() );
+ tx = s.beginTransaction();
+ s.purgeAll( Clock.class);
+
+ tx.commit();
+
+ tx = s.beginTransaction();
+
+ Query query = parser.parse( "brand:Festina or brand:Seiko or brand:Longine or brand:Rolex" );
+ org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ List results = hibQuery.list();
+ assertEquals("class not completely purged", 0, results.size());
+
+ query = parser.parse( "summary:Festina or summary:gloire" );
+ hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ results = hibQuery.list();
+ assertEquals("incorrect class purged", 2, results.size());
+
+ for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Book.class,
+ AlternateBook.class,
+ Clock.class,
+ Author.class,
+ Employee.class
+ };
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/RamDirectoryTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/RamDirectoryTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/RamDirectoryTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,69 +1,92 @@
-//$Id$
-package org.hibernate.search.test;
-
-import org.hibernate.Session;
-import org.hibernate.search.Search;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.TermQuery;
-
-/**
- * @author Emmanuel Bernard
- */
-public class RamDirectoryTest extends SearchTestCase {
-
- public void testMultipleEntitiesPerIndex() throws Exception {
-
-
- Session s = getSessions().openSession();
- s.getTransaction().begin();
- Document document =
- new Document( "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" );
- s.persist(document);
- s.flush();
- s.persist(
- new AlternateDocument( document.getId(), "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" )
- );
- s.getTransaction().commit();
- s.close();
-
- assertEquals( 2, getDocumentNbr() );
-
- s = getSessions().openSession();
- s.getTransaction().begin();
- TermQuery q = new TermQuery(new Term("alt_title", "hibernate"));
- assertEquals( "does not properly filter", 0,
- Search.getFullTextSession( s ).createFullTextQuery( q, Document.class ).list().size() );
- assertEquals( "does not properly filter", 1,
- Search.getFullTextSession( s ).createFullTextQuery( q, Document.class, AlternateDocument.class ).list().size() );
- s.delete( s.get( AlternateDocument.class, document.getId() ) );
- s.getTransaction().commit();
- s.close();
-
- assertEquals( 1, getDocumentNbr() );
-
- s = getSessions().openSession();
- s.getTransaction().begin();
- s.delete( s.createCriteria( Document.class ).uniqueResult() );
- s.getTransaction().commit();
- s.close();
- }
-
- private int getDocumentNbr() throws Exception {
- IndexReader reader = IndexReader.open( getDirectory( Document.class ), false );
- try {
- return reader.numDocs();
- }
- finally {
- reader.close();
- }
- }
-
- protected Class[] getMappings() {
- return new Class[]{
- Document.class,
- AlternateDocument.class
- };
- }
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test;
+
+import org.hibernate.Session;
+import org.hibernate.search.Search;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.TermQuery;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class RamDirectoryTest extends SearchTestCase {
+
+ public void testMultipleEntitiesPerIndex() throws Exception {
+
+
+ Session s = getSessions().openSession();
+ s.getTransaction().begin();
+ Document document =
+ new Document( "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" );
+ s.persist(document);
+ s.flush();
+ s.persist(
+ new AlternateDocument( document.getId(), "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" )
+ );
+ s.getTransaction().commit();
+ s.close();
+
+ assertEquals( 2, getDocumentNbr() );
+
+ s = getSessions().openSession();
+ s.getTransaction().begin();
+ TermQuery q = new TermQuery(new Term("alt_title", "hibernate"));
+ assertEquals( "does not properly filter", 0,
+ Search.getFullTextSession( s ).createFullTextQuery( q, Document.class ).list().size() );
+ assertEquals( "does not properly filter", 1,
+ Search.getFullTextSession( s ).createFullTextQuery( q, Document.class, AlternateDocument.class ).list().size() );
+ s.delete( s.get( AlternateDocument.class, document.getId() ) );
+ s.getTransaction().commit();
+ s.close();
+
+ assertEquals( 1, getDocumentNbr() );
+
+ s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.delete( s.createCriteria( Document.class ).uniqueResult() );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ private int getDocumentNbr() throws Exception {
+ IndexReader reader = IndexReader.open( getDirectory( Document.class ), false );
+ try {
+ return reader.numDocs();
+ }
+ finally {
+ reader.close();
+ }
+ }
+
+ protected Class[] getMappings() {
+ return new Class[]{
+ Document.class,
+ AlternateDocument.class
+ };
+ }
+
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/SearchTestCase.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/SearchTestCase.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/SearchTestCase.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,160 +1,183 @@
-//$Id$
-package org.hibernate.search.test;
-
-import java.io.File;
-import java.io.InputStream;
-
-import org.apache.lucene.analysis.StopAnalyzer;
-import org.apache.lucene.store.Directory;
-import org.slf4j.Logger;
-
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.AnnotationConfiguration;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.impl.SessionFactoryImpl;
-import org.hibernate.search.Environment;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.SearchFactory;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.event.FullTextIndexEventListener;
-import org.hibernate.search.store.RAMDirectoryProvider;
-import org.hibernate.tool.hbm2ddl.SchemaExport;
-
-/**
- * Base class for Hibernate Search unit tests.
- *
- * @author Emmanuel Bernard
- */
-public abstract class SearchTestCase extends TestCase {
-
- private static final Logger log = org.hibernate.search.util.LoggerFactory.make();
-
- private static File indexDir;
-
- private SearchFactory searchFactory;
-
- static {
- String buildDir = System.getProperty( "build.dir" );
- if ( buildDir == null ) {
- buildDir = ".";
- }
- File current = new File( buildDir );
- indexDir = new File( current, "indextemp" );
- log.debug( "Using {} as index directory.", indexDir.getAbsolutePath() );
- }
-
- protected void setUp() throws Exception {
- buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFiles() );
- ensureIndexesAreEmpty();
- }
-
- protected void tearDown() throws Exception {
- SchemaExport export = new SchemaExport( cfg );
- export.drop( false, true );
- searchFactory = null;
- }
-
- protected Directory getDirectory(Class<?> clazz) {
- return getLuceneEventListener().getSearchFactoryImplementor().getDirectoryProviders( clazz )[0].getDirectory();
- }
-
- private FullTextIndexEventListener getLuceneEventListener() {
- PostInsertEventListener[] listeners = ( ( SessionFactoryImpl ) getSessions() ).getEventListeners()
- .getPostInsertEventListeners();
- FullTextIndexEventListener listener = null;
- //FIXME this sucks since we mandante the event listener use
- for ( PostInsertEventListener candidate : listeners ) {
- if ( candidate instanceof FullTextIndexEventListener ) {
- listener = ( FullTextIndexEventListener ) candidate;
- break;
- }
- }
- if ( listener == null ) {
- throw new HibernateException( "Lucene event listener not initialized" );
- }
- return listener;
- }
-
- protected void ensureIndexesAreEmpty() {
- if ( "jms".equals( getCfg().getProperty( "hibernate.search.worker.backend" ) ) ) {
- log.debug( "JMS based test. Skipping index emptying" );
- return;
- }
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx;
- tx = s.beginTransaction();
- for ( Class<?> clazz : getMappings() ) {
- if ( clazz.getAnnotation( Indexed.class ) != null ) {
- s.purgeAll( clazz );
- }
- }
- tx.commit();
- s.close();
- }
-
- protected SearchFactory getSearchFactory() {
- if ( searchFactory == null ) {
- Session session = openSession();
- FullTextSession fullTextSession = Search.getFullTextSession( session );
- searchFactory = fullTextSession.getSearchFactory();
- fullTextSession.close();
- }
- return searchFactory;
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty( "hibernate.search.default.directory_provider", RAMDirectoryProvider.class.getName() );
- cfg.setProperty( "hibernate.search.default.indexBase", indexDir.getAbsolutePath() );
- cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
- cfg.setProperty( "hibernate.search.default.transaction.merge_factor", "100" );
- cfg.setProperty( "hibernate.search.default.batch.max_buffered_docs", "1000" );
- }
-
- protected File getBaseIndexDir() {
- return indexDir;
- }
-
- protected void buildSessionFactory(Class<?>[] classes, String[] packages, String[] xmlFiles) throws Exception {
- if ( getSessions() != null ) {
- getSessions().close();
- }
- try {
- setCfg( new AnnotationConfiguration() );
- configure( cfg );
- if ( recreateSchema() ) {
- cfg.setProperty( org.hibernate.cfg.Environment.HBM2DDL_AUTO, "create-drop" );
- }
- for ( String aPackage : packages ) {
- ( ( AnnotationConfiguration ) getCfg() ).addPackage( aPackage );
- }
- for ( Class<?> aClass : classes ) {
- ( ( AnnotationConfiguration ) getCfg() ).addAnnotatedClass( aClass );
- }
- for ( String xmlFile : xmlFiles ) {
- InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile );
- getCfg().addInputStream( is );
- }
- setDialect( Dialect.getDialect() );
- setSessions( getCfg().buildSessionFactory( /*new TestInterceptor()*/ ) );
- }
- catch ( Exception e ) {
- e.printStackTrace();
- throw e;
- }
- }
-
- protected abstract Class<?>[] getMappings();
-
- protected String[] getAnnotatedPackages() {
- return new String[] { };
- }
-
- protected static File getIndexDir() {
- return indexDir;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test;
+
+import java.io.File;
+import java.io.InputStream;
+
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.store.Directory;
+import org.slf4j.Logger;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.event.PostInsertEventListener;
+import org.hibernate.impl.SessionFactoryImpl;
+import org.hibernate.search.Environment;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.SearchFactory;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.event.FullTextIndexEventListener;
+import org.hibernate.search.store.RAMDirectoryProvider;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
+
+/**
+ * Base class for Hibernate Search unit tests.
+ *
+ * @author Emmanuel Bernard
+ */
+public abstract class SearchTestCase extends TestCase {
+
+ private static final Logger log = org.hibernate.search.util.LoggerFactory.make();
+
+ private static File indexDir;
+
+ private SearchFactory searchFactory;
+
+ static {
+ String buildDir = System.getProperty( "build.dir" );
+ if ( buildDir == null ) {
+ buildDir = ".";
+ }
+ File current = new File( buildDir );
+ indexDir = new File( current, "indextemp" );
+ log.debug( "Using {} as index directory.", indexDir.getAbsolutePath() );
+ }
+
+ protected void setUp() throws Exception {
+ buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFiles() );
+ ensureIndexesAreEmpty();
+ }
+
+ protected void tearDown() throws Exception {
+ SchemaExport export = new SchemaExport( cfg );
+ export.drop( false, true );
+ searchFactory = null;
+ }
+
+ protected Directory getDirectory(Class<?> clazz) {
+ return getLuceneEventListener().getSearchFactoryImplementor().getDirectoryProviders( clazz )[0].getDirectory();
+ }
+
+ private FullTextIndexEventListener getLuceneEventListener() {
+ PostInsertEventListener[] listeners = ( ( SessionFactoryImpl ) getSessions() ).getEventListeners()
+ .getPostInsertEventListeners();
+ FullTextIndexEventListener listener = null;
+ //FIXME this sucks since we mandante the event listener use
+ for ( PostInsertEventListener candidate : listeners ) {
+ if ( candidate instanceof FullTextIndexEventListener ) {
+ listener = ( FullTextIndexEventListener ) candidate;
+ break;
+ }
+ }
+ if ( listener == null ) {
+ throw new HibernateException( "Lucene event listener not initialized" );
+ }
+ return listener;
+ }
+
+ protected void ensureIndexesAreEmpty() {
+ if ( "jms".equals( getCfg().getProperty( "hibernate.search.worker.backend" ) ) ) {
+ log.debug( "JMS based test. Skipping index emptying" );
+ return;
+ }
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx;
+ tx = s.beginTransaction();
+ for ( Class<?> clazz : getMappings() ) {
+ if ( clazz.getAnnotation( Indexed.class ) != null ) {
+ s.purgeAll( clazz );
+ }
+ }
+ tx.commit();
+ s.close();
+ }
+
+ protected SearchFactory getSearchFactory() {
+ if ( searchFactory == null ) {
+ Session session = openSession();
+ FullTextSession fullTextSession = Search.getFullTextSession( session );
+ searchFactory = fullTextSession.getSearchFactory();
+ fullTextSession.close();
+ }
+ return searchFactory;
+ }
+
+ protected void configure(Configuration cfg) {
+ cfg.setProperty( "hibernate.search.default.directory_provider", RAMDirectoryProvider.class.getName() );
+ cfg.setProperty( "hibernate.search.default.indexBase", indexDir.getAbsolutePath() );
+ cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
+ cfg.setProperty( "hibernate.search.default.transaction.merge_factor", "100" );
+ cfg.setProperty( "hibernate.search.default.batch.max_buffered_docs", "1000" );
+ }
+
+ protected File getBaseIndexDir() {
+ return indexDir;
+ }
+
+ protected void buildSessionFactory(Class<?>[] classes, String[] packages, String[] xmlFiles) throws Exception {
+ if ( getSessions() != null ) {
+ getSessions().close();
+ }
+ try {
+ setCfg( new AnnotationConfiguration() );
+ configure( cfg );
+ if ( recreateSchema() ) {
+ cfg.setProperty( org.hibernate.cfg.Environment.HBM2DDL_AUTO, "create-drop" );
+ }
+ for ( String aPackage : packages ) {
+ ( ( AnnotationConfiguration ) getCfg() ).addPackage( aPackage );
+ }
+ for ( Class<?> aClass : classes ) {
+ ( ( AnnotationConfiguration ) getCfg() ).addAnnotatedClass( aClass );
+ }
+ for ( String xmlFile : xmlFiles ) {
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile );
+ getCfg().addInputStream( is );
+ }
+ setDialect( Dialect.getDialect() );
+ setSessions( getCfg().buildSessionFactory( /*new TestInterceptor()*/ ) );
+ }
+ catch ( Exception e ) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ protected abstract Class<?>[] getMappings();
+
+ protected String[] getAnnotatedPackages() {
+ return new String[] { };
+ }
+
+ protected static File getIndexDir() {
+ return indexDir;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/SerializationTestHelper.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/SerializationTestHelper.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/SerializationTestHelper.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test;
import java.io.ByteArrayInputStream;
Modified: search/trunk/src/test/java/org/hibernate/search/test/TestCase.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/TestCase.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/TestCase.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test;
import java.io.InputStream;
@@ -163,4 +186,4 @@
protected boolean recreateSchema() {
return true;
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/TransactionTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/TransactionTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/TransactionTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,72 +1,95 @@
-//$Id$
-package org.hibernate.search.test;
-
-import java.io.IOException;
-
-import org.apache.lucene.index.IndexReader;
-
-import org.hibernate.Session;
-
-/**
- * @author Emmanuel Bernard
- */
-public class TransactionTest extends SearchTestCase {
-
- public void testTransactionCommit() throws Exception {
- Session s = getSessions().openSession();
- s.getTransaction().begin();
- s.persist(
- new Document( "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" )
- );
- s.persist(
- new Document( "Lucene in Action", "FullText search engine", "blah blah blah" )
- );
- s.persist(
- new Document( "Hibernate Search in Action", "ORM and FullText search engine", "blah blah blah" )
- );
- s.getTransaction().commit();
- s.close();
-
- assertEquals( "transaction.commit() should index", 3, getDocumentNumber() );
-
- s = getSessions().openSession();
- s.getTransaction().begin();
- s.persist(
- new Document(
- "Java Persistence with Hibernate", "Object/relational mapping with Hibernate", "blah blah blah"
- )
- );
- s.flush();
- s.getTransaction().rollback();
- s.close();
-
- assertEquals( "rollback() should not index", 3, getDocumentNumber() );
-
- s = getSessions().openSession();
- s.connection().setAutoCommit( true ); // www.hibernate.org/403.html
- s.persist(
- new Document(
- "Java Persistence with Hibernate", "Object/relational mapping with Hibernate", "blah blah blah"
- )
- );
- s.flush();
- s.close();
-
- assertEquals( "no transaction should index", 4, getDocumentNumber() );
-
- }
-
- private int getDocumentNumber() throws IOException {
- IndexReader reader = IndexReader.open( getDirectory( Document.class ), false );
- try {
- return reader.numDocs();
- }
- finally {
- reader.close();
- }
- }
-
- protected Class[] getMappings() {
- return new Class[] { Document.class };
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test;
+
+import java.io.IOException;
+
+import org.apache.lucene.index.IndexReader;
+
+import org.hibernate.Session;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class TransactionTest extends SearchTestCase {
+
+ public void testTransactionCommit() throws Exception {
+ Session s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.persist(
+ new Document( "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" )
+ );
+ s.persist(
+ new Document( "Lucene in Action", "FullText search engine", "blah blah blah" )
+ );
+ s.persist(
+ new Document( "Hibernate Search in Action", "ORM and FullText search engine", "blah blah blah" )
+ );
+ s.getTransaction().commit();
+ s.close();
+
+ assertEquals( "transaction.commit() should index", 3, getDocumentNumber() );
+
+ s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.persist(
+ new Document(
+ "Java Persistence with Hibernate", "Object/relational mapping with Hibernate", "blah blah blah"
+ )
+ );
+ s.flush();
+ s.getTransaction().rollback();
+ s.close();
+
+ assertEquals( "rollback() should not index", 3, getDocumentNumber() );
+
+ s = getSessions().openSession();
+ s.connection().setAutoCommit( true ); // www.hibernate.org/403.html
+ s.persist(
+ new Document(
+ "Java Persistence with Hibernate", "Object/relational mapping with Hibernate", "blah blah blah"
+ )
+ );
+ s.flush();
+ s.close();
+
+ assertEquals( "no transaction should index", 4, getDocumentNumber() );
+
+ }
+
+ private int getDocumentNumber() throws IOException {
+ IndexReader reader = IndexReader.open( getDirectory( Document.class ), false );
+ try {
+ return reader.numDocs();
+ }
+ finally {
+ reader.close();
+ }
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] { Document.class };
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/AbstractTestAnalyzer.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/AbstractTestAnalyzer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/AbstractTestAnalyzer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer;
import java.io.Reader;
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/AlarmEntity.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/AlarmEntity.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/AlarmEntity.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/AnalyzerTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/AnalyzerTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/AnalyzerTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer;
import java.util.HashSet;
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/Article.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/Article.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/Article.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer;
import java.util.Set;
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/BlogEntry.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/BlogEntry.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/BlogEntry.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer;
import java.util.Set;
@@ -91,4 +114,4 @@
public void setReferences(Set<BlogEntry> references) {
this.references = references;
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/DoubleAnalyzerTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/DoubleAnalyzerTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/DoubleAnalyzerTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/LanguageDiscriminator.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/LanguageDiscriminator.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/LanguageDiscriminator.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer;
import org.hibernate.search.analyzer.Discriminator;
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/MyComponent.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/MyComponent.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/MyComponent.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer;
import org.hibernate.search.annotations.Field;
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/MyEntity.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/MyEntity.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/MyEntity.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test1Analyzer.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test1Analyzer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test1Analyzer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer;
/**
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test2Analyzer.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test2Analyzer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test2Analyzer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer;
/**
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test3Analyzer.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test3Analyzer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test3Analyzer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer;
/**
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test4Analyzer.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test4Analyzer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/Test4Analyzer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer;
/**
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/AnalyzerInheritanceTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/AnalyzerInheritanceTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/AnalyzerInheritanceTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer.inheritance;
import org.apache.lucene.analysis.Analyzer;
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/BaseClass.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/BaseClass.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/BaseClass.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer.inheritance;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/ISOLatin1Analyzer.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/ISOLatin1Analyzer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/ISOLatin1Analyzer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer.inheritance;
import java.io.Reader;
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/SubClass.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/SubClass.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/inheritance/SubClass.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer.inheritance;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/InsertWhitespaceFilter.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/InsertWhitespaceFilter.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/InsertWhitespaceFilter.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer.solr;
import java.io.IOException;
@@ -28,4 +51,4 @@
return null;
}
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/InsertWhitespaceFilterFactory.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/InsertWhitespaceFilterFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/InsertWhitespaceFilterFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer.solr;
import org.apache.lucene.analysis.TokenStream;
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/SolrAnalyzerTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/SolrAnalyzerTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/SolrAnalyzerTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer.solr;
import org.apache.lucene.index.Term;
@@ -29,7 +52,7 @@
public void testAnalyzerDef() throws Exception {
// create the test instance
Team team = new Team();
- team.setDescription( "This is a D\u00E0scription" ); // \u00E0 == � - ISOLatin1AccentFilterFactory should strip of diacritic
+ team.setDescription( "This is a D\u00E0scription" ); // \u00E0 == � - ISOLatin1AccentFilterFactory should strip of diacritic
team.setLocation( "Atlanta" );
team.setName( "ATL team" );
@@ -44,7 +67,7 @@
tx = fts.beginTransaction();
TermQuery query = new TermQuery( new Term( "description", "D\u00E0scription" ) );
assertEquals(
- "iso latin filter should work. � should be a now", 0, fts.createFullTextQuery( query ).list().size()
+ "iso latin filter should work. � should be a now", 0, fts.createFullTextQuery( query ).list().size()
);
query = new TermQuery( new Term( "description", "is" ) );
Modified: search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/Team.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/Team.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/analyzer/solr/Team.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.analyzer.solr;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/batchindexing/AncientBook.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/batchindexing/AncientBook.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/batchindexing/AncientBook.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.batchindexing;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/batchindexing/Book.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/batchindexing/Book.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/batchindexing/Book.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.batchindexing;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/batchindexing/Dvd.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/batchindexing/Dvd.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/batchindexing/Dvd.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.batchindexing;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.batchindexing;
import junit.framework.TestCase;
Modified: search/trunk/src/test/java/org/hibernate/search/test/batchindexing/ModernBook.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/batchindexing/ModernBook.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/batchindexing/ModernBook.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.batchindexing;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/batchindexing/SearchIndexerTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/batchindexing/SearchIndexerTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/batchindexing/SearchIndexerTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.batchindexing;
import java.util.Set;
Modified: search/trunk/src/test/java/org/hibernate/search/test/batchindexing/TitleAble.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/batchindexing/TitleAble.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/batchindexing/TitleAble.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.batchindexing;
public interface TitleAble {
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/BridgeTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/BridgeTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/BridgeTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,198 +1,221 @@
-//$Id$
-package org.hibernate.search.test.bridge;
-
-import java.net.URI;
-import java.net.URL;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.TimeZone;
-
-import org.apache.lucene.analysis.SimpleAnalyzer;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.search.Environment;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.test.SearchTestCase;
-
-/**
- * @author Emmanuel Bernard
- */
-public class BridgeTest extends SearchTestCase {
- public void testDefaultAndNullBridges() throws Exception {
- Cloud cloud = new Cloud();
- cloud.setMyDate( null );
- cloud.setDouble1( null );
- cloud.setDouble2( 2.1d );
- cloud.setIntegerv1( null );
- cloud.setIntegerv2( 2 );
- cloud.setFloat1( null );
- cloud.setFloat2( 2.1f );
- cloud.setLong1( null );
- cloud.setLong2( 2l );
- cloud.setString( null );
- cloud.setType( CloudType.DOG );
- cloud.setChar1( null );
- cloud.setChar2( 'P' );
- cloud.setStorm( false );
- cloud.setClazz( Cloud.class );
- cloud.setUri( new URI( "http://www.hibernate.org" ) );
- cloud.setUrl( new URL( "http://www.hibernate.org" ) );
- org.hibernate.Session s = openSession();
- Transaction tx = s.beginTransaction();
- s.persist( cloud );
- s.flush();
- tx.commit();
-
- tx = s.beginTransaction();
- FullTextSession session = Search.getFullTextSession( s );
- QueryParser parser = new QueryParser( "id", new StandardAnalyzer() );
- Query query;
- List result;
-
- query = parser.parse(
- "double2:[2.1 TO 2.1] AND float2:[2.1 TO 2.1] " +
- "AND integerv2:[2 TO 2.1] AND long2:[2 TO 2.1] AND type:\"dog\" AND storm:false"
- );
-
- result = session.createFullTextQuery( query ).list();
- assertEquals( "find primitives and do not fail on null", 1, result.size() );
-
- query = parser.parse( "double1:[2.1 TO 2.1] OR float1:[2.1 TO 2.1] OR integerv1:[2 TO 2.1] OR long1:[2 TO 2.1]" );
- result = session.createFullTextQuery( query ).list();
- assertEquals( "null elements should not be stored", 0, result.size() ); //the query is dumb because restrictive
-
- query = parser.parse( "type:dog" );
- result = session.createFullTextQuery( query ).setProjection( "type" ).list();
- assertEquals( "Enum projection works", 1, result.size() ); //the query is dumb because restrictive
-
- query = new TermQuery( new Term( "clazz", Cloud.class.getName() ) );
- result = session.createFullTextQuery( query ).setProjection( "clazz" ).list();
- assertEquals( "Clazz projection works", 1, result.size() );
- assertEquals(
- "Clazz projection works",
- Cloud.class.getName(),
- ( ( Class ) ( ( Object[] ) result.get( 0 ) )[0] ).getName()
- );
-
- BooleanQuery bQuery = new BooleanQuery();
- bQuery.add( new TermQuery( new Term( "uri", "http://www.hibernate.org" ) ), BooleanClause.Occur.MUST );
- bQuery.add( new TermQuery( new Term( "url", "http://www.hibernate.org" ) ), BooleanClause.Occur.MUST );
-
- result = session.createFullTextQuery( bQuery ).setProjection( "clazz" ).list();
- assertEquals( "Clazz projection works", 1, result.size() );
-
- query = parser.parse( "char1:[" + String.valueOf( Character.MIN_VALUE ) + " TO " + String.valueOf( Character.MAX_VALUE ) + "]" );
- result = session.createFullTextQuery( query ).setProjection( "char1" ).list();
- assertEquals( "Null elements should not be stored, CharacterBridge is not working", 0, result.size() );
-
- query = parser.parse( "char2:P" );
- result = session.createFullTextQuery( query ).setProjection( "char2" ).list();
- assertEquals( "Wrong results number, CharacterBridge is not working", 1, result.size() );
- assertEquals( "Wrong result, CharacterBridge is not working", 'P', ( ( Object[] ) result.get( 0 ) )[0] );
-
- s.delete( s.get( Cloud.class, cloud.getId() ) );
- tx.commit();
- s.close();
-
- }
-
- public void testCustomBridges() throws Exception {
- Cloud cloud = new Cloud();
- cloud.setCustomFieldBridge( "This is divided by 2" );
- cloud.setCustomStringBridge( "This is div by 4" );
- org.hibernate.Session s = openSession();
- Transaction tx = s.beginTransaction();
- s.persist( cloud );
- s.flush();
- tx.commit();
-
- tx = s.beginTransaction();
- FullTextSession session = Search.getFullTextSession( s );
- QueryParser parser = new QueryParser( "id", new SimpleAnalyzer() );
- Query query;
- List result;
-
- query = parser.parse( "customFieldBridge:This AND customStringBridge:This" );
- result = session.createFullTextQuery( query ).list();
- assertEquals( "Properties not mapped", 1, result.size() );
-
- query = parser.parse( "customFieldBridge:by AND customStringBridge:is" );
- result = session.createFullTextQuery( query ).list();
- assertEquals( "Custom types not taken into account", 0, result.size() );
-
- s.delete( s.get( Cloud.class, cloud.getId() ) );
- tx.commit();
- s.close();
-
- }
-
- public void testDateBridge() throws Exception {
- Cloud cloud = new Cloud();
- Calendar c = GregorianCalendar.getInstance();
- c.setTimeZone( TimeZone.getTimeZone( "GMT" ) ); //for the sake of tests
- c.set( 2000, 11, 15, 3, 43, 2 );
- c.set( Calendar.MILLISECOND, 5 );
-
- Date date = new Date( c.getTimeInMillis() );
- cloud.setMyDate( date ); //5 millisecond
- cloud.setDateDay( date );
- cloud.setDateHour( date );
- cloud.setDateMillisecond( date );
- cloud.setDateMinute( date );
- cloud.setDateMonth( date );
- cloud.setDateSecond( date );
- cloud.setDateYear( date );
- org.hibernate.Session s = openSession();
- Transaction tx = s.beginTransaction();
- s.persist( cloud );
- s.flush();
- tx.commit();
-
- tx = s.beginTransaction();
- FullTextSession session = Search.getFullTextSession( s );
- QueryParser parser = new QueryParser( "id", new StandardAnalyzer() );
- Query query;
- List result;
-
- query = parser.parse(
- "myDate:[19900101 TO 20060101]"
- + " AND dateDay:[20001214 TO 2000121501]"
- + " AND dateMonth:[200012 TO 20001201]"
- + " AND dateYear:[2000 TO 200001]"
- + " AND dateHour:[20001214 TO 2000121503]"
- + " AND dateMinute:[20001214 TO 200012150343]"
- + " AND dateSecond:[20001214 TO 20001215034302]"
- + " AND dateMillisecond:[20001214 TO 20001215034302005]"
- );
- result = session.createFullTextQuery( query ).list();
- assertEquals( "Date not found or not property truncated", 1, result.size() );
-
- s.delete( s.get( Cloud.class, cloud.getId() ) );
- tx.commit();
- s.close();
-
- }
-
- protected Class[] getMappings() {
- return new Class[] {
- Cloud.class
- };
- }
-
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( Environment.ANALYZER_CLASS, SimpleAnalyzer.class.getName() );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.bridge;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.TimeZone;
+
+import org.apache.lucene.analysis.SimpleAnalyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.search.Environment;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.test.SearchTestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class BridgeTest extends SearchTestCase {
+ public void testDefaultAndNullBridges() throws Exception {
+ Cloud cloud = new Cloud();
+ cloud.setMyDate( null );
+ cloud.setDouble1( null );
+ cloud.setDouble2( 2.1d );
+ cloud.setIntegerv1( null );
+ cloud.setIntegerv2( 2 );
+ cloud.setFloat1( null );
+ cloud.setFloat2( 2.1f );
+ cloud.setLong1( null );
+ cloud.setLong2( 2l );
+ cloud.setString( null );
+ cloud.setType( CloudType.DOG );
+ cloud.setChar1( null );
+ cloud.setChar2( 'P' );
+ cloud.setStorm( false );
+ cloud.setClazz( Cloud.class );
+ cloud.setUri( new URI( "http://www.hibernate.org" ) );
+ cloud.setUrl( new URL( "http://www.hibernate.org" ) );
+ org.hibernate.Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist( cloud );
+ s.flush();
+ tx.commit();
+
+ tx = s.beginTransaction();
+ FullTextSession session = Search.getFullTextSession( s );
+ QueryParser parser = new QueryParser( "id", new StandardAnalyzer() );
+ Query query;
+ List result;
+
+ query = parser.parse(
+ "double2:[2.1 TO 2.1] AND float2:[2.1 TO 2.1] " +
+ "AND integerv2:[2 TO 2.1] AND long2:[2 TO 2.1] AND type:\"dog\" AND storm:false"
+ );
+
+ result = session.createFullTextQuery( query ).list();
+ assertEquals( "find primitives and do not fail on null", 1, result.size() );
+
+ query = parser.parse( "double1:[2.1 TO 2.1] OR float1:[2.1 TO 2.1] OR integerv1:[2 TO 2.1] OR long1:[2 TO 2.1]" );
+ result = session.createFullTextQuery( query ).list();
+ assertEquals( "null elements should not be stored", 0, result.size() ); //the query is dumb because restrictive
+
+ query = parser.parse( "type:dog" );
+ result = session.createFullTextQuery( query ).setProjection( "type" ).list();
+ assertEquals( "Enum projection works", 1, result.size() ); //the query is dumb because restrictive
+
+ query = new TermQuery( new Term( "clazz", Cloud.class.getName() ) );
+ result = session.createFullTextQuery( query ).setProjection( "clazz" ).list();
+ assertEquals( "Clazz projection works", 1, result.size() );
+ assertEquals(
+ "Clazz projection works",
+ Cloud.class.getName(),
+ ( ( Class ) ( ( Object[] ) result.get( 0 ) )[0] ).getName()
+ );
+
+ BooleanQuery bQuery = new BooleanQuery();
+ bQuery.add( new TermQuery( new Term( "uri", "http://www.hibernate.org" ) ), BooleanClause.Occur.MUST );
+ bQuery.add( new TermQuery( new Term( "url", "http://www.hibernate.org" ) ), BooleanClause.Occur.MUST );
+
+ result = session.createFullTextQuery( bQuery ).setProjection( "clazz" ).list();
+ assertEquals( "Clazz projection works", 1, result.size() );
+
+ query = parser.parse( "char1:[" + String.valueOf( Character.MIN_VALUE ) + " TO " + String.valueOf( Character.MAX_VALUE ) + "]" );
+ result = session.createFullTextQuery( query ).setProjection( "char1" ).list();
+ assertEquals( "Null elements should not be stored, CharacterBridge is not working", 0, result.size() );
+
+ query = parser.parse( "char2:P" );
+ result = session.createFullTextQuery( query ).setProjection( "char2" ).list();
+ assertEquals( "Wrong results number, CharacterBridge is not working", 1, result.size() );
+ assertEquals( "Wrong result, CharacterBridge is not working", 'P', ( ( Object[] ) result.get( 0 ) )[0] );
+
+ s.delete( s.get( Cloud.class, cloud.getId() ) );
+ tx.commit();
+ s.close();
+
+ }
+
+ public void testCustomBridges() throws Exception {
+ Cloud cloud = new Cloud();
+ cloud.setCustomFieldBridge( "This is divided by 2" );
+ cloud.setCustomStringBridge( "This is div by 4" );
+ org.hibernate.Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist( cloud );
+ s.flush();
+ tx.commit();
+
+ tx = s.beginTransaction();
+ FullTextSession session = Search.getFullTextSession( s );
+ QueryParser parser = new QueryParser( "id", new SimpleAnalyzer() );
+ Query query;
+ List result;
+
+ query = parser.parse( "customFieldBridge:This AND customStringBridge:This" );
+ result = session.createFullTextQuery( query ).list();
+ assertEquals( "Properties not mapped", 1, result.size() );
+
+ query = parser.parse( "customFieldBridge:by AND customStringBridge:is" );
+ result = session.createFullTextQuery( query ).list();
+ assertEquals( "Custom types not taken into account", 0, result.size() );
+
+ s.delete( s.get( Cloud.class, cloud.getId() ) );
+ tx.commit();
+ s.close();
+
+ }
+
+ public void testDateBridge() throws Exception {
+ Cloud cloud = new Cloud();
+ Calendar c = GregorianCalendar.getInstance();
+ c.setTimeZone( TimeZone.getTimeZone( "GMT" ) ); //for the sake of tests
+ c.set( 2000, 11, 15, 3, 43, 2 );
+ c.set( Calendar.MILLISECOND, 5 );
+
+ Date date = new Date( c.getTimeInMillis() );
+ cloud.setMyDate( date ); //5 millisecond
+ cloud.setDateDay( date );
+ cloud.setDateHour( date );
+ cloud.setDateMillisecond( date );
+ cloud.setDateMinute( date );
+ cloud.setDateMonth( date );
+ cloud.setDateSecond( date );
+ cloud.setDateYear( date );
+ org.hibernate.Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist( cloud );
+ s.flush();
+ tx.commit();
+
+ tx = s.beginTransaction();
+ FullTextSession session = Search.getFullTextSession( s );
+ QueryParser parser = new QueryParser( "id", new StandardAnalyzer() );
+ Query query;
+ List result;
+
+ query = parser.parse(
+ "myDate:[19900101 TO 20060101]"
+ + " AND dateDay:[20001214 TO 2000121501]"
+ + " AND dateMonth:[200012 TO 20001201]"
+ + " AND dateYear:[2000 TO 200001]"
+ + " AND dateHour:[20001214 TO 2000121503]"
+ + " AND dateMinute:[20001214 TO 200012150343]"
+ + " AND dateSecond:[20001214 TO 20001215034302]"
+ + " AND dateMillisecond:[20001214 TO 20001215034302005]"
+ );
+ result = session.createFullTextQuery( query ).list();
+ assertEquals( "Date not found or not property truncated", 1, result.size() );
+
+ s.delete( s.get( Cloud.class, cloud.getId() ) );
+ tx.commit();
+ s.close();
+
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Cloud.class
+ };
+ }
+
+
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.ANALYZER_CLASS, SimpleAnalyzer.class.getName() );
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/CatDeptsFieldsClassBridge.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/CatDeptsFieldsClassBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/CatDeptsFieldsClassBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,43 +1,66 @@
-// $Id$
-package org.hibernate.search.test.bridge;
-
-import java.util.Map;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.hibernate.search.bridge.FieldBridge;
-import org.hibernate.search.bridge.LuceneOptions;
-import org.hibernate.search.bridge.ParameterizedBridge;
-
-/**
- * @author John Griffin
- */
-public class CatDeptsFieldsClassBridge implements FieldBridge, ParameterizedBridge {
-
- private String sepChar;
-
- @SuppressWarnings("unchecked")
- public void setParameterValues(Map parameters) {
- this.sepChar = (String) parameters.get( "sepChar" );
- }
-
- public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
- // In this particular class the name of the new field was passed
- // from the name field of the ClassBridge Annotation. This is not
- // a requirement. It just works that way in this instance. The
- // actual name could be supplied by hard coding it below.
- Departments dep = (Departments) value;
- String fieldValue1 = dep.getBranch();
- if ( fieldValue1 == null ) {
- fieldValue1 = "";
- }
- String fieldValue2 = dep.getNetwork();
- if ( fieldValue2 == null ) {
- fieldValue2 = "";
- }
- String fieldValue = fieldValue1 + sepChar + fieldValue2;
- Field field = new Field( name, fieldValue, luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector() );
- field.setBoost( luceneOptions.getBoost() );
- document.add( field );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.bridge;
+
+import java.util.Map;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.hibernate.search.bridge.FieldBridge;
+import org.hibernate.search.bridge.LuceneOptions;
+import org.hibernate.search.bridge.ParameterizedBridge;
+
+/**
+ * @author John Griffin
+ */
+public class CatDeptsFieldsClassBridge implements FieldBridge, ParameterizedBridge {
+
+ private String sepChar;
+
+ @SuppressWarnings("unchecked")
+ public void setParameterValues(Map parameters) {
+ this.sepChar = (String) parameters.get( "sepChar" );
+ }
+
+ public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
+ // In this particular class the name of the new field was passed
+ // from the name field of the ClassBridge Annotation. This is not
+ // a requirement. It just works that way in this instance. The
+ // actual name could be supplied by hard coding it below.
+ Departments dep = (Departments) value;
+ String fieldValue1 = dep.getBranch();
+ if ( fieldValue1 == null ) {
+ fieldValue1 = "";
+ }
+ String fieldValue2 = dep.getNetwork();
+ if ( fieldValue2 == null ) {
+ fieldValue2 = "";
+ }
+ String fieldValue = fieldValue1 + sepChar + fieldValue2;
+ Field field = new Field( name, fieldValue, luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector() );
+ field.setBoost( luceneOptions.getBoost() );
+ document.add( field );
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/CatFieldsClassBridge.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/CatFieldsClassBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/CatFieldsClassBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.bridge;
import java.util.Map;
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/ClassBridgeTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/ClassBridgeTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/ClassBridgeTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.bridge;
import java.util.List;
@@ -309,4 +332,4 @@
super.configure( cfg );
cfg.setProperty( Environment.ANALYZER_CLASS, SimpleAnalyzer.class.getName() );
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/Cloud.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/Cloud.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/Cloud.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,308 +1,331 @@
-//$Id$
-package org.hibernate.search.test.bridge;
-
-import java.util.Date;
-import java.net.URL;
-import java.net.URI;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-
-import org.hibernate.search.annotations.DateBridge;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.FieldBridge;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.Parameter;
-import org.hibernate.search.annotations.Resolution;
-import org.hibernate.search.annotations.Store;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-@Indexed
-public class Cloud {
- private int id;
- private Long long1;
- private long long2;
- private Integer integerv1;
- private int integerv2;
- private Double double1;
- private double double2;
- private Float float1;
- private float float2;
- private String string;
- private Date myDate;
- private Date dateYear;
- private Date dateMonth;
- private Date dateDay;
- private Date dateHour;
- private Date dateMinute;
- private Date dateSecond;
- private Date dateMillisecond;
- private String customFieldBridge;
- private String customStringBridge;
- private Character char1;
- private char char2;
- private CloudType type;
- private boolean storm;
- private Class clazz;
- private URL url;
- private URI uri;
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- public URL getUrl() {
- return url;
- }
-
- public void setUrl(URL url) {
- this.url = url;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- public URI getUri() {
- return uri;
- }
-
- public void setUri(URI uri) {
- this.uri = uri;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- public Class getClazz() {
- return clazz;
- }
-
- public void setClazz(Class clazz) {
- this.clazz = clazz;
- }
-
- @Field(index=Index.TOKENIZED, store=Store.YES)
- @FieldBridge(impl = TruncateFieldBridge.class)
- public String getCustomFieldBridge() {
- return customFieldBridge;
- }
-
- public void setCustomFieldBridge(String customFieldBridge) {
- this.customFieldBridge = customFieldBridge;
- }
-
- @Field(index=Index.TOKENIZED, store=Store.YES,
- bridge = @FieldBridge(impl = TruncateStringBridge.class, params = @Parameter( name="dividedBy", value="4" ) )
- )
- public String getCustomStringBridge() {
- return customStringBridge;
- }
-
- public void setCustomStringBridge(String customStringBridge) {
- this.customStringBridge = customStringBridge;
- }
-
- @Id @GeneratedValue @DocumentId
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- public Long getLong1() {
- return long1;
- }
-
- public void setLong1(Long long1) {
- this.long1 = long1;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- public long getLong2() {
- return long2;
- }
-
- public void setLong2(long long2) {
- this.long2 = long2;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- public Integer getIntegerv1() {
- return integerv1;
- }
-
- public void setIntegerv1(Integer integerv1) {
- this.integerv1 = integerv1;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- public int getIntegerv2() {
- return integerv2;
- }
-
- public void setIntegerv2(int integerv2) {
- this.integerv2 = integerv2;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- public Double getDouble1() {
- return double1;
- }
-
- public void setDouble1(Double double1) {
- this.double1 = double1;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- public double getDouble2() {
- return double2;
- }
-
- public void setDouble2(double double2) {
- this.double2 = double2;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- public Float getFloat1() {
- return float1;
- }
-
- public void setFloat1(Float float1) {
- this.float1 = float1;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- public float getFloat2() {
- return float2;
- }
-
- public void setFloat2(float float2) {
- this.float2 = float2;
- }
-
- @Field(index=Index.TOKENIZED, store=Store.YES)
- public String getString() {
- return string;
- }
-
- public void setString(String string) {
- this.string = string;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- public Date getMyDate() {
- return myDate;
- }
-
- public void setMyDate(Date myDate) {
- this.myDate = myDate;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- @DateBridge( resolution = Resolution.YEAR )
- public Date getDateYear() {
- return dateYear;
- }
-
- public void setDateYear(Date dateYear) {
- this.dateYear = dateYear;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- @DateBridge( resolution = Resolution.MONTH )
- public Date getDateMonth() {
- return dateMonth;
- }
-
- public void setDateMonth(Date dateMonth) {
- this.dateMonth = dateMonth;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- @DateBridge( resolution = Resolution.DAY )
- public Date getDateDay() {
- return dateDay;
- }
-
- public void setDateDay(Date dateDay) {
- this.dateDay = dateDay;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- @DateBridge( resolution = Resolution.HOUR )
- public Date getDateHour() {
- return dateHour;
- }
-
- public void setDateHour(Date dateHour) {
- this.dateHour = dateHour;
- }
-
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- @DateBridge( resolution = Resolution.MINUTE )
- public Date getDateMinute() {
- return dateMinute;
- }
-
- public void setDateMinute(Date dateMinute) {
- this.dateMinute = dateMinute;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- @DateBridge( resolution = Resolution.SECOND )
- public Date getDateSecond() {
- return dateSecond;
- }
-
- public void setDateSecond(Date dateSecond) {
- this.dateSecond = dateSecond;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- @DateBridge( resolution = Resolution.MILLISECOND )
- public Date getDateMillisecond() {
- return dateMillisecond;
- }
-
- public void setDateMillisecond(Date dateMillisecond) {
- this.dateMillisecond = dateMillisecond;
- }
-
- @Field(index = Index.TOKENIZED, store = Store.YES)
- public CloudType getType() {
- return type;
- }
-
- public void setType(CloudType type) {
- this.type = type;
- }
-
- @Field(index = Index.TOKENIZED )
- public boolean isStorm() {
- return storm;
- }
-
- public void setStorm(boolean storm) {
- this.storm = storm;
- }
-
- @Field(index = Index.TOKENIZED, store = Store.YES)
- public Character getChar1() {
- return char1;
- }
-
- public void setChar1(Character char1) {
- this.char1 = char1;
- }
-
- @Field(index = Index.TOKENIZED, store = Store.YES)
- public char getChar2() {
- return char2;
- }
-
- public void setChar2(char char2) {
- this.char2 = char2;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.bridge;
+
+import java.util.Date;
+import java.net.URL;
+import java.net.URI;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.search.annotations.DateBridge;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.FieldBridge;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Parameter;
+import org.hibernate.search.annotations.Resolution;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed
+public class Cloud {
+ private int id;
+ private Long long1;
+ private long long2;
+ private Integer integerv1;
+ private int integerv2;
+ private Double double1;
+ private double double2;
+ private Float float1;
+ private float float2;
+ private String string;
+ private Date myDate;
+ private Date dateYear;
+ private Date dateMonth;
+ private Date dateDay;
+ private Date dateHour;
+ private Date dateMinute;
+ private Date dateSecond;
+ private Date dateMillisecond;
+ private String customFieldBridge;
+ private String customStringBridge;
+ private Character char1;
+ private char char2;
+ private CloudType type;
+ private boolean storm;
+ private Class clazz;
+ private URL url;
+ private URI uri;
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public URL getUrl() {
+ return url;
+ }
+
+ public void setUrl(URL url) {
+ this.url = url;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public URI getUri() {
+ return uri;
+ }
+
+ public void setUri(URI uri) {
+ this.uri = uri;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public Class getClazz() {
+ return clazz;
+ }
+
+ public void setClazz(Class clazz) {
+ this.clazz = clazz;
+ }
+
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ @FieldBridge(impl = TruncateFieldBridge.class)
+ public String getCustomFieldBridge() {
+ return customFieldBridge;
+ }
+
+ public void setCustomFieldBridge(String customFieldBridge) {
+ this.customFieldBridge = customFieldBridge;
+ }
+
+ @Field(index=Index.TOKENIZED, store=Store.YES,
+ bridge = @FieldBridge(impl = TruncateStringBridge.class, params = @Parameter( name="dividedBy", value="4" ) )
+ )
+ public String getCustomStringBridge() {
+ return customStringBridge;
+ }
+
+ public void setCustomStringBridge(String customStringBridge) {
+ this.customStringBridge = customStringBridge;
+ }
+
+ @Id @GeneratedValue @DocumentId
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public Long getLong1() {
+ return long1;
+ }
+
+ public void setLong1(Long long1) {
+ this.long1 = long1;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public long getLong2() {
+ return long2;
+ }
+
+ public void setLong2(long long2) {
+ this.long2 = long2;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public Integer getIntegerv1() {
+ return integerv1;
+ }
+
+ public void setIntegerv1(Integer integerv1) {
+ this.integerv1 = integerv1;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public int getIntegerv2() {
+ return integerv2;
+ }
+
+ public void setIntegerv2(int integerv2) {
+ this.integerv2 = integerv2;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public Double getDouble1() {
+ return double1;
+ }
+
+ public void setDouble1(Double double1) {
+ this.double1 = double1;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public double getDouble2() {
+ return double2;
+ }
+
+ public void setDouble2(double double2) {
+ this.double2 = double2;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public Float getFloat1() {
+ return float1;
+ }
+
+ public void setFloat1(Float float1) {
+ this.float1 = float1;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public float getFloat2() {
+ return float2;
+ }
+
+ public void setFloat2(float float2) {
+ this.float2 = float2;
+ }
+
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ public String getString() {
+ return string;
+ }
+
+ public void setString(String string) {
+ this.string = string;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public Date getMyDate() {
+ return myDate;
+ }
+
+ public void setMyDate(Date myDate) {
+ this.myDate = myDate;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ @DateBridge( resolution = Resolution.YEAR )
+ public Date getDateYear() {
+ return dateYear;
+ }
+
+ public void setDateYear(Date dateYear) {
+ this.dateYear = dateYear;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ @DateBridge( resolution = Resolution.MONTH )
+ public Date getDateMonth() {
+ return dateMonth;
+ }
+
+ public void setDateMonth(Date dateMonth) {
+ this.dateMonth = dateMonth;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ @DateBridge( resolution = Resolution.DAY )
+ public Date getDateDay() {
+ return dateDay;
+ }
+
+ public void setDateDay(Date dateDay) {
+ this.dateDay = dateDay;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ @DateBridge( resolution = Resolution.HOUR )
+ public Date getDateHour() {
+ return dateHour;
+ }
+
+ public void setDateHour(Date dateHour) {
+ this.dateHour = dateHour;
+ }
+
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ @DateBridge( resolution = Resolution.MINUTE )
+ public Date getDateMinute() {
+ return dateMinute;
+ }
+
+ public void setDateMinute(Date dateMinute) {
+ this.dateMinute = dateMinute;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ @DateBridge( resolution = Resolution.SECOND )
+ public Date getDateSecond() {
+ return dateSecond;
+ }
+
+ public void setDateSecond(Date dateSecond) {
+ this.dateSecond = dateSecond;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ @DateBridge( resolution = Resolution.MILLISECOND )
+ public Date getDateMillisecond() {
+ return dateMillisecond;
+ }
+
+ public void setDateMillisecond(Date dateMillisecond) {
+ this.dateMillisecond = dateMillisecond;
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.YES)
+ public CloudType getType() {
+ return type;
+ }
+
+ public void setType(CloudType type) {
+ this.type = type;
+ }
+
+ @Field(index = Index.TOKENIZED )
+ public boolean isStorm() {
+ return storm;
+ }
+
+ public void setStorm(boolean storm) {
+ this.storm = storm;
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.YES)
+ public Character getChar1() {
+ return char1;
+ }
+
+ public void setChar1(Character char1) {
+ this.char1 = char1;
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.YES)
+ public char getChar2() {
+ return char2;
+ }
+
+ public void setChar2(char char2) {
+ this.char2 = char2;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/CloudType.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/CloudType.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/CloudType.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.bridge;
/**
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/DateSplitBridge.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/DateSplitBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/DateSplitBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,52 +1,75 @@
-//$Id$
-package org.hibernate.search.test.bridge;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.hibernate.search.bridge.FieldBridge;
-import org.hibernate.search.bridge.LuceneOptions;
-
-/**
- * Store the date in 3 different fields - year, month, day - to ease Range Query per
- * year, month or day (eg get all the elements of December for the last 5 years).
- *
- * @author Emmanuel Bernard
- */
-public class DateSplitBridge implements FieldBridge {
- private final static TimeZone GMT = TimeZone.getTimeZone("GMT");
-
- public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
- Date date = (Date) value;
- Calendar cal = GregorianCalendar.getInstance(GMT);
- cal.setTime(date);
- int year = cal.get(Calendar.YEAR);
- int month = cal.get(Calendar.MONTH) + 1;
- int day = cal.get(Calendar.DAY_OF_MONTH);
-
- // set year
- Field field = new Field(name + ".year", String.valueOf(year),
- luceneOptions.getStore(), luceneOptions.getIndex(),
- luceneOptions.getTermVector());
- field.setBoost(luceneOptions.getBoost());
- document.add(field);
-
- // set month and pad it if needed
- field = new Field(name + ".month", month < 10 ? "0" : ""
- + String.valueOf(month), luceneOptions.getStore(),
- luceneOptions.getIndex(), luceneOptions.getTermVector());
- field.setBoost(luceneOptions.getBoost());
- document.add(field);
-
- // set day and pad it if needed
- field = new Field(name + ".day", day < 10 ? "0" : ""
- + String.valueOf(day), luceneOptions.getStore(),
- luceneOptions.getIndex(), luceneOptions.getTermVector());
- field.setBoost(luceneOptions.getBoost());
- document.add(field);
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.bridge;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.hibernate.search.bridge.FieldBridge;
+import org.hibernate.search.bridge.LuceneOptions;
+
+/**
+ * Store the date in 3 different fields - year, month, day - to ease Range Query per
+ * year, month or day (eg get all the elements of December for the last 5 years).
+ *
+ * @author Emmanuel Bernard
+ */
+public class DateSplitBridge implements FieldBridge {
+ private final static TimeZone GMT = TimeZone.getTimeZone("GMT");
+
+ public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
+ Date date = (Date) value;
+ Calendar cal = GregorianCalendar.getInstance(GMT);
+ cal.setTime(date);
+ int year = cal.get(Calendar.YEAR);
+ int month = cal.get(Calendar.MONTH) + 1;
+ int day = cal.get(Calendar.DAY_OF_MONTH);
+
+ // set year
+ Field field = new Field(name + ".year", String.valueOf(year),
+ luceneOptions.getStore(), luceneOptions.getIndex(),
+ luceneOptions.getTermVector());
+ field.setBoost(luceneOptions.getBoost());
+ document.add(field);
+
+ // set month and pad it if needed
+ field = new Field(name + ".month", month < 10 ? "0" : ""
+ + String.valueOf(month), luceneOptions.getStore(),
+ luceneOptions.getIndex(), luceneOptions.getTermVector());
+ field.setBoost(luceneOptions.getBoost());
+ document.add(field);
+
+ // set day and pad it if needed
+ field = new Field(name + ".day", day < 10 ? "0" : ""
+ + String.valueOf(day), luceneOptions.getStore(),
+ luceneOptions.getIndex(), luceneOptions.getTermVector());
+ field.setBoost(luceneOptions.getBoost());
+ document.add(field);
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/Department.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/Department.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/Department.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.bridge;
import javax.persistence.Entity;
@@ -76,4 +99,4 @@
public void setMaxEmployees(Integer maxEmployees) {
this.maxEmployees = maxEmployees;
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/Departments.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/Departments.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/Departments.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.bridge;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/EquipmentType.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/EquipmentType.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/EquipmentType.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,43 +1,66 @@
-// $Id$
-package org.hibernate.search.test.bridge;
-
-import java.util.Map;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-
-import org.hibernate.search.bridge.FieldBridge;
-import org.hibernate.search.bridge.LuceneOptions;
-import org.hibernate.search.bridge.ParameterizedBridge;
-
-/**
- * @author John Griffin
- */
-@SuppressWarnings("unchecked")
-public class EquipmentType implements FieldBridge, ParameterizedBridge {
- private Map equips;
-
- public void setParameterValues(Map parameters) {
- // This map was defined by the parameters of the ClassBridge annotation.
- this.equips = parameters;
- }
-
- public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
- // In this particular class the name of the new field was passed
- // from the name field of the ClassBridge Annotation. This is not
- // a requirement. It just works that way in this instance. The
- // actual name could be supplied by hard coding it below.
- Departments deps = ( Departments ) value;
- Field field;
- String fieldValue1 = deps.getManufacturer();
-
- if ( fieldValue1 != null ) {
- String fieldValue = ( String ) equips.get( fieldValue1 );
- field = new Field(
- name, fieldValue, luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector()
- );
- field.setBoost( luceneOptions.getBoost() );
- document.add( field );
- }
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.bridge;
+
+import java.util.Map;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+
+import org.hibernate.search.bridge.FieldBridge;
+import org.hibernate.search.bridge.LuceneOptions;
+import org.hibernate.search.bridge.ParameterizedBridge;
+
+/**
+ * @author John Griffin
+ */
+@SuppressWarnings("unchecked")
+public class EquipmentType implements FieldBridge, ParameterizedBridge {
+ private Map equips;
+
+ public void setParameterValues(Map parameters) {
+ // This map was defined by the parameters of the ClassBridge annotation.
+ this.equips = parameters;
+ }
+
+ public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
+ // In this particular class the name of the new field was passed
+ // from the name field of the ClassBridge Annotation. This is not
+ // a requirement. It just works that way in this instance. The
+ // actual name could be supplied by hard coding it below.
+ Departments deps = ( Departments ) value;
+ Field field;
+ String fieldValue1 = deps.getManufacturer();
+
+ if ( fieldValue1 != null ) {
+ String fieldValue = ( String ) equips.get( fieldValue1 );
+ field = new Field(
+ name, fieldValue, luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector()
+ );
+ field.setBoost( luceneOptions.getBoost() );
+ document.add( field );
+ }
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/Gangster.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/Gangster.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/Gangster.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.bridge;
import java.io.Serializable;
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/PaddedIntegerBridge.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/PaddedIntegerBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/PaddedIntegerBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,39 +1,62 @@
-//$Id$
-package org.hibernate.search.test.bridge;
-
-import java.util.Map;
-
-import org.hibernate.search.bridge.ParameterizedBridge;
-import org.hibernate.search.bridge.TwoWayStringBridge;
-
-/**
- * Padding Integer bridge.
- * All numbers will be padded with 0 to match 5 digits
- *
- * @author Emmanuel Bernard
- */
-public class PaddedIntegerBridge implements TwoWayStringBridge, ParameterizedBridge {
-
- public static final String PADDING_PROPERTY = "padding";
-
- private int padding = 5; //default
-
- public void setParameterValues(Map parameters) {
- Object padding = parameters.get( PADDING_PROPERTY );
- if (padding != null) this.padding = (Integer) padding;
- }
-
- public String objectToString(Object object) {
- String rawInteger = object.toString();
- if (rawInteger.length() > padding) throw new IllegalArgumentException( "Try to pad on a number too big" );
- StringBuilder paddedInteger = new StringBuilder( );
- for ( int padIndex = rawInteger.length() ; padIndex < padding ; padIndex++ ) {
- paddedInteger.append('0');
- }
- return paddedInteger.append( rawInteger ).toString();
- }
-
- public Object stringToObject(String stringValue) {
- return new Integer(stringValue);
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.bridge;
+
+import java.util.Map;
+
+import org.hibernate.search.bridge.ParameterizedBridge;
+import org.hibernate.search.bridge.TwoWayStringBridge;
+
+/**
+ * Padding Integer bridge.
+ * All numbers will be padded with 0 to match 5 digits
+ *
+ * @author Emmanuel Bernard
+ */
+public class PaddedIntegerBridge implements TwoWayStringBridge, ParameterizedBridge {
+
+ public static final String PADDING_PROPERTY = "padding";
+
+ private int padding = 5; //default
+
+ public void setParameterValues(Map parameters) {
+ Object padding = parameters.get( PADDING_PROPERTY );
+ if (padding != null) this.padding = (Integer) padding;
+ }
+
+ public String objectToString(Object object) {
+ String rawInteger = object.toString();
+ if (rawInteger.length() > padding) throw new IllegalArgumentException( "Try to pad on a number too big" );
+ StringBuilder paddedInteger = new StringBuilder( );
+ for ( int padIndex = rawInteger.length() ; padIndex < padding ; padIndex++ ) {
+ paddedInteger.append('0');
+ }
+ return paddedInteger.append( rawInteger ).toString();
+ }
+
+ public Object stringToObject(String stringValue) {
+ return new Integer(stringValue);
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/TruncateFieldBridge.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/TruncateFieldBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/TruncateFieldBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,30 +1,53 @@
-//$Id$
-package org.hibernate.search.test.bridge;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.hibernate.search.bridge.FieldBridge;
-import org.hibernate.search.bridge.LuceneOptions;
-import org.hibernate.util.StringHelper;
-
-/**
- * @author Emmanuel Bernard
- */
-public class TruncateFieldBridge implements FieldBridge {
- public Object get(String name, Document document) {
- Field field = document.getField( name );
- return field.stringValue();
- }
-
- public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
- String indexedString = (String) value;
- //Do not add fields on empty strings, seems a sensible default in most situations
- if ( StringHelper.isNotEmpty( indexedString ) ) {
- Field field = new Field(name, indexedString.substring(0,
- indexedString.length() / 2), luceneOptions.getStore(),
- luceneOptions.getIndex(), luceneOptions.getTermVector());
- field.setBoost( luceneOptions.getBoost() );
- document.add( field );
- }
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.bridge;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.hibernate.search.bridge.FieldBridge;
+import org.hibernate.search.bridge.LuceneOptions;
+import org.hibernate.util.StringHelper;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class TruncateFieldBridge implements FieldBridge {
+ public Object get(String name, Document document) {
+ Field field = document.getField( name );
+ return field.stringValue();
+ }
+
+ public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
+ String indexedString = (String) value;
+ //Do not add fields on empty strings, seems a sensible default in most situations
+ if ( StringHelper.isNotEmpty( indexedString ) ) {
+ Field field = new Field(name, indexedString.substring(0,
+ indexedString.length() / 2), luceneOptions.getStore(),
+ luceneOptions.getIndex(), luceneOptions.getTermVector());
+ field.setBoost( luceneOptions.getBoost() );
+ document.add( field );
+ }
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/TruncateStringBridge.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/TruncateStringBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/TruncateStringBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,26 +1,49 @@
-//$Id$
-package org.hibernate.search.test.bridge;
-
-import java.util.Map;
-
-import org.hibernate.search.bridge.StringBridge;
-import org.hibernate.search.bridge.ParameterizedBridge;
-
-/**
- * @author Emmanuel Bernard
- */
-public class TruncateStringBridge implements StringBridge, ParameterizedBridge {
- private int div;
- public Object stringToObject(String stringValue) {
- return stringValue;
- }
-
- public String objectToString(Object object) {
- String string = (String) object;
- return object != null ? string.substring( 0, string.length() / div ) : null;
- }
-
- public void setParameterValues(Map parameters) {
- div = Integer.valueOf( (String) parameters.get( "dividedBy" ) );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.bridge;
+
+import java.util.Map;
+
+import org.hibernate.search.bridge.StringBridge;
+import org.hibernate.search.bridge.ParameterizedBridge;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class TruncateStringBridge implements StringBridge, ParameterizedBridge {
+ private int div;
+ public Object stringToObject(String stringValue) {
+ return stringValue;
+ }
+
+ public String objectToString(Object object) {
+ String string = (String) object;
+ return object != null ? string.substring( 0, string.length() / div ) : null;
+ }
+
+ public void setParameterValues(Map parameters) {
+ div = Integer.valueOf( (String) parameters.get( "dividedBy" ) );
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/UnresolvedBridgeTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/UnresolvedBridgeTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/UnresolvedBridgeTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.bridge;
import org.hibernate.search.SearchException;
Modified: search/trunk/src/test/java/org/hibernate/search/test/classloading/Animal.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/classloading/Animal.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/classloading/Animal.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.classloading;
import org.hibernate.search.annotations.Field;
@@ -51,4 +58,4 @@
public void setName(String name) {
this.name = name;
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/classloading/NoAnnotationsTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/classloading/NoAnnotationsTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/classloading/NoAnnotationsTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.classloading;
import java.util.List;
@@ -65,4 +88,4 @@
"org/hibernate/search/test/classloading/Animal.hbm.xml"
};
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/Address.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/Address.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/Address.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.configuration;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/ConfigurationParseHelperTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/ConfigurationParseHelperTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/ConfigurationParseHelperTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.configuration;
import java.util.Properties;
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/ConfigurationReadTestCase.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/ConfigurationReadTestCase.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/ConfigurationReadTestCase.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.configuration;
import org.hibernate.HibernateException;
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/Country.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/Country.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/Country.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.configuration;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/CustomBackendTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/CustomBackendTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/CustomBackendTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.configuration;
import junit.framework.TestCase;
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/EventListenerRegisterTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/EventListenerRegisterTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/EventListenerRegisterTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.configuration;
import java.util.Properties;
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/LuceneIndexingParametersTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/LuceneIndexingParametersTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/LuceneIndexingParametersTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.configuration;
import java.io.IOException;
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/MaskedPropertiesTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/MaskedPropertiesTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/MaskedPropertiesTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.configuration;
import java.io.IOException;
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.configuration;
import java.lang.annotation.ElementType;
@@ -215,4 +239,4 @@
Country.class
};
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/ShardsConfigurationTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/ShardsConfigurationTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/ShardsConfigurationTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.configuration;
import static org.hibernate.search.backend.configuration.IndexWriterSetting.MAX_BUFFERED_DOCS;
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/UselessShardingStrategy.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/UselessShardingStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/UselessShardingStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.configuration;
import java.io.Serializable;
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/User.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/User.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/User.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.configuration;
/**
Modified: search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/CustomLockFactoryFactory.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/CustomLockFactoryFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/CustomLockFactoryFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.directoryProvider;
import java.io.File;
Modified: search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/CustomLockProviderTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/CustomLockProviderTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/CustomLockProviderTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.directoryProvider;
import junit.framework.TestCase;
Modified: search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/DirectoryProviderHelperTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/DirectoryProviderHelperTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/DirectoryProviderHelperTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.directoryProvider;
import java.io.File;
Modified: search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/FSSlaveAndMasterDPTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/FSSlaveAndMasterDPTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/FSSlaveAndMasterDPTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.directoryProvider;
import java.io.File;
Modified: search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/MultipleSFTestCase.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/MultipleSFTestCase.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/MultipleSFTestCase.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.directoryProvider;
import java.io.InputStream;
Modified: search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/SnowStorm.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/SnowStorm.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/directoryProvider/SnowStorm.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.directoryProvider;
import java.util.Date;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/Address.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/Address.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/Address.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded;
import java.util.HashSet;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/Author.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/Author.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/Author.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/Country.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/Country.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/Country.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded;
import java.util.ArrayList;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/EmbeddedTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/EmbeddedTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/EmbeddedTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded;
import java.util.ArrayList;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/NonIndexedEntity.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/NonIndexedEntity.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/NonIndexedEntity.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/Order.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/Order.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/Order.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded;
import javax.persistence.Id;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/Owner.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/Owner.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/Owner.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded;
import javax.persistence.Embeddable;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/Person.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/Person.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/Person.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded;
/**
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/Product.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/Product.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/Product.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded;
import java.util.Set;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/State.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/State.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/State.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/StateCandidate.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/StateCandidate.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/StateCandidate.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded;
import javax.persistence.CascadeType;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/Tower.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/Tower.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/Tower.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded;
import javax.persistence.CascadeType;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/Address.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/Address.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/Address.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded.doubleinsert;
import java.io.Serializable;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/BusinessContact.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/BusinessContact.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/BusinessContact.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded.doubleinsert;
import javax.persistence.Column;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/Contact.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/Contact.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/Contact.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded.doubleinsert;
import java.io.Serializable;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/DoubleInsertEmbeddedTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/DoubleInsertEmbeddedTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/DoubleInsertEmbeddedTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded.doubleinsert;
import java.util.Date;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/PersonalContact.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/PersonalContact.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/PersonalContact.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded.doubleinsert;
import java.util.Date;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/Phone.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/Phone.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/doubleinsert/Phone.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded.doubleinsert;
import java.io.Serializable;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Address.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Address.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Address.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id:$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded.nested;
import java.util.HashSet;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Attribute.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Attribute.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Attribute.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id:$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded.nested;
import java.util.ArrayList;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/AttributeValue.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/AttributeValue.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/AttributeValue.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id:$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded.nested;
import javax.persistence.Column;
@@ -74,4 +81,4 @@
public void setAttribute(Attribute attribute) {
this.attribute = attribute;
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/NestedEmbeddedTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/NestedEmbeddedTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/NestedEmbeddedTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded.nested;
import java.util.List;
@@ -135,4 +158,4 @@
Product.class, Attribute.class, AttributeValue.class, Person.class, Place.class, Address.class
};
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Person.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Person.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Person.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id:$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded.nested;
import java.util.ArrayList;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Place.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Place.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Place.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id:$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded.nested;
import java.util.HashSet;
Modified: search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Product.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Product.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/embedded/nested/Product.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id:$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.embedded.nested;
import java.util.ArrayList;
Modified: search/trunk/src/test/java/org/hibernate/search/test/engine/BusLine.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/engine/BusLine.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/engine/BusLine.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.engine;
import java.util.HashSet;
Modified: search/trunk/src/test/java/org/hibernate/search/test/engine/BusStop.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/engine/BusStop.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/engine/BusStop.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.engine;
import java.util.HashSet;
Modified: search/trunk/src/test/java/org/hibernate/search/test/engine/EventListenerSerializationTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/engine/EventListenerSerializationTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/engine/EventListenerSerializationTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.engine;
import java.io.IOException;
Modified: search/trunk/src/test/java/org/hibernate/search/test/engine/LazyCollectionsUpdatingTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/engine/LazyCollectionsUpdatingTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/engine/LazyCollectionsUpdatingTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.engine;
import java.util.List;
Modified: search/trunk/src/test/java/org/hibernate/search/test/engine/RollbackTransactionTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/engine/RollbackTransactionTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/engine/RollbackTransactionTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.engine;
import org.apache.lucene.analysis.SimpleAnalyzer;
Modified: search/trunk/src/test/java/org/hibernate/search/test/fieldAccess/Document.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/fieldAccess/Document.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/fieldAccess/Document.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,80 +1,103 @@
-//$Id$
-package org.hibernate.search.test.fieldAccess;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-
-import org.hibernate.search.annotations.Boost;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.Store;
-
-/**
- * @author Richard Hallier
- */
-@Entity
-@Indexed(index = "DocumentField")
-public class Document {
- @Id
- @GeneratedValue
- @DocumentId
- private Long id;
-
- @Field(index = Index.TOKENIZED)
- @Boost(2)
- private String title;
-
- @Field(name="Abstract", index=Index.TOKENIZED, store= Store.NO)
- private String summary;
-
- @Lob
- @Field(index=Index.TOKENIZED, store=Store.NO)
- private String text;
-
- Document() {
- }
-
- public Document(String title, String summary, String text) {
- super();
- this.summary = summary;
- this.text = text;
- this.title = title;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getSummary() {
- return summary;
- }
-
- public void setSummary(String summary) {
- this.summary = summary;
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-}
-
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.fieldAccess;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+
+import org.hibernate.search.annotations.Boost;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author Richard Hallier
+ */
+@Entity
+@Indexed(index = "DocumentField")
+public class Document {
+ @Id
+ @GeneratedValue
+ @DocumentId
+ private Long id;
+
+ @Field(index = Index.TOKENIZED)
+ @Boost(2)
+ private String title;
+
+ @Field(name="Abstract", index=Index.TOKENIZED, store= Store.NO)
+ private String summary;
+
+ @Lob
+ @Field(index=Index.TOKENIZED, store=Store.NO)
+ private String text;
+
+ Document() {
+ }
+
+ public Document(String title, String summary, String text) {
+ super();
+ this.summary = summary;
+ this.text = text;
+ this.title = title;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getSummary() {
+ return summary;
+ }
+
+ public void setSummary(String summary) {
+ this.summary = summary;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+}
+
Modified: search/trunk/src/test/java/org/hibernate/search/test/fieldAccess/FieldAccessTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/fieldAccess/FieldAccessTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/fieldAccess/FieldAccessTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,69 +1,92 @@
-//$Id$
-package org.hibernate.search.test.fieldAccess;
-
-import java.util.List;
-
-import org.hibernate.search.test.SearchTestCase;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-
-/**
- * @author Emmanuel Bernard
- */
-public class FieldAccessTest extends SearchTestCase {
-
- public void testFields() throws Exception {
- Document doc = new Document( "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" );
- Session s = openSession();
- Transaction tx = s.beginTransaction();
- s.persist( doc );
- tx.commit();
-
- s.clear();
-
- FullTextSession session = Search.getFullTextSession(s);
- tx = session.beginTransaction();
- QueryParser p = new QueryParser("id", new StandardAnalyzer( ) );
- List result = session.createFullTextQuery( p.parse( "Abstract:Hibernate" ) ).list();
- assertEquals( "Query by field", 1, result.size() );
- s.delete( result.get( 0 ) );
- tx.commit();
- s.close();
-
- }
-
- public void testFieldBoost() throws Exception {
- Session s = openSession();
- Transaction tx = s.beginTransaction();
- s.persist(
- new Document( "Hibernate in Action", "Object and Relational", "blah blah blah" )
- );
- s.persist(
- new Document( "Object and Relational", "Hibernate in Action", "blah blah blah" )
- );
- tx.commit();
-
- s.clear();
-
- FullTextSession session = Search.getFullTextSession(s);
- tx = session.beginTransaction();
- QueryParser p = new QueryParser("id", new StandardAnalyzer( ) );
- List result = session.createFullTextQuery( p.parse( "title:Action OR Abstract:Action" ) ).list();
- assertEquals( "Query by field", 2, result.size() );
- assertEquals( "@Boost fails", "Hibernate in Action", ( (Document) result.get( 0 ) ).getTitle() );
- s.delete( result.get( 0 ) );
- tx.commit();
- s.close();
-
- }
-
- protected Class[] getMappings() {
- return new Class[] {
- Document.class
- };
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.fieldAccess;
+
+import java.util.List;
+
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class FieldAccessTest extends SearchTestCase {
+
+ public void testFields() throws Exception {
+ Document doc = new Document( "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" );
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist( doc );
+ tx.commit();
+
+ s.clear();
+
+ FullTextSession session = Search.getFullTextSession(s);
+ tx = session.beginTransaction();
+ QueryParser p = new QueryParser("id", new StandardAnalyzer( ) );
+ List result = session.createFullTextQuery( p.parse( "Abstract:Hibernate" ) ).list();
+ assertEquals( "Query by field", 1, result.size() );
+ s.delete( result.get( 0 ) );
+ tx.commit();
+ s.close();
+
+ }
+
+ public void testFieldBoost() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist(
+ new Document( "Hibernate in Action", "Object and Relational", "blah blah blah" )
+ );
+ s.persist(
+ new Document( "Object and Relational", "Hibernate in Action", "blah blah blah" )
+ );
+ tx.commit();
+
+ s.clear();
+
+ FullTextSession session = Search.getFullTextSession(s);
+ tx = session.beginTransaction();
+ QueryParser p = new QueryParser("id", new StandardAnalyzer( ) );
+ List result = session.createFullTextQuery( p.parse( "title:Action OR Abstract:Action" ) ).list();
+ assertEquals( "Query by field", 2, result.size() );
+ assertEquals( "@Boost fails", "Hibernate in Action", ( (Document) result.get( 0 ) ).getTitle() );
+ s.delete( result.get( 0 ) );
+ tx.commit();
+ s.close();
+
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Document.class
+ };
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/filter/AndDocIdSetsTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/filter/AndDocIdSetsTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/filter/AndDocIdSetsTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.filter;
import java.io.IOException;
Modified: search/trunk/src/test/java/org/hibernate/search/test/filter/BestDriversFilter.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/filter/BestDriversFilter.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/filter/BestDriversFilter.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.filter;
import java.io.IOException;
Modified: search/trunk/src/test/java/org/hibernate/search/test/filter/Driver.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/filter/Driver.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/filter/Driver.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.filter;
import java.util.Date;
Modified: search/trunk/src/test/java/org/hibernate/search/test/filter/ExcludeAllFilter.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/filter/ExcludeAllFilter.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/filter/ExcludeAllFilter.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.filter;
import java.util.BitSet;
Modified: search/trunk/src/test/java/org/hibernate/search/test/filter/ExcludeAllFilterFactory.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/filter/ExcludeAllFilterFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/filter/ExcludeAllFilterFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.filter;
import org.apache.lucene.search.Filter;
Modified: search/trunk/src/test/java/org/hibernate/search/test/filter/FilterTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/filter/FilterTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/filter/FilterTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.filter;
import java.util.Calendar;
Modified: search/trunk/src/test/java/org/hibernate/search/test/filter/FiltersOptimizationTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/filter/FiltersOptimizationTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/filter/FiltersOptimizationTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.filter;
import java.io.IOException;
Modified: search/trunk/src/test/java/org/hibernate/search/test/filter/InstanceBasedExcludeAllFilter.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/filter/InstanceBasedExcludeAllFilter.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/filter/InstanceBasedExcludeAllFilter.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.filter;
import java.util.BitSet;
Modified: search/trunk/src/test/java/org/hibernate/search/test/filter/SecurityFilterFactory.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/filter/SecurityFilterFactory.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/filter/SecurityFilterFactory.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.filter;
import org.apache.lucene.index.Term;
Modified: search/trunk/src/test/java/org/hibernate/search/test/filter/Soap.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/filter/Soap.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/filter/Soap.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.filter;
import javax.persistence.Id;
Modified: search/trunk/src/test/java/org/hibernate/search/test/id/Animal.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/id/Animal.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/id/Animal.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,20 +1,27 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.id;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/id/EmbeddedIdTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/id/EmbeddedIdTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/id/EmbeddedIdTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.id;
import java.util.List;
Modified: search/trunk/src/test/java/org/hibernate/search/test/id/ImplicitIdTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/id/ImplicitIdTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/id/ImplicitIdTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.id;
import java.util.List;
@@ -45,4 +68,4 @@
Animal.class
};
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/id/Person.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/id/Person.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/id/Person.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.id;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/id/PersonPK.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/id/PersonPK.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/id/PersonPK.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.id;
import java.io.Serializable;
Modified: search/trunk/src/test/java/org/hibernate/search/test/id/PersonPKBridge.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/id/PersonPKBridge.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/id/PersonPKBridge.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.id;
import org.apache.lucene.document.Document;
Modified: search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdPerson.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdPerson.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdPerson.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.id.providedId;
import org.hibernate.search.annotations.*;
Modified: search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdPersonSub.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdPersonSub.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdPersonSub.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.id.providedId;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.id.providedId;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
Modified: search/trunk/src/test/java/org/hibernate/search/test/indexingStrategy/ManualIndexingStrategyTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/indexingStrategy/ManualIndexingStrategyTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/indexingStrategy/ManualIndexingStrategyTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.indexingStrategy;
import org.apache.lucene.index.IndexReader;
Modified: search/trunk/src/test/java/org/hibernate/search/test/inheritance/Animal.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/inheritance/Animal.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/inheritance/Animal.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,38 +1,61 @@
-//$Id$
-package org.hibernate.search.test.inheritance;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Store;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-public abstract class Animal extends Being {
- private Long id;
- private String name;
-
- @Id @GeneratedValue @DocumentId
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- @Field(index= Index.TOKENIZED, store= Store.YES)
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.inheritance;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public abstract class Animal extends Being {
+ private Long id;
+ private String name;
+
+ @Id @GeneratedValue @DocumentId
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Field(index= Index.TOKENIZED, store= Store.YES)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/inheritance/Being.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/inheritance/Being.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/inheritance/Being.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.inheritance;
import javax.persistence.MappedSuperclass;
Modified: search/trunk/src/test/java/org/hibernate/search/test/inheritance/Bird.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/inheritance/Bird.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/inheritance/Bird.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,28 +1,51 @@
-//$Id$
-package org.hibernate.search.test.inheritance;
-
-import javax.persistence.Entity;
-
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.Store;
-
-/**
- * @author Hardy Ferentschik
- */
-@Entity
-@Indexed
-public class Bird extends Animal {
-
- private int numberOfEggs;
-
- @Field(index = Index.UN_TOKENIZED, store = Store.YES)
- public int getNumberOfEggs() {
- return numberOfEggs;
- }
-
- public void setNumberOfEggs(int numberOfEggs) {
- this.numberOfEggs = numberOfEggs;
- }
-}
\ No newline at end of file
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.inheritance;
+
+import javax.persistence.Entity;
+
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+@Indexed
+public class Bird extends Animal {
+
+ private int numberOfEggs;
+
+ @Field(index = Index.UN_TOKENIZED, store = Store.YES)
+ public int getNumberOfEggs() {
+ return numberOfEggs;
+ }
+
+ public void setNumberOfEggs(int numberOfEggs) {
+ this.numberOfEggs = numberOfEggs;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/inheritance/Eagle.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/inheritance/Eagle.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/inheritance/Eagle.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,33 +1,56 @@
-//$Id$
-package org.hibernate.search.test.inheritance;
-
-import javax.persistence.Entity;
-
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.Store;
-
-/**
- * @author Hardy Ferentschik
- */
-@Entity
-@Indexed
-public class Eagle extends Bird {
-
- private WingType wingYype;
-
- @Field(index = Index.UN_TOKENIZED, store = Store.YES)
- public WingType getWingYype() {
- return wingYype;
- }
-
- public void setWingYype(WingType wingYype) {
- this.wingYype = wingYype;
- }
-
- public enum WingType {
- BROAD,
- LONG
- }
-}
\ No newline at end of file
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.inheritance;
+
+import javax.persistence.Entity;
+
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+@Indexed
+public class Eagle extends Bird {
+
+ private WingType wingYype;
+
+ @Field(index = Index.UN_TOKENIZED, store = Store.YES)
+ public WingType getWingYype() {
+ return wingYype;
+ }
+
+ public void setWingYype(WingType wingYype) {
+ this.wingYype = wingYype;
+ }
+
+ public enum WingType {
+ BROAD,
+ LONG
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/inheritance/Fish.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/inheritance/Fish.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/inheritance/Fish.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,28 +1,51 @@
-//$Id$
-package org.hibernate.search.test.inheritance;
-
-import javax.persistence.Entity;
-
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.Store;
-
-/**
- * @author Hardy Ferentschik
- */
-@Entity
-@Indexed
-public class Fish extends Animal {
-
- private int numberOfDorsalFins;
-
- @Field(index = Index.UN_TOKENIZED, store = Store.YES)
- public int getNumberOfDorsalFins() {
- return numberOfDorsalFins;
- }
-
- public void setNumberOfDorsalFins(int numberOfDorsalFins) {
- this.numberOfDorsalFins = numberOfDorsalFins;
- }
-}
\ No newline at end of file
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.inheritance;
+
+import javax.persistence.Entity;
+
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+@Indexed
+public class Fish extends Animal {
+
+ private int numberOfDorsalFins;
+
+ @Field(index = Index.UN_TOKENIZED, store = Store.YES)
+ public int getNumberOfDorsalFins() {
+ return numberOfDorsalFins;
+ }
+
+ public void setNumberOfDorsalFins(int numberOfDorsalFins) {
+ this.numberOfDorsalFins = numberOfDorsalFins;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/inheritance/InheritanceTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/inheritance/InheritanceTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/inheritance/InheritanceTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,293 +1,316 @@
-//$Id$
-package org.hibernate.search.test.inheritance;
-
-import java.util.List;
-import java.io.Serializable;
-
-import org.apache.lucene.analysis.StopAnalyzer;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RangeQuery;
-import org.apache.lucene.search.TermQuery;
-import org.slf4j.Logger;
-
-import org.hibernate.Transaction;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.util.LoggerFactory;
-import org.hibernate.search.test.SearchTestCase;
-
-/**
- * @author Emmanuel Bernard
- */
-public class InheritanceTest extends SearchTestCase {
-
- private static final Logger log = LoggerFactory.make();
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- public void testSearchUnindexClass() throws Exception {
- createTestData();
-
- QueryParser parser = new QueryParser( "name", new StopAnalyzer() );
- Query query = parser.parse( "Elephant" );
-
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
- try {
- org.hibernate.Query hibQuery = s.createFullTextQuery( query, String.class );
- hibQuery.list();
- tx.commit();
- fail();
- }
- catch ( IllegalArgumentException iae ) {
- log.debug( "success" );
- }
-
- tx = s.beginTransaction();
- org.hibernate.Query hibQuery = s.createFullTextQuery( query, Mammal.class );
- assertItsTheElephant( hibQuery.list() );
- tx.commit();
-
- s.close();
- }
-
- public void testInheritance() throws Exception {
- createTestData();
-
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
-
- QueryParser parser = new QueryParser( "name", new StopAnalyzer() );
- Query query = parser.parse( "Elephant" );
- org.hibernate.Query hibQuery = s.createFullTextQuery( query, Mammal.class );
- assertItsTheElephant( hibQuery.list() );
-
- query = parser.parse( "Elephant" );
- hibQuery = s.createFullTextQuery( query);
- assertItsTheElephant( hibQuery.list() );
-
- query = parser.parse( "hasSweatGlands:false" );
- hibQuery = s.createFullTextQuery( query, Animal.class, Mammal.class );
- assertItsTheElephant( hibQuery.list() );
-
- query = parser.parse( "Elephant OR White Pointer" );
- hibQuery = s.createFullTextQuery( query, Being.class );
- List result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "Query filtering on superclass return mapped subclasses", 2, result.size() );
-
- query = new RangeQuery( new Term( "weight", "04000" ), new Term( "weight", "05000" ), true );
- hibQuery = s.createFullTextQuery( query, Animal.class );
- assertItsTheElephant( hibQuery.list() );
-
- query = parser.parse( "Elephant" );
- hibQuery = s.createFullTextQuery( query, Being.class );
- assertItsTheElephant( hibQuery.list() );
-
- tx.commit();
- s.close();
- }
-
-
- public void testPolymorphicQueries() throws Exception {
- createTestData();
-
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "name", new StopAnalyzer() );
- Query query = parser.parse( "Elephant" );
-
- org.hibernate.Query hibQuery = s.createFullTextQuery( query, Mammal.class );
- assertItsTheElephant( hibQuery.list() );
-
- hibQuery = s.createFullTextQuery( query, Animal.class );
- assertItsTheElephant( hibQuery.list() );
-
- hibQuery = s.createFullTextQuery( query, Being.class );
- assertItsTheElephant( hibQuery.list() );
-
- hibQuery = s.createFullTextQuery( query, Object.class );
- assertItsTheElephant( hibQuery.list() );
-
- hibQuery = s.createFullTextQuery( query, Serializable.class );
- assertItsTheElephant( hibQuery.list() );
-
- hibQuery = s.createFullTextQuery(
- query, Mammal.class, Animal.class, Being.class, Object.class, Serializable.class
- );
- assertItsTheElephant( hibQuery.list() );
-
- tx.commit();
- s.close();
- }
-
- public void testSubclassInclusion() throws Exception {
- createTestData();
-
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
-
- Query query = new TermQuery( new Term( "numberOfEggs", "2" ) );
- org.hibernate.Query hibQuery = s.createFullTextQuery( query, Eagle.class );
- List result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "Wrong number of hits. There should be two birds.", 1, result.size() );
-
- query = new TermQuery( new Term( "numberOfEggs", "2" ) );
- hibQuery = s.createFullTextQuery( query, Bird.class );
- result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "Wrong number of hits. There should be two birds.", 2, result.size() );
-
- query = new TermQuery( new Term( "numberOfEggs", "2" ) );
- hibQuery = s.createFullTextQuery( query, Mammal.class );
- result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "Wrong number of hits. There should be two birds.", 0, result.size() );
-
- try {
- query = new TermQuery( new Term( "numberOfEggs", "2" ) );
- hibQuery = s.createFullTextQuery( query, String.class );
- hibQuery.list();
- fail();
- }
- catch ( IllegalArgumentException iae ) {
- log.debug( "success" );
- }
-
- tx.commit();
- s.close();
- }
-
- /**
- * Tests that purging the index of a class also purges the index of the subclasses. See also HSEARCH-262.
- *
- * @throws Exception in case the test fails.
- */
- public void testPurgeIndex() throws Exception {
- createTestData();
- FullTextSession s = Search.getFullTextSession( openSession() );
-
- Transaction tx = s.beginTransaction();
- assertNumberOfAnimals( s, 5 );
- tx.commit();
-
- tx = s.beginTransaction();
- s.purgeAll( Serializable.class );
- tx.commit();
-
- tx = s.beginTransaction();
- assertNumberOfAnimals( s, 3 );
- tx.commit();
-
- tx = s.beginTransaction();
- s.purgeAll( Bird.class );
- tx.commit();
-
- tx = s.beginTransaction();
- assertNumberOfAnimals( s, 1 );
- tx.commit();
-
- tx = s.beginTransaction();
- s.purgeAll( Object.class );
- tx.commit();
-
- tx = s.beginTransaction();
- assertNumberOfAnimals( s, 0 );
- tx.commit();
-
- s.close();
- }
-
- /**
- * Tests that purging the an uninexed class triggers an exception.
- *
- * @throws Exception in case the test fails.
- */
- public void testPurgeUnIndexClass() throws Exception {
- createTestData();
- FullTextSession s = Search.getFullTextSession( openSession() );
-
- Transaction tx = s.beginTransaction();
- assertNumberOfAnimals( s, 5 );
- tx.commit();
-
- tx = s.beginTransaction();
- try {
- s.purgeAll( String.class );
- tx.commit();
- fail();
- }
- catch ( IllegalArgumentException iae ) {
- log.debug( "Success" );
- }
- s.close();
- }
-
- private void assertNumberOfAnimals(FullTextSession s, int count) throws Exception {
- QueryParser parser = new QueryParser( "name", new StopAnalyzer() );
- Query query = parser.parse( "Elephant OR White Pointer OR Chimpanzee OR Dove or Eagle" );
- List result = s.createFullTextQuery( query, Animal.class ).list();
- assertNotNull( result );
- assertEquals( "Wrong number of hits. There should be one elephant and one shark.", count, result.size() );
- }
-
- private void createTestData() {
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
-
- Fish shark = new Fish();
- shark.setName( "White Pointer" );
- shark.setNumberOfDorsalFins( 2 );
- shark.setWeight( 1500 );
- s.save( shark );
-
- Mammal elephant = new Mammal();
- elephant.setName( "Elephant" );
- elephant.setHasSweatGlands( false );
- elephant.setWeight( 4500 );
- s.save( elephant );
-
- Mammal chimp = new Mammal();
- chimp.setName( "Chimpanzee" );
- chimp.setHasSweatGlands( true );
- chimp.setWeight( 50 );
- s.save( chimp );
-
- Bird dove = new Bird();
- dove.setName( "Dove" );
- dove.setNumberOfEggs( 2 );
- s.save( dove );
-
- Eagle eagle = new Eagle();
- eagle.setName( "Bald Eagle" );
- eagle.setNumberOfEggs( 2 );
- eagle.setWingYype( Eagle.WingType.BROAD );
- s.save( eagle );
-
- tx.commit();
- s.clear();
- }
-
- private void assertItsTheElephant(List result) {
- assertNotNull( result );
- assertEquals( "Wrong number of results", 1, result.size() );
- assertTrue( "Wrong result type", result.get( 0 ) instanceof Mammal );
- Mammal mammal = ( Mammal ) result.get( 0 );
- assertEquals( "Wrong animal name", "Elephant", mammal.getName() );
- }
-
- protected Class[] getMappings() {
- return new Class[] {
- Animal.class,
- Mammal.class,
- Fish.class,
- Bird.class,
- Eagle.class
- };
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.inheritance;
+
+import java.util.List;
+import java.io.Serializable;
+
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.RangeQuery;
+import org.apache.lucene.search.TermQuery;
+import org.slf4j.Logger;
+
+import org.hibernate.Transaction;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.util.LoggerFactory;
+import org.hibernate.search.test.SearchTestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class InheritanceTest extends SearchTestCase {
+
+ private static final Logger log = LoggerFactory.make();
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testSearchUnindexClass() throws Exception {
+ createTestData();
+
+ QueryParser parser = new QueryParser( "name", new StopAnalyzer() );
+ Query query = parser.parse( "Elephant" );
+
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ try {
+ org.hibernate.Query hibQuery = s.createFullTextQuery( query, String.class );
+ hibQuery.list();
+ tx.commit();
+ fail();
+ }
+ catch ( IllegalArgumentException iae ) {
+ log.debug( "success" );
+ }
+
+ tx = s.beginTransaction();
+ org.hibernate.Query hibQuery = s.createFullTextQuery( query, Mammal.class );
+ assertItsTheElephant( hibQuery.list() );
+ tx.commit();
+
+ s.close();
+ }
+
+ public void testInheritance() throws Exception {
+ createTestData();
+
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+
+ QueryParser parser = new QueryParser( "name", new StopAnalyzer() );
+ Query query = parser.parse( "Elephant" );
+ org.hibernate.Query hibQuery = s.createFullTextQuery( query, Mammal.class );
+ assertItsTheElephant( hibQuery.list() );
+
+ query = parser.parse( "Elephant" );
+ hibQuery = s.createFullTextQuery( query);
+ assertItsTheElephant( hibQuery.list() );
+
+ query = parser.parse( "hasSweatGlands:false" );
+ hibQuery = s.createFullTextQuery( query, Animal.class, Mammal.class );
+ assertItsTheElephant( hibQuery.list() );
+
+ query = parser.parse( "Elephant OR White Pointer" );
+ hibQuery = s.createFullTextQuery( query, Being.class );
+ List result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Query filtering on superclass return mapped subclasses", 2, result.size() );
+
+ query = new RangeQuery( new Term( "weight", "04000" ), new Term( "weight", "05000" ), true );
+ hibQuery = s.createFullTextQuery( query, Animal.class );
+ assertItsTheElephant( hibQuery.list() );
+
+ query = parser.parse( "Elephant" );
+ hibQuery = s.createFullTextQuery( query, Being.class );
+ assertItsTheElephant( hibQuery.list() );
+
+ tx.commit();
+ s.close();
+ }
+
+
+ public void testPolymorphicQueries() throws Exception {
+ createTestData();
+
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "name", new StopAnalyzer() );
+ Query query = parser.parse( "Elephant" );
+
+ org.hibernate.Query hibQuery = s.createFullTextQuery( query, Mammal.class );
+ assertItsTheElephant( hibQuery.list() );
+
+ hibQuery = s.createFullTextQuery( query, Animal.class );
+ assertItsTheElephant( hibQuery.list() );
+
+ hibQuery = s.createFullTextQuery( query, Being.class );
+ assertItsTheElephant( hibQuery.list() );
+
+ hibQuery = s.createFullTextQuery( query, Object.class );
+ assertItsTheElephant( hibQuery.list() );
+
+ hibQuery = s.createFullTextQuery( query, Serializable.class );
+ assertItsTheElephant( hibQuery.list() );
+
+ hibQuery = s.createFullTextQuery(
+ query, Mammal.class, Animal.class, Being.class, Object.class, Serializable.class
+ );
+ assertItsTheElephant( hibQuery.list() );
+
+ tx.commit();
+ s.close();
+ }
+
+ public void testSubclassInclusion() throws Exception {
+ createTestData();
+
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+
+ Query query = new TermQuery( new Term( "numberOfEggs", "2" ) );
+ org.hibernate.Query hibQuery = s.createFullTextQuery( query, Eagle.class );
+ List result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Wrong number of hits. There should be two birds.", 1, result.size() );
+
+ query = new TermQuery( new Term( "numberOfEggs", "2" ) );
+ hibQuery = s.createFullTextQuery( query, Bird.class );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Wrong number of hits. There should be two birds.", 2, result.size() );
+
+ query = new TermQuery( new Term( "numberOfEggs", "2" ) );
+ hibQuery = s.createFullTextQuery( query, Mammal.class );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Wrong number of hits. There should be two birds.", 0, result.size() );
+
+ try {
+ query = new TermQuery( new Term( "numberOfEggs", "2" ) );
+ hibQuery = s.createFullTextQuery( query, String.class );
+ hibQuery.list();
+ fail();
+ }
+ catch ( IllegalArgumentException iae ) {
+ log.debug( "success" );
+ }
+
+ tx.commit();
+ s.close();
+ }
+
+ /**
+ * Tests that purging the index of a class also purges the index of the subclasses. See also HSEARCH-262.
+ *
+ * @throws Exception in case the test fails.
+ */
+ public void testPurgeIndex() throws Exception {
+ createTestData();
+ FullTextSession s = Search.getFullTextSession( openSession() );
+
+ Transaction tx = s.beginTransaction();
+ assertNumberOfAnimals( s, 5 );
+ tx.commit();
+
+ tx = s.beginTransaction();
+ s.purgeAll( Serializable.class );
+ tx.commit();
+
+ tx = s.beginTransaction();
+ assertNumberOfAnimals( s, 3 );
+ tx.commit();
+
+ tx = s.beginTransaction();
+ s.purgeAll( Bird.class );
+ tx.commit();
+
+ tx = s.beginTransaction();
+ assertNumberOfAnimals( s, 1 );
+ tx.commit();
+
+ tx = s.beginTransaction();
+ s.purgeAll( Object.class );
+ tx.commit();
+
+ tx = s.beginTransaction();
+ assertNumberOfAnimals( s, 0 );
+ tx.commit();
+
+ s.close();
+ }
+
+ /**
+ * Tests that purging the an uninexed class triggers an exception.
+ *
+ * @throws Exception in case the test fails.
+ */
+ public void testPurgeUnIndexClass() throws Exception {
+ createTestData();
+ FullTextSession s = Search.getFullTextSession( openSession() );
+
+ Transaction tx = s.beginTransaction();
+ assertNumberOfAnimals( s, 5 );
+ tx.commit();
+
+ tx = s.beginTransaction();
+ try {
+ s.purgeAll( String.class );
+ tx.commit();
+ fail();
+ }
+ catch ( IllegalArgumentException iae ) {
+ log.debug( "Success" );
+ }
+ s.close();
+ }
+
+ private void assertNumberOfAnimals(FullTextSession s, int count) throws Exception {
+ QueryParser parser = new QueryParser( "name", new StopAnalyzer() );
+ Query query = parser.parse( "Elephant OR White Pointer OR Chimpanzee OR Dove or Eagle" );
+ List result = s.createFullTextQuery( query, Animal.class ).list();
+ assertNotNull( result );
+ assertEquals( "Wrong number of hits. There should be one elephant and one shark.", count, result.size() );
+ }
+
+ private void createTestData() {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+
+ Fish shark = new Fish();
+ shark.setName( "White Pointer" );
+ shark.setNumberOfDorsalFins( 2 );
+ shark.setWeight( 1500 );
+ s.save( shark );
+
+ Mammal elephant = new Mammal();
+ elephant.setName( "Elephant" );
+ elephant.setHasSweatGlands( false );
+ elephant.setWeight( 4500 );
+ s.save( elephant );
+
+ Mammal chimp = new Mammal();
+ chimp.setName( "Chimpanzee" );
+ chimp.setHasSweatGlands( true );
+ chimp.setWeight( 50 );
+ s.save( chimp );
+
+ Bird dove = new Bird();
+ dove.setName( "Dove" );
+ dove.setNumberOfEggs( 2 );
+ s.save( dove );
+
+ Eagle eagle = new Eagle();
+ eagle.setName( "Bald Eagle" );
+ eagle.setNumberOfEggs( 2 );
+ eagle.setWingYype( Eagle.WingType.BROAD );
+ s.save( eagle );
+
+ tx.commit();
+ s.clear();
+ }
+
+ private void assertItsTheElephant(List result) {
+ assertNotNull( result );
+ assertEquals( "Wrong number of results", 1, result.size() );
+ assertTrue( "Wrong result type", result.get( 0 ) instanceof Mammal );
+ Mammal mammal = ( Mammal ) result.get( 0 );
+ assertEquals( "Wrong animal name", "Elephant", mammal.getName() );
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Animal.class,
+ Mammal.class,
+ Fish.class,
+ Bird.class,
+ Eagle.class
+ };
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/inheritance/Mammal.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/inheritance/Mammal.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/inheritance/Mammal.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,28 +1,51 @@
-//$Id$
-package org.hibernate.search.test.inheritance;
-
-import java.io.Serializable;
-import javax.persistence.Entity;
-
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.Store;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-@Indexed
-public class Mammal extends Animal implements Serializable {
- private boolean hasSweatGlands;
-
- @Field(index= Index.UN_TOKENIZED, store= Store.YES)
- public boolean isHasSweatGlands() {
- return hasSweatGlands;
- }
-
- public void setHasSweatGlands(boolean hasSweatGlands) {
- this.hasSweatGlands = hasSweatGlands;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.inheritance;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed
+public class Mammal extends Animal implements Serializable {
+ private boolean hasSweatGlands;
+
+ @Field(index= Index.UN_TOKENIZED, store= Store.YES)
+ public boolean isHasSweatGlands() {
+ return hasSweatGlands;
+ }
+
+ public void setHasSweatGlands(boolean hasSweatGlands) {
+ this.hasSweatGlands = hasSweatGlands;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/jgroups/common/JGroupsCommonTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jgroups/common/JGroupsCommonTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jgroups/common/JGroupsCommonTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,129 +1,152 @@
-// $Id$
-package org.hibernate.search.test.jgroups.common;
-
-import java.util.List;
-
-import org.apache.lucene.analysis.StopAnalyzer;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Query;
-
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.search.Environment;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.backend.impl.jgroups.JGroupsBackendQueueProcessorFactory;
-import org.hibernate.search.test.jgroups.master.TShirt;
-
-/**
- * In case of running test outside Hibernate Search Maven configuration set following VM configuration:
- * <br><br>
- * <code>
- * -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1
- * </code>
- * @author Lukasz Moren
- */
-
-public class JGroupsCommonTest extends MultipleSessionsSearchTestCase {
-
- public static final String CHANNEL_NAME = "jgroups_test_channel";
- private static final String DEFAULT_JGROUPS_CONFIGURATION_FILE = "flush-udp.xml";
-
- public void testJGroupsBackend() throws Exception {
-
- //get slave session
- Session s = getSlaveSession();
- Transaction tx = s.beginTransaction();
- TShirt ts = new TShirt();
- ts.setLogo( "Boston" );
- ts.setSize( "XXL" );
- TShirt ts2 = new TShirt();
- ts2.setLogo( "Mapple leaves" );
- ts2.setSize( "L" );
- s.persist( ts );
- s.persist( ts2 );
- tx.commit();
-
- Thread.sleep( 3000 );
-
- FullTextSession ftSess = Search.getFullTextSession( openSession() );
- ftSess.getTransaction().begin();
- QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
- Query luceneQuery = parser.parse( "logo:Boston or logo:Mapple leaves" );
- org.hibernate.Query query = ftSess.createFullTextQuery( luceneQuery );
- List result = query.list();
-
- assertEquals( 2, result.size() );
-
- s = getSlaveSession();
- tx = s.beginTransaction();
- ts = ( TShirt ) s.get( TShirt.class, ts.getId() );
- ts.setLogo( "Peter pan" );
- tx.commit();
-
- //need to sleep for the message consumption
- Thread.sleep( 3000 );
-
- parser = new QueryParser( "id", new StopAnalyzer() );
- luceneQuery = parser.parse( "logo:Peter pan" );
- query = ftSess.createFullTextQuery( luceneQuery );
- result = query.list();
- assertEquals( 1, result.size() );
-
- s = getSlaveSession();
- tx = s.beginTransaction();
- s.delete( s.get( TShirt.class, ts.getId() ) );
- s.delete( s.get( TShirt.class, ts2.getId() ) );
- tx.commit();
-
- //Need to sleep for the message consumption
- Thread.sleep( 3000 );
-
- parser = new QueryParser( "id", new StopAnalyzer() );
- luceneQuery = parser.parse( "logo:Boston or logo:Mapple leaves" );
- query = ftSess.createFullTextQuery( luceneQuery );
- result = query.list();
- assertEquals( 0, result.size() );
-
- ftSess.close();
- s.close();
-
- }
-
- @Override
- protected void configure(Configuration cfg) {
- //master jgroups configuration
- super.configure( cfg );
- cfg.setProperty( Environment.WORKER_BACKEND, "jgroupsMaster" );
- cfg.setProperty( JGroupsBackendQueueProcessorFactory.CONFIGURATION_FILE, DEFAULT_JGROUPS_CONFIGURATION_FILE );
- }
-
- @Override
- protected void commonConfigure(Configuration cfg) {
- //slave jgroups configuration
- super.commonConfigure( cfg );
- cfg.setProperty( Environment.WORKER_BACKEND, "jgroupsSlave" );
- cfg.setProperty( JGroupsBackendQueueProcessorFactory.CONFIGURATION_FILE, DEFAULT_JGROUPS_CONFIGURATION_FILE );
- }
-
- public static Session getSession() throws HibernateException {
- return sessions.openSession();
- }
-
- @Override
- protected Class<?>[] getMappings() {
- return new Class[] {
- TShirt.class
- };
- }
-
- protected Class<?>[] getCommonMappings() {
- return new Class[] {
- TShirt.class
- };
- }
-
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.jgroups.common;
+
+import java.util.List;
+
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.search.Environment;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.backend.impl.jgroups.JGroupsBackendQueueProcessorFactory;
+import org.hibernate.search.test.jgroups.master.TShirt;
+
+/**
+ * In case of running test outside Hibernate Search Maven configuration set following VM configuration:
+ * <br><br>
+ * <code>
+ * -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1
+ * </code>
+ * @author Lukasz Moren
+ */
+
+public class JGroupsCommonTest extends MultipleSessionsSearchTestCase {
+
+ public static final String CHANNEL_NAME = "jgroups_test_channel";
+ private static final String DEFAULT_JGROUPS_CONFIGURATION_FILE = "flush-udp.xml";
+
+ public void testJGroupsBackend() throws Exception {
+
+ //get slave session
+ Session s = getSlaveSession();
+ Transaction tx = s.beginTransaction();
+ TShirt ts = new TShirt();
+ ts.setLogo( "Boston" );
+ ts.setSize( "XXL" );
+ TShirt ts2 = new TShirt();
+ ts2.setLogo( "Mapple leaves" );
+ ts2.setSize( "L" );
+ s.persist( ts );
+ s.persist( ts2 );
+ tx.commit();
+
+ Thread.sleep( 3000 );
+
+ FullTextSession ftSess = Search.getFullTextSession( openSession() );
+ ftSess.getTransaction().begin();
+ QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
+ Query luceneQuery = parser.parse( "logo:Boston or logo:Mapple leaves" );
+ org.hibernate.Query query = ftSess.createFullTextQuery( luceneQuery );
+ List result = query.list();
+
+ assertEquals( 2, result.size() );
+
+ s = getSlaveSession();
+ tx = s.beginTransaction();
+ ts = ( TShirt ) s.get( TShirt.class, ts.getId() );
+ ts.setLogo( "Peter pan" );
+ tx.commit();
+
+ //need to sleep for the message consumption
+ Thread.sleep( 3000 );
+
+ parser = new QueryParser( "id", new StopAnalyzer() );
+ luceneQuery = parser.parse( "logo:Peter pan" );
+ query = ftSess.createFullTextQuery( luceneQuery );
+ result = query.list();
+ assertEquals( 1, result.size() );
+
+ s = getSlaveSession();
+ tx = s.beginTransaction();
+ s.delete( s.get( TShirt.class, ts.getId() ) );
+ s.delete( s.get( TShirt.class, ts2.getId() ) );
+ tx.commit();
+
+ //Need to sleep for the message consumption
+ Thread.sleep( 3000 );
+
+ parser = new QueryParser( "id", new StopAnalyzer() );
+ luceneQuery = parser.parse( "logo:Boston or logo:Mapple leaves" );
+ query = ftSess.createFullTextQuery( luceneQuery );
+ result = query.list();
+ assertEquals( 0, result.size() );
+
+ ftSess.close();
+ s.close();
+
+ }
+
+ @Override
+ protected void configure(Configuration cfg) {
+ //master jgroups configuration
+ super.configure( cfg );
+ cfg.setProperty( Environment.WORKER_BACKEND, "jgroupsMaster" );
+ cfg.setProperty( JGroupsBackendQueueProcessorFactory.CONFIGURATION_FILE, DEFAULT_JGROUPS_CONFIGURATION_FILE );
+ }
+
+ @Override
+ protected void commonConfigure(Configuration cfg) {
+ //slave jgroups configuration
+ super.commonConfigure( cfg );
+ cfg.setProperty( Environment.WORKER_BACKEND, "jgroupsSlave" );
+ cfg.setProperty( JGroupsBackendQueueProcessorFactory.CONFIGURATION_FILE, DEFAULT_JGROUPS_CONFIGURATION_FILE );
+ }
+
+ public static Session getSession() throws HibernateException {
+ return sessions.openSession();
+ }
+
+ @Override
+ protected Class<?>[] getMappings() {
+ return new Class[] {
+ TShirt.class
+ };
+ }
+
+ protected Class<?>[] getCommonMappings() {
+ return new Class[] {
+ TShirt.class
+ };
+ }
+
+
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/jgroups/common/MultipleSessionsSearchTestCase.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jgroups/common/MultipleSessionsSearchTestCase.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jgroups/common/MultipleSessionsSearchTestCase.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,151 +1,174 @@
-// $Id$
-package org.hibernate.search.test.jgroups.common;
-
-import java.io.InputStream;
-
-import org.slf4j.Logger;
-
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.AnnotationConfiguration;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.classic.Session;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.search.test.SearchTestCase;
-import org.hibernate.search.util.FileHelper;
-
-/**
- * Test class to simulate clustered environment (one master, and one slave node)
- *
- * @author Lukasz Moren
- */
-public abstract class MultipleSessionsSearchTestCase extends SearchTestCase {
-
- private static final Logger log = org.hibernate.search.util.LoggerFactory.make();
-
- private String masterCopy = "/master/copy";
-
- /**
- * The lucene index directory which is specific to the master node.
- */
- private String masterMain = "/master/main";
-
- /**
- * The lucene index directory which is specific to the slave node.
- */
- private String slave = "/slave";
-
-
- protected static SessionFactory slaveSessionFactory;
-
- /**
- * Common configuration for all slave nodes
- */
- private Configuration commonCfg;
-
- @Override
- protected void configure(Configuration cfg) {
- super.configure( cfg );
-
- //master
- cfg.setProperty( "hibernate.search.default.sourceBase", getIndexDir().getAbsolutePath() + masterCopy );
- cfg.setProperty( "hibernate.search.default.indexBase", getIndexDir().getAbsolutePath() + masterMain );
- cfg.setProperty( "hibernate.search.default.refresh", "1" );
- cfg.setProperty(
- "hibernate.search.default.directory_provider", "org.hibernate.search.store.FSMasterDirectoryProvider"
- );
- }
-
- protected void commonConfigure(Configuration cfg) {
- super.configure( cfg );
-
- //slave(s)
- cfg.setProperty( "hibernate.search.default.sourceBase", getIndexDir().getAbsolutePath() + masterCopy );
- cfg.setProperty( "hibernate.search.default.indexBase", getIndexDir().getAbsolutePath() + slave );
- cfg.setProperty( "hibernate.search.default.refresh", "1" );
- cfg.setProperty(
- "hibernate.search.default.directory_provider", "org.hibernate.search.store.FSSlaveDirectoryProvider"
- );
- }
-
- @Override
- protected void setUp() throws Exception {
- if ( getIndexDir().exists() ) {
- FileHelper.delete( getIndexDir() );
- }
- super.setUp();
- buildCommonSessionFactory( getCommonMappings(), getCommonAnnotatedPackages(), getCommonXmlFiles() );
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
-
- //close session factories and clean index files
- if ( slaveSessionFactory != null ) {
- slaveSessionFactory.close();
- }
- if ( getSessions() != null ) {
- getSessions().close();
- }
- log.info( "Deleting test directory {} ", getIndexDir().getAbsolutePath() );
- FileHelper.delete( getIndexDir() );
- }
-
- private void buildCommonSessionFactory(Class<?>[] classes, String[] packages, String[] xmlFiles) throws Exception {
- try {
- if ( getSlaveSessionFactory() != null ) {
- getSlaveSessionFactory().close();
- }
-
- setCommonCfg( new AnnotationConfiguration() );
- commonConfigure( commonCfg );
- if ( recreateSchema() ) {
- commonCfg.setProperty( org.hibernate.cfg.Environment.HBM2DDL_AUTO, "create-drop" );
- }
- for ( String aPackage : packages ) {
- ( ( AnnotationConfiguration ) getCommonConfiguration() ).addPackage( aPackage );
- }
- for ( Class<?> aClass : classes ) {
- ( ( AnnotationConfiguration ) getCommonConfiguration() ).addAnnotatedClass( aClass );
- }
- for ( String xmlFile : xmlFiles ) {
- InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile );
- getCommonConfiguration().addInputStream( is );
- }
- setDialect( Dialect.getDialect() );
- slaveSessionFactory = getCommonConfiguration().buildSessionFactory();
- }
- catch ( Exception e ) {
- e.printStackTrace();
- throw e;
- }
- }
-
- private void setCommonCfg(Configuration configuration) {
- this.commonCfg = configuration;
- }
-
- protected Configuration getCommonConfiguration() {
- return commonCfg;
- }
-
- protected Session getSlaveSession() {
- return slaveSessionFactory.openSession();
- }
-
- protected static SessionFactory getSlaveSessionFactory() {
- return slaveSessionFactory;
- }
-
- private String[] getCommonAnnotatedPackages() {
- return new String[] { };
- }
-
- private String[] getCommonXmlFiles() {
- return new String[] { };
- }
-
- protected abstract Class<?>[] getMappings();
-
- protected abstract Class<?>[] getCommonMappings();
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.jgroups.common;
+
+import java.io.InputStream;
+
+import org.slf4j.Logger;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.classic.Session;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.util.FileHelper;
+
+/**
+ * Test class to simulate clustered environment (one master, and one slave node)
+ *
+ * @author Lukasz Moren
+ */
+public abstract class MultipleSessionsSearchTestCase extends SearchTestCase {
+
+ private static final Logger log = org.hibernate.search.util.LoggerFactory.make();
+
+ private String masterCopy = "/master/copy";
+
+ /**
+ * The lucene index directory which is specific to the master node.
+ */
+ private String masterMain = "/master/main";
+
+ /**
+ * The lucene index directory which is specific to the slave node.
+ */
+ private String slave = "/slave";
+
+
+ protected static SessionFactory slaveSessionFactory;
+
+ /**
+ * Common configuration for all slave nodes
+ */
+ private Configuration commonCfg;
+
+ @Override
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+
+ //master
+ cfg.setProperty( "hibernate.search.default.sourceBase", getIndexDir().getAbsolutePath() + masterCopy );
+ cfg.setProperty( "hibernate.search.default.indexBase", getIndexDir().getAbsolutePath() + masterMain );
+ cfg.setProperty( "hibernate.search.default.refresh", "1" );
+ cfg.setProperty(
+ "hibernate.search.default.directory_provider", "org.hibernate.search.store.FSMasterDirectoryProvider"
+ );
+ }
+
+ protected void commonConfigure(Configuration cfg) {
+ super.configure( cfg );
+
+ //slave(s)
+ cfg.setProperty( "hibernate.search.default.sourceBase", getIndexDir().getAbsolutePath() + masterCopy );
+ cfg.setProperty( "hibernate.search.default.indexBase", getIndexDir().getAbsolutePath() + slave );
+ cfg.setProperty( "hibernate.search.default.refresh", "1" );
+ cfg.setProperty(
+ "hibernate.search.default.directory_provider", "org.hibernate.search.store.FSSlaveDirectoryProvider"
+ );
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ if ( getIndexDir().exists() ) {
+ FileHelper.delete( getIndexDir() );
+ }
+ super.setUp();
+ buildCommonSessionFactory( getCommonMappings(), getCommonAnnotatedPackages(), getCommonXmlFiles() );
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+
+ //close session factories and clean index files
+ if ( slaveSessionFactory != null ) {
+ slaveSessionFactory.close();
+ }
+ if ( getSessions() != null ) {
+ getSessions().close();
+ }
+ log.info( "Deleting test directory {} ", getIndexDir().getAbsolutePath() );
+ FileHelper.delete( getIndexDir() );
+ }
+
+ private void buildCommonSessionFactory(Class<?>[] classes, String[] packages, String[] xmlFiles) throws Exception {
+ try {
+ if ( getSlaveSessionFactory() != null ) {
+ getSlaveSessionFactory().close();
+ }
+
+ setCommonCfg( new AnnotationConfiguration() );
+ commonConfigure( commonCfg );
+ if ( recreateSchema() ) {
+ commonCfg.setProperty( org.hibernate.cfg.Environment.HBM2DDL_AUTO, "create-drop" );
+ }
+ for ( String aPackage : packages ) {
+ ( ( AnnotationConfiguration ) getCommonConfiguration() ).addPackage( aPackage );
+ }
+ for ( Class<?> aClass : classes ) {
+ ( ( AnnotationConfiguration ) getCommonConfiguration() ).addAnnotatedClass( aClass );
+ }
+ for ( String xmlFile : xmlFiles ) {
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile );
+ getCommonConfiguration().addInputStream( is );
+ }
+ setDialect( Dialect.getDialect() );
+ slaveSessionFactory = getCommonConfiguration().buildSessionFactory();
+ }
+ catch ( Exception e ) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ private void setCommonCfg(Configuration configuration) {
+ this.commonCfg = configuration;
+ }
+
+ protected Configuration getCommonConfiguration() {
+ return commonCfg;
+ }
+
+ protected Session getSlaveSession() {
+ return slaveSessionFactory.openSession();
+ }
+
+ protected static SessionFactory getSlaveSessionFactory() {
+ return slaveSessionFactory;
+ }
+
+ private String[] getCommonAnnotatedPackages() {
+ return new String[] { };
+ }
+
+ private String[] getCommonXmlFiles() {
+ return new String[] { };
+ }
+
+ protected abstract Class<?>[] getMappings();
+
+ protected abstract Class<?>[] getCommonMappings();
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/jgroups/master/JGroupsMasterTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jgroups/master/JGroupsMasterTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jgroups/master/JGroupsMasterTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,171 +1,194 @@
-// $Id$
-package org.hibernate.search.test.jgroups.master;
-
-import java.io.Serializable;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.lucene.analysis.StopAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Query;
-import org.jgroups.JChannel;
-import org.jgroups.Message;
-
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.search.Environment;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.backend.AddLuceneWork;
-import org.hibernate.search.backend.LuceneWork;
-import org.hibernate.search.backend.impl.jgroups.JGroupsBackendQueueProcessorFactory;
-import org.hibernate.search.engine.DocumentBuilder;
-import org.hibernate.search.test.SearchTestCase;
-import org.hibernate.search.test.jms.master.TShirt;
-
-/**
- * Tests that the Master node in a JGroups cluster can properly process messages received from channel.
- * <p/>
- * In case of running test outside Hibernate Search Maven configuration set following VM configuration:
- * <br><br>
- * <code>
- * -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1
- * </code>
- *
- * @author Lukasz Moren
- */
-public class JGroupsMasterTest extends SearchTestCase {
-
- /**
- * Name of the JGroups channel used in test
- */
- public static final String CHANNEL_NAME = "jgroups_test_channel";
-
- private JChannel channel;
-
- public void testMessageSending() throws Exception {
-
- TShirt shirt = createObjectWithSQL();
- List<LuceneWork> queue = createDocumentAndWorkQueue( shirt );
-
- sendMessage( queue );
-
- Thread.sleep( 3000 );
-
- FullTextSession ftSess = Search.getFullTextSession( openSession() );
- ftSess.getTransaction().begin();
- QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
- Query luceneQuery = parser.parse( "logo:jboss" );
- org.hibernate.Query query = ftSess.createFullTextQuery( luceneQuery );
- List result = query.list();
- assertEquals( 1, result.size() );
- ftSess.delete( result.get( 0 ) );
- ftSess.getTransaction().commit();
- ftSess.close();
- }
-
- private void prepareJGroupsChannel() throws Exception {
- channel = new JChannel( prepareJGroupsCongigurationString() );
- channel.connect( CHANNEL_NAME );
- }
-
- private void sendMessage(List<LuceneWork> queue) throws Exception {
- //send message to all listeners
- Message message = new Message( null, null, ( Serializable ) queue );
- channel.send( message );
- }
-
- /**
- * Manually create the work queue. This lists gets send by the Slaves to the Master for indexing.
- *
- * @param shirt The shirt to index
- *
- * @return A manually create <code>LuceneWork</code> list.
- */
- private List<LuceneWork> createDocumentAndWorkQueue(TShirt shirt) {
- Document doc = new Document();
- Field field = new Field(
- DocumentBuilder.CLASS_FIELDNAME, shirt.getClass().getName(), Field.Store.YES, Field.Index.NOT_ANALYZED
- );
- doc.add( field );
- field = new Field( "id", "1", Field.Store.YES, Field.Index.NOT_ANALYZED );
- doc.add( field );
- field = new Field( "logo", shirt.getLogo(), Field.Store.NO, Field.Index.ANALYZED );
- doc.add( field );
- LuceneWork luceneWork = new AddLuceneWork(
- shirt.getId(), String.valueOf( shirt.getId() ), shirt.getClass(), doc
- );
- List<LuceneWork> queue = new ArrayList<LuceneWork>();
- queue.add( luceneWork );
- return queue;
- }
-
- /**
- * Create a test object without trigggering indexing. Use SQL directly.
- *
- * @return a <code>TShirt</code> test object.
- *
- * @throws java.sql.SQLException in case the inset fails.
- */
- @SuppressWarnings({ "deprecation" })
- private TShirt createObjectWithSQL() throws SQLException {
- Session s = openSession();
- s.getTransaction().begin();
- Statement statement = s.connection().createStatement();
- statement.executeUpdate(
- "insert into TShirt_Master(id, logo, size) values( '1', 'JBoss balls', 'large')"
- );
- statement.close();
- TShirt ts = ( TShirt ) s.get( TShirt.class, 1 );
- s.getTransaction().commit();
- s.close();
- return ts;
- }
-
- public static Session getSession() throws HibernateException {
- return sessions.openSession();
- }
-
- protected void setUp() throws Exception {
- prepareJGroupsChannel();
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- channel.close();
- super.tearDown();
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- // JGroups configuration for master node
- cfg.setProperty( Environment.WORKER_BACKEND, "jgroupsMaster" );
- cfg.setProperty( JGroupsBackendQueueProcessorFactory.JG_CLUSTER_NAME, CHANNEL_NAME );
- cfg.setProperty(
- JGroupsBackendQueueProcessorFactory.CONFIGURATION_STRING, prepareJGroupsCongigurationString()
- );
- }
-
- private String prepareJGroupsCongigurationString() {
- return "UDP(mcast_addr=228.1.2.3;mcast_port=45566;ip_ttl=32):" +
- "PING(timeout=3000;num_initial_members=6):" +
- "FD(timeout=5000):" +
- "VERIFY_SUSPECT(timeout=1500):" +
- "pbcast.NAKACK(gc_lag=10;retransmit_timeout=3000):" +
- "UNICAST(timeout=5000):" +
- "FRAG:" +
- "pbcast.GMS(join_timeout=3000;" +
- "shun=false;print_local_addr=true)";
- }
-
- protected Class[] getMappings() {
- return new Class[] {
- TShirt.class
- };
- }
-}
\ No newline at end of file
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.jgroups.master;
+
+import java.io.Serializable;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.jgroups.JChannel;
+import org.jgroups.Message;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.search.Environment;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.backend.AddLuceneWork;
+import org.hibernate.search.backend.LuceneWork;
+import org.hibernate.search.backend.impl.jgroups.JGroupsBackendQueueProcessorFactory;
+import org.hibernate.search.engine.DocumentBuilder;
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.test.jms.master.TShirt;
+
+/**
+ * Tests that the Master node in a JGroups cluster can properly process messages received from channel.
+ * <p/>
+ * In case of running test outside Hibernate Search Maven configuration set following VM configuration:
+ * <br><br>
+ * <code>
+ * -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1
+ * </code>
+ *
+ * @author Lukasz Moren
+ */
+public class JGroupsMasterTest extends SearchTestCase {
+
+ /**
+ * Name of the JGroups channel used in test
+ */
+ public static final String CHANNEL_NAME = "jgroups_test_channel";
+
+ private JChannel channel;
+
+ public void testMessageSending() throws Exception {
+
+ TShirt shirt = createObjectWithSQL();
+ List<LuceneWork> queue = createDocumentAndWorkQueue( shirt );
+
+ sendMessage( queue );
+
+ Thread.sleep( 3000 );
+
+ FullTextSession ftSess = Search.getFullTextSession( openSession() );
+ ftSess.getTransaction().begin();
+ QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
+ Query luceneQuery = parser.parse( "logo:jboss" );
+ org.hibernate.Query query = ftSess.createFullTextQuery( luceneQuery );
+ List result = query.list();
+ assertEquals( 1, result.size() );
+ ftSess.delete( result.get( 0 ) );
+ ftSess.getTransaction().commit();
+ ftSess.close();
+ }
+
+ private void prepareJGroupsChannel() throws Exception {
+ channel = new JChannel( prepareJGroupsCongigurationString() );
+ channel.connect( CHANNEL_NAME );
+ }
+
+ private void sendMessage(List<LuceneWork> queue) throws Exception {
+ //send message to all listeners
+ Message message = new Message( null, null, ( Serializable ) queue );
+ channel.send( message );
+ }
+
+ /**
+ * Manually create the work queue. This lists gets send by the Slaves to the Master for indexing.
+ *
+ * @param shirt The shirt to index
+ *
+ * @return A manually create <code>LuceneWork</code> list.
+ */
+ private List<LuceneWork> createDocumentAndWorkQueue(TShirt shirt) {
+ Document doc = new Document();
+ Field field = new Field(
+ DocumentBuilder.CLASS_FIELDNAME, shirt.getClass().getName(), Field.Store.YES, Field.Index.NOT_ANALYZED
+ );
+ doc.add( field );
+ field = new Field( "id", "1", Field.Store.YES, Field.Index.NOT_ANALYZED );
+ doc.add( field );
+ field = new Field( "logo", shirt.getLogo(), Field.Store.NO, Field.Index.ANALYZED );
+ doc.add( field );
+ LuceneWork luceneWork = new AddLuceneWork(
+ shirt.getId(), String.valueOf( shirt.getId() ), shirt.getClass(), doc
+ );
+ List<LuceneWork> queue = new ArrayList<LuceneWork>();
+ queue.add( luceneWork );
+ return queue;
+ }
+
+ /**
+ * Create a test object without trigggering indexing. Use SQL directly.
+ *
+ * @return a <code>TShirt</code> test object.
+ *
+ * @throws java.sql.SQLException in case the inset fails.
+ */
+ @SuppressWarnings({ "deprecation" })
+ private TShirt createObjectWithSQL() throws SQLException {
+ Session s = openSession();
+ s.getTransaction().begin();
+ Statement statement = s.connection().createStatement();
+ statement.executeUpdate(
+ "insert into TShirt_Master(id, logo, size) values( '1', 'JBoss balls', 'large')"
+ );
+ statement.close();
+ TShirt ts = ( TShirt ) s.get( TShirt.class, 1 );
+ s.getTransaction().commit();
+ s.close();
+ return ts;
+ }
+
+ public static Session getSession() throws HibernateException {
+ return sessions.openSession();
+ }
+
+ protected void setUp() throws Exception {
+ prepareJGroupsChannel();
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ channel.close();
+ super.tearDown();
+ }
+
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+ // JGroups configuration for master node
+ cfg.setProperty( Environment.WORKER_BACKEND, "jgroupsMaster" );
+ cfg.setProperty( JGroupsBackendQueueProcessorFactory.JG_CLUSTER_NAME, CHANNEL_NAME );
+ cfg.setProperty(
+ JGroupsBackendQueueProcessorFactory.CONFIGURATION_STRING, prepareJGroupsCongigurationString()
+ );
+ }
+
+ private String prepareJGroupsCongigurationString() {
+ return "UDP(mcast_addr=228.1.2.3;mcast_port=45566;ip_ttl=32):" +
+ "PING(timeout=3000;num_initial_members=6):" +
+ "FD(timeout=5000):" +
+ "VERIFY_SUSPECT(timeout=1500):" +
+ "pbcast.NAKACK(gc_lag=10;retransmit_timeout=3000):" +
+ "UNICAST(timeout=5000):" +
+ "FRAG:" +
+ "pbcast.GMS(join_timeout=3000;" +
+ "shun=false;print_local_addr=true)";
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ TShirt.class
+ };
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/jgroups/master/TShirt.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jgroups/master/TShirt.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jgroups/master/TShirt.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,50 +1,73 @@
-//$Id$
-package org.hibernate.search.test.jgroups.master;
-
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Indexed;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-@Indexed
-public class TShirt {
- @Id
- @GeneratedValue
- @DocumentId
- private int id;
- @Field(index= Index.TOKENIZED)
- private String logo;
- private String size;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getLogo() {
- return logo;
- }
-
- public void setLogo(String logo) {
- this.logo = logo;
- }
-
- public String getSize() {
- return size;
- }
-
- public void setSize(String size) {
- this.size = size;
- }
-}
\ No newline at end of file
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.jgroups.master;
+
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed
+public class TShirt {
+ @Id
+ @GeneratedValue
+ @DocumentId
+ private int id;
+ @Field(index= Index.TOKENIZED)
+ private String logo;
+ private String size;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getLogo() {
+ return logo;
+ }
+
+ public void setLogo(String logo) {
+ this.logo = logo;
+ }
+
+ public String getSize() {
+ return size;
+ }
+
+ public void setSize(String size) {
+ this.size = size;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/jgroups/slave/JGroupsReceiver.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jgroups/slave/JGroupsReceiver.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jgroups/slave/JGroupsReceiver.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,40 +1,63 @@
-// $Id$
-package org.hibernate.search.test.jgroups.slave;
-
-import java.util.List;
-
-import org.jgroups.Message;
-import org.jgroups.ReceiverAdapter;
-
-import org.hibernate.search.backend.LuceneWork;
-
-/**
- * @author Lukasz Moren
- */
-
-public class JGroupsReceiver extends ReceiverAdapter {
-
- public static int queues;
- public static int works;
-
- public static void reset() {
- queues = 0;
- works = 0;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void receive(Message message) {
-
- List<LuceneWork> queue;
- try {
- queue = ( List<LuceneWork> ) message.getObject();
- }
-
- catch ( ClassCastException e ) {
- return;
- }
- queues++;
- works += queue.size();
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.jgroups.slave;
+
+import java.util.List;
+
+import org.jgroups.Message;
+import org.jgroups.ReceiverAdapter;
+
+import org.hibernate.search.backend.LuceneWork;
+
+/**
+ * @author Lukasz Moren
+ */
+
+public class JGroupsReceiver extends ReceiverAdapter {
+
+ public static int queues;
+ public static int works;
+
+ public static void reset() {
+ queues = 0;
+ works = 0;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void receive(Message message) {
+
+ List<LuceneWork> queue;
+ try {
+ queue = ( List<LuceneWork> ) message.getObject();
+ }
+
+ catch ( ClassCastException e ) {
+ return;
+ }
+ queues++;
+ works += queue.size();
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/jgroups/slave/JGroupsSlaveTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jgroups/slave/JGroupsSlaveTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jgroups/slave/JGroupsSlaveTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,165 +1,188 @@
-// $Id$
-package org.hibernate.search.test.jgroups.slave;
-
-import org.jgroups.Channel;
-import org.jgroups.JChannel;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.search.Environment;
-import org.hibernate.search.backend.impl.jgroups.JGroupsBackendQueueProcessorFactory;
-import org.hibernate.search.test.SearchTestCase;
-import org.hibernate.search.util.XMLHelper;
-
-/**
- * Tests that the Slave node in a JGroups cluster can properly send messages to the channel.
- * <p/>
- * In case of running test outside Hibernate Search Maven configuration set following VM configuration:
- * <br><br>
- * <code>
- * -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1
- * </code>
- *
- * @author Lukasz Moren
- */
-
-public class JGroupsSlaveTest extends SearchTestCase {
-
- public static final String CHANNEL_NAME = "HSearchCluster";
-
- private Channel channel;
-
- public void testMessageSend() throws Exception {
-
- JGroupsReceiver.reset();
-
- Session s = openSession();
- Transaction tx = s.beginTransaction();
- TShirt ts = new TShirt();
- ts.setLogo( "Boston" );
- ts.setSize( "XXL" );
- TShirt ts2 = new TShirt();
- ts2.setLogo( "Mapple leaves" );
- ts2.setSize( "L" );
- s.persist( ts );
- s.persist( ts2 );
- tx.commit();
-
- //need to sleep for the message consumption
- Thread.sleep( 500 );
-
- assertEquals( 1, JGroupsReceiver.queues );
- assertEquals( 2, JGroupsReceiver.works );
-
- JGroupsReceiver.reset();
- s = openSession();
- tx = s.beginTransaction();
- ts = ( TShirt ) s.get( TShirt.class, ts.getId() );
- ts.setLogo( "Peter pan" );
- tx.commit();
-
- //need to sleep for the message consumption
- Thread.sleep( 500 );
-
- assertEquals( 1, JGroupsReceiver.queues );
- assertEquals( 2, JGroupsReceiver.works );
-
- JGroupsReceiver.reset();
- s = openSession();
- tx = s.beginTransaction();
- s.delete( s.get( TShirt.class, ts.getId() ) );
- tx.commit();
-
- //Need to sleep for the message consumption
- Thread.sleep( 500 );
-
- assertEquals( 1, JGroupsReceiver.queues );
- assertEquals( 1, JGroupsReceiver.works );
- s.close();
- }
-
- private void prepareJGroupsChannel() throws Exception {
- channel = new JChannel( XMLHelper.elementFromString( prepareXmlJGroupsConfiguration() ) );
- channel.connect( CHANNEL_NAME );
- channel.setReceiver( new JGroupsReceiver() );
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- prepareJGroupsChannel();
- }
-
- protected void tearDown() throws Exception {
- channel.close();
- super.tearDown();
- }
-
- protected Class[] getMappings() {
- return new Class[] {
- TShirt.class
- };
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( Environment.WORKER_BACKEND, "jgroupsSlave" );
- cfg.setProperty( JGroupsBackendQueueProcessorFactory.CONFIGURATION_XML, prepareXmlJGroupsConfiguration() );
- }
-
- private String prepareXmlJGroupsConfiguration() {
- return "<config>" +
- "<UDP" +
- " mcast_addr=\"${jgroups.udp.mcast_addr:228.10.10.10}\"" +
- " mcast_port=\"${jgroups.udp.mcast_port:45588}\"" +
- " tos=\"8\"" +
- " ucast_recv_buf_size=\"20000000\"" +
- " ucast_send_buf_size=\"640000\"" +
- " mcast_recv_buf_size=\"25000000\"" +
- " mcast_send_buf_size=\"640000\"" +
- " loopback=\"false\"\n" +
- " discard_incompatible_packets=\"true\"" +
- " max_bundle_size=\"64000\"" +
- " max_bundle_timeout=\"30\"" +
- " use_incoming_packet_handler=\"true\"" +
- " ip_ttl=\"${jgroups.udp.ip_ttl:2}\"" +
- " enable_bundling=\"true\"" +
- " enable_diagnostics=\"true\"" +
- " use_concurrent_stack=\"true\"" +
- " thread_naming_pattern=\"pl\"" +
- " thread_pool.enabled=\"true\"" +
- " thread_pool.min_threads=\"1\"" +
- " thread_pool.max_threads=\"25\"" +
- " thread_pool.keep_alive_time=\"5000\"" +
- " thread_pool.queue_enabled=\"false\"" +
- " thread_pool.queue_max_size=\"100\"" +
- " thread_pool.rejection_policy=\"Run\"" +
- " oob_thread_pool.enabled=\"true\"" +
- " oob_thread_pool.min_threads=\"1\"" +
- " oob_thread_pool.max_threads=\"8\"" +
- " oob_thread_pool.keep_alive_time=\"5000\"" +
- " oob_thread_pool.queue_enabled=\"false\"" +
- " oob_thread_pool.queue_max_size=\"100\"" +
- " oob_thread_pool.rejection_policy=\"Run\"/>" +
- "<PING timeout=\"2000\" num_initial_members=\"3\"/>" +
- "<MERGE2 max_interval=\"30000\" min_interval=\"10000\"/>" +
- "<FD_SOCK/>" +
- "<FD timeout=\"10000\" max_tries=\"5\" shun=\"true\"/>" +
- "<VERIFY_SUSPECT timeout=\"1500\"/>" +
- "<pbcast.NAKACK " +
- " use_mcast_xmit=\"false\" gc_lag=\"0\"" +
- " retransmit_timeout=\"300,600,1200,2400,4800\"" +
- " discard_delivered_msgs=\"false\"/>" +
- "<UNICAST timeout=\"300,600,1200,2400,3600\"/>" +
- "<pbcast.STABLE stability_delay=\"1000\" desired_avg_gossip=\"50000\"" +
- " max_bytes=\"400000\"/> " +
- "<pbcast.GMS print_local_addr=\"true\" join_timeout=\"3000\"" +
- " shun=\"false\"" +
- " view_bundling=\"true\"/>" +
- "<FC max_credits=\"20000000\" min_threshold=\"0.10\"/>" +
- "<FRAG2 frag_size=\"60000\"/>" +
- "<pbcast.STREAMING_STATE_TRANSFER />" +
- "<pbcast.FLUSH timeout=\"0\"/>" +
- "</config>";
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.jgroups.slave;
+
+import org.jgroups.Channel;
+import org.jgroups.JChannel;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.search.Environment;
+import org.hibernate.search.backend.impl.jgroups.JGroupsBackendQueueProcessorFactory;
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.util.XMLHelper;
+
+/**
+ * Tests that the Slave node in a JGroups cluster can properly send messages to the channel.
+ * <p/>
+ * In case of running test outside Hibernate Search Maven configuration set following VM configuration:
+ * <br><br>
+ * <code>
+ * -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1
+ * </code>
+ *
+ * @author Lukasz Moren
+ */
+
+public class JGroupsSlaveTest extends SearchTestCase {
+
+ public static final String CHANNEL_NAME = "HSearchCluster";
+
+ private Channel channel;
+
+ public void testMessageSend() throws Exception {
+
+ JGroupsReceiver.reset();
+
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ TShirt ts = new TShirt();
+ ts.setLogo( "Boston" );
+ ts.setSize( "XXL" );
+ TShirt ts2 = new TShirt();
+ ts2.setLogo( "Mapple leaves" );
+ ts2.setSize( "L" );
+ s.persist( ts );
+ s.persist( ts2 );
+ tx.commit();
+
+ //need to sleep for the message consumption
+ Thread.sleep( 500 );
+
+ assertEquals( 1, JGroupsReceiver.queues );
+ assertEquals( 2, JGroupsReceiver.works );
+
+ JGroupsReceiver.reset();
+ s = openSession();
+ tx = s.beginTransaction();
+ ts = ( TShirt ) s.get( TShirt.class, ts.getId() );
+ ts.setLogo( "Peter pan" );
+ tx.commit();
+
+ //need to sleep for the message consumption
+ Thread.sleep( 500 );
+
+ assertEquals( 1, JGroupsReceiver.queues );
+ assertEquals( 2, JGroupsReceiver.works );
+
+ JGroupsReceiver.reset();
+ s = openSession();
+ tx = s.beginTransaction();
+ s.delete( s.get( TShirt.class, ts.getId() ) );
+ tx.commit();
+
+ //Need to sleep for the message consumption
+ Thread.sleep( 500 );
+
+ assertEquals( 1, JGroupsReceiver.queues );
+ assertEquals( 1, JGroupsReceiver.works );
+ s.close();
+ }
+
+ private void prepareJGroupsChannel() throws Exception {
+ channel = new JChannel( XMLHelper.elementFromString( prepareXmlJGroupsConfiguration() ) );
+ channel.connect( CHANNEL_NAME );
+ channel.setReceiver( new JGroupsReceiver() );
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ prepareJGroupsChannel();
+ }
+
+ protected void tearDown() throws Exception {
+ channel.close();
+ super.tearDown();
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ TShirt.class
+ };
+ }
+
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.WORKER_BACKEND, "jgroupsSlave" );
+ cfg.setProperty( JGroupsBackendQueueProcessorFactory.CONFIGURATION_XML, prepareXmlJGroupsConfiguration() );
+ }
+
+ private String prepareXmlJGroupsConfiguration() {
+ return "<config>" +
+ "<UDP" +
+ " mcast_addr=\"${jgroups.udp.mcast_addr:228.10.10.10}\"" +
+ " mcast_port=\"${jgroups.udp.mcast_port:45588}\"" +
+ " tos=\"8\"" +
+ " ucast_recv_buf_size=\"20000000\"" +
+ " ucast_send_buf_size=\"640000\"" +
+ " mcast_recv_buf_size=\"25000000\"" +
+ " mcast_send_buf_size=\"640000\"" +
+ " loopback=\"false\"\n" +
+ " discard_incompatible_packets=\"true\"" +
+ " max_bundle_size=\"64000\"" +
+ " max_bundle_timeout=\"30\"" +
+ " use_incoming_packet_handler=\"true\"" +
+ " ip_ttl=\"${jgroups.udp.ip_ttl:2}\"" +
+ " enable_bundling=\"true\"" +
+ " enable_diagnostics=\"true\"" +
+ " use_concurrent_stack=\"true\"" +
+ " thread_naming_pattern=\"pl\"" +
+ " thread_pool.enabled=\"true\"" +
+ " thread_pool.min_threads=\"1\"" +
+ " thread_pool.max_threads=\"25\"" +
+ " thread_pool.keep_alive_time=\"5000\"" +
+ " thread_pool.queue_enabled=\"false\"" +
+ " thread_pool.queue_max_size=\"100\"" +
+ " thread_pool.rejection_policy=\"Run\"" +
+ " oob_thread_pool.enabled=\"true\"" +
+ " oob_thread_pool.min_threads=\"1\"" +
+ " oob_thread_pool.max_threads=\"8\"" +
+ " oob_thread_pool.keep_alive_time=\"5000\"" +
+ " oob_thread_pool.queue_enabled=\"false\"" +
+ " oob_thread_pool.queue_max_size=\"100\"" +
+ " oob_thread_pool.rejection_policy=\"Run\"/>" +
+ "<PING timeout=\"2000\" num_initial_members=\"3\"/>" +
+ "<MERGE2 max_interval=\"30000\" min_interval=\"10000\"/>" +
+ "<FD_SOCK/>" +
+ "<FD timeout=\"10000\" max_tries=\"5\" shun=\"true\"/>" +
+ "<VERIFY_SUSPECT timeout=\"1500\"/>" +
+ "<pbcast.NAKACK " +
+ " use_mcast_xmit=\"false\" gc_lag=\"0\"" +
+ " retransmit_timeout=\"300,600,1200,2400,4800\"" +
+ " discard_delivered_msgs=\"false\"/>" +
+ "<UNICAST timeout=\"300,600,1200,2400,3600\"/>" +
+ "<pbcast.STABLE stability_delay=\"1000\" desired_avg_gossip=\"50000\"" +
+ " max_bytes=\"400000\"/> " +
+ "<pbcast.GMS print_local_addr=\"true\" join_timeout=\"3000\"" +
+ " shun=\"false\"" +
+ " view_bundling=\"true\"/>" +
+ "<FC max_credits=\"20000000\" min_threshold=\"0.10\"/>" +
+ "<FRAG2 frag_size=\"60000\"/>" +
+ "<pbcast.STREAMING_STATE_TRANSFER />" +
+ "<pbcast.FLUSH timeout=\"0\"/>" +
+ "</config>";
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/jgroups/slave/TShirt.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jgroups/slave/TShirt.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jgroups/slave/TShirt.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,50 +1,73 @@
-// $Id$
-package org.hibernate.search.test.jgroups.slave;
-
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Indexed;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-@Indexed
-public class TShirt {
- @Id
- @GeneratedValue
- @DocumentId
- private int id;
- @Field(index= Index.TOKENIZED)
- private String logo;
- private String size;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getLogo() {
- return logo;
- }
-
- public void setLogo(String logo) {
- this.logo = logo;
- }
-
- public String getSize() {
- return size;
- }
-
- public void setSize(String size) {
- this.size = size;
- }
-}
\ No newline at end of file
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.jgroups.slave;
+
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed
+public class TShirt {
+ @Id
+ @GeneratedValue
+ @DocumentId
+ private int id;
+ @Field(index= Index.TOKENIZED)
+ private String logo;
+ private String size;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getLogo() {
+ return logo;
+ }
+
+ public void setLogo(String logo) {
+ this.logo = logo;
+ }
+
+ public String getSize() {
+ return size;
+ }
+
+ public void setSize(String size) {
+ this.size = size;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/jms/master/JMSMasterTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jms/master/JMSMasterTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jms/master/JMSMasterTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.jms.master;
import java.io.Serializable;
Modified: search/trunk/src/test/java/org/hibernate/search/test/jms/master/MDBSearchController.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jms/master/MDBSearchController.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jms/master/MDBSearchController.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.jms.master;
import org.hibernate.search.backend.impl.jms.AbstractJMSHibernateSearchController;
Modified: search/trunk/src/test/java/org/hibernate/search/test/jms/master/TShirt.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jms/master/TShirt.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jms/master/TShirt.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.jms.master;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/jms/slave/JMSSlaveTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jms/slave/JMSSlaveTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jms/slave/JMSSlaveTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.jms.slave;
import javax.jms.MessageConsumer;
Modified: search/trunk/src/test/java/org/hibernate/search/test/jms/slave/SearchQueueChecker.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jms/slave/SearchQueueChecker.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jms/slave/SearchQueueChecker.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.jms.slave;
import java.util.List;
Modified: search/trunk/src/test/java/org/hibernate/search/test/jms/slave/TShirt.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jms/slave/TShirt.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jms/slave/TShirt.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.jms.slave;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/jpa/Bretzel.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jpa/Bretzel.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jpa/Bretzel.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.jpa;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/jpa/EntityManagerSerializationTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jpa/EntityManagerSerializationTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jpa/EntityManagerSerializationTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.jpa;
import java.io.File;
Modified: search/trunk/src/test/java/org/hibernate/search/test/jpa/EntityManagerTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jpa/EntityManagerTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jpa/EntityManagerTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.jpa;
import org.hibernate.search.jpa.Search;
Modified: search/trunk/src/test/java/org/hibernate/search/test/jpa/JPATestCase.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/jpa/JPATestCase.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/jpa/JPATestCase.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.jpa;
import java.util.Map;
Modified: search/trunk/src/test/java/org/hibernate/search/test/optimizer/Construction.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/optimizer/Construction.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/optimizer/Construction.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.optimizer;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.optimizer;
/**
Modified: search/trunk/src/test/java/org/hibernate/search/test/optimizer/OptimizerTestCase.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/optimizer/OptimizerTestCase.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/optimizer/OptimizerTestCase.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.optimizer;
import java.io.File;
Modified: search/trunk/src/test/java/org/hibernate/search/test/optimizer/Worker.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/optimizer/Worker.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/optimizer/Worker.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.optimizer;
import javax.persistence.Id;
Modified: search/trunk/src/test/java/org/hibernate/search/test/perf/Boat.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/perf/Boat.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/perf/Boat.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.perf;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/perf/IndexTestDontRun.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/perf/IndexTestDontRun.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/perf/IndexTestDontRun.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.perf;
import java.io.IOException;
Modified: search/trunk/src/test/java/org/hibernate/search/test/perf/SearcherThread.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/perf/SearcherThread.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/perf/SearcherThread.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.perf;
import java.io.IOException;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/AlternateBook.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/AlternateBook.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/AlternateBook.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,47 +1,70 @@
-//$Id$
-package org.hibernate.search.test.query;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-@Indexed(index="Book")
-public class AlternateBook {
- @Id @DocumentId
- private Integer id;
- @Field(index = Index.TOKENIZED)
- private String summary;
-
-
- public AlternateBook() {
- }
-
- public AlternateBook(Integer id, String summary) {
- this.id = id;
- this.summary = summary;
- }
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getSummary() {
- return summary;
- }
-
- public void setSummary(String summary) {
- this.summary = summary;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.query;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed(index="Book")
+public class AlternateBook {
+ @Id @DocumentId
+ private Integer id;
+ @Field(index = Index.TOKENIZED)
+ private String summary;
+
+
+ public AlternateBook() {
+ }
+
+ public AlternateBook(Integer id, String summary) {
+ this.id = id;
+ this.summary = summary;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getSummary() {
+ return summary;
+ }
+
+ public void setSummary(String summary) {
+ this.summary = summary;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/Author.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/Author.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/Author.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/Book.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/Book.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/Book.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,103 +1,126 @@
-//$Id$
-package org.hibernate.search.test.query;
-
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.ManyToMany;
-import javax.persistence.ManyToOne;
-
-import org.hibernate.search.annotations.DateBridge;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Fields;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.IndexedEmbedded;
-import org.hibernate.search.annotations.Resolution;
-import org.hibernate.search.annotations.Store;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-@Indexed(index = "Book" )
-public class Book {
-
- private Integer id;
- private String body;
- private String summary;
- private Set<Author> authors = new HashSet<Author>();
- private Author mainAuthor;
- private Date publicationDate;
-
- @IndexedEmbedded
- @ManyToOne
- public Author getMainAuthor() {
- return mainAuthor;
- }
-
- public void setMainAuthor(Author mainAuthor) {
- this.mainAuthor = mainAuthor;
- }
-
- @ManyToMany
- public Set<Author> getAuthors() {
- return authors;
- }
-
- public void setAuthors(Set<Author> authors) {
- this.authors = authors;
- }
-
- public Book() {
- }
-
- public Book(Integer id, String summary, String body) {
- this.id = id;
- this.summary = summary;
- this.body = body;
- }
-
- @Field(index=Index.TOKENIZED, store=Store.NO)
- public String getBody() {
- return body;
- }
-
- public void setBody(String body) {
- this.body = body;
- }
-
- @Id @DocumentId
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- @Fields( {
- @Field(index = Index.TOKENIZED, store = Store.YES),
- @Field(name = "summary_forSort", index = Index.UN_TOKENIZED, store = Store.YES)
- } )
- public String getSummary() {
- return summary;
- }
-
- public void setSummary(String summary) {
- this.summary = summary;
- }
-
- @Field(index=Index.UN_TOKENIZED, store=Store.YES)
- @DateBridge(resolution=Resolution.SECOND)
- public Date getPublicationDate() {
- return publicationDate;
- }
-
- public void setPublicationDate(Date publicationDate) {
- this.publicationDate = publicationDate;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.query;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+
+import org.hibernate.search.annotations.DateBridge;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Fields;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.search.annotations.Resolution;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed(index = "Book" )
+public class Book {
+
+ private Integer id;
+ private String body;
+ private String summary;
+ private Set<Author> authors = new HashSet<Author>();
+ private Author mainAuthor;
+ private Date publicationDate;
+
+ @IndexedEmbedded
+ @ManyToOne
+ public Author getMainAuthor() {
+ return mainAuthor;
+ }
+
+ public void setMainAuthor(Author mainAuthor) {
+ this.mainAuthor = mainAuthor;
+ }
+
+ @ManyToMany
+ public Set<Author> getAuthors() {
+ return authors;
+ }
+
+ public void setAuthors(Set<Author> authors) {
+ this.authors = authors;
+ }
+
+ public Book() {
+ }
+
+ public Book(Integer id, String summary, String body) {
+ this.id = id;
+ this.summary = summary;
+ this.body = body;
+ }
+
+ @Field(index=Index.TOKENIZED, store=Store.NO)
+ public String getBody() {
+ return body;
+ }
+
+ public void setBody(String body) {
+ this.body = body;
+ }
+
+ @Id @DocumentId
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @Fields( {
+ @Field(index = Index.TOKENIZED, store = Store.YES),
+ @Field(name = "summary_forSort", index = Index.UN_TOKENIZED, store = Store.YES)
+ } )
+ public String getSummary() {
+ return summary;
+ }
+
+ public void setSummary(String summary) {
+ this.summary = summary;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ @DateBridge(resolution=Resolution.SECOND)
+ public Date getPublicationDate() {
+ return publicationDate;
+ }
+
+ public void setPublicationDate(Date publicationDate) {
+ this.publicationDate = publicationDate;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/Clock.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/Clock.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/Clock.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,47 +1,70 @@
-//$Id$
-package org.hibernate.search.test.query;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.Store;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-@Indexed
-public class Clock {
- private Integer id;
- private String brand;
-
- public Clock() {
- }
-
- public Clock(Integer id, String brand) {
- this.id = id;
- this.brand = brand;
- }
-
- @Field(index= Index.TOKENIZED, store= Store.YES)
- public String getBrand() {
- return brand;
- }
-
- public void setBrand(String brand) {
- this.brand = brand;
- }
-
- @Id @DocumentId
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.query;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed
+public class Clock {
+ private Integer id;
+ private String brand;
+
+ public Clock() {
+ }
+
+ public Clock(Integer id, String brand) {
+ this.id = id;
+ this.brand = brand;
+ }
+
+ @Field(index= Index.TOKENIZED, store= Store.YES)
+ public String getBrand() {
+ return brand;
+ }
+
+ public void setBrand(String brand) {
+ this.brand = brand;
+ }
+
+ @Id @DocumentId
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/ElectricalProperties.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/ElectricalProperties.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/ElectricalProperties.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/Employee.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/Employee.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/Employee.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query;
import java.util.Date;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/LuceneQuerySortTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/LuceneQuerySortTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/LuceneQuerySortTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query;
import java.util.List;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/LuceneQueryTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/LuceneQueryTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/LuceneQueryTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,662 +1,685 @@
-//$Id$
-package org.hibernate.search.test.query;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.lucene.analysis.StopAnalyzer;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Query;
-import org.hibernate.FetchMode;
-import org.hibernate.Hibernate;
-import org.hibernate.ScrollableResults;
-import org.hibernate.Transaction;
-import org.hibernate.search.FullTextQuery;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.test.SearchTestCase;
-import org.hibernate.stat.Statistics;
-
-
-/**
- * @author Emmanuel Bernard
- * @author John Griffin
- */
-public class LuceneQueryTest extends SearchTestCase {
-
- public void testList() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
- Clock clock = new Clock( 1, "Seiko" );
- s.save( clock );
- clock = new Clock( 2, "Festina" );
- s.save( clock );
- Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
- s.save( book );
- book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
- s.save( book );
- tx.commit();
- s.clear();
- tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
-
- Query query = parser.parse( "summary:noword" );
- org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- List result = hibQuery.list();
- assertNotNull( result );
- assertEquals( 0, result.size() );
-
- query = parser.parse( "summary:Festina Or brand:Seiko" );
- hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "Query with explicit class filter", 2, result.size() );
-
- query = parser.parse( "summary:Festina Or brand:Seiko" );
- hibQuery = s.createFullTextQuery( query, Clock.class );
- result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "Query with one class filter", 1, result.size() );
-
- query = parser.parse( "summary:Festina Or brand:Seiko" );
- hibQuery = s.createFullTextQuery( query );
- result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "Query with no class filter", 2, result.size() );
- for (Object element : result) {
- assertTrue( Hibernate.isInitialized( element ) );
- s.delete( element );
- }
- s.flush();
- query = parser.parse( "summary:Festina Or brand:Seiko" );
- hibQuery = s.createFullTextQuery( query );
- result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "Query with delete objects", 0, result.size() );
-
- for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testResultSize() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
- Clock clock = new Clock( 1, "Seiko" );
- s.save( clock );
- clock = new Clock( 2, "Festina" );
- s.save( clock );
- Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
- s.save( book );
- book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
- s.save( book );
- tx.commit();
- s.clear();
- tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
-
- Query query = parser.parse( "summary:Festina Or brand:Seiko" );
- Statistics stats = s.getSessionFactory().getStatistics();
- stats.clear();
- boolean enabled = stats.isStatisticsEnabled();
- if ( !enabled ) stats.setStatisticsEnabled( true );
- FullTextQuery hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- assertEquals( "Exection of getResultSize without actual results", 2, hibQuery.getResultSize() );
- assertEquals( "No entity should be loaded", 0, stats.getEntityLoadCount() );
-
- query = parser.parse( "summary:Festina Or brand:Seiko" );
- hibQuery = s.createFullTextQuery( query );
- List result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "2 entities should be loaded", 2, stats.getEntityLoadCount() );
- if ( !enabled ) stats.setStatisticsEnabled( false );
- for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testFirstMax() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
- Clock clock = new Clock( 1, "Seiko" );
- s.save( clock );
- clock = new Clock( 2, "Festina" );
- s.save( clock );
- Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
- s.save( book );
- book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
- s.save( book );
- tx.commit();
- s.clear();
- tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
-
- Query query = parser.parse( "summary:Festina Or brand:Seiko" );
- org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- hibQuery.setFirstResult( 1 );
- List result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "first result no max result", 1, result.size() );
-
- hibQuery.setFirstResult( 0 );
- hibQuery.setMaxResults( 1 );
- result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "max result set", 1, result.size() );
-
- hibQuery.setFirstResult( 0 );
- hibQuery.setMaxResults( 3 );
- result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "max result out of limit", 2, result.size() );
-
- hibQuery.setFirstResult( 2 );
- hibQuery.setMaxResults( 3 );
- result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "first result out of limit", 0, result.size() );
-
- for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testIterator() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
- Clock clock = new Clock( 1, "Seiko" );
- s.save( clock );
- clock = new Clock( 2, "Festina" );
- s.save( clock );
- Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
- s.save( book );
- book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
- s.save( book );
- tx.commit();//post commit events for lucene
- s.clear();
- tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
-
- Query query = parser.parse( "summary:noword" );
- org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- Iterator result = hibQuery.iterate();
- assertNotNull( result );
- assertFalse( result.hasNext() );
-
- query = parser.parse( "summary:Festina Or brand:Seiko" );
- hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- result = hibQuery.iterate();
- assertNotNull( result );
- int index = 0;
- while ( result.hasNext() ) {
- index++;
- s.delete( result.next() );
- }
- assertEquals( 2, index );
-
- s.flush();
-
- query = parser.parse( "summary:Festina Or brand:Seiko" );
- hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- result = hibQuery.iterate();
- assertNotNull( result );
- assertFalse( result.hasNext() );
-
- for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testScrollableResultSet() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
- Clock clock = new Clock( 1, "Seiko" );
- s.save( clock );
- clock = new Clock( 2, "Festina" );
- s.save( clock );
- Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
- s.save( book );
- book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
- s.save( book );
- tx.commit();//post commit events for lucene
- s.clear();
- tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
-
- Query query = parser.parse( "summary:noword" );
- org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- ScrollableResults result = hibQuery.scroll();
- assertNotNull( result );
- assertEquals( -1, result.getRowNumber() );
- assertEquals( false, result.next() );
- result.close();
-
- query = parser.parse( "summary:Festina Or brand:Seiko" );
- hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- result = hibQuery.scroll();
- assertEquals( -1, result.getRowNumber() );
- result.beforeFirst();
- assertEquals( true, result.next() );
- assertTrue( result.isFirst() );
- assertTrue( result.scroll( 1 ) );
- assertTrue( result.isLast() );
- assertFalse( result.scroll( 1 ) );
- result.beforeFirst();
- while ( result.next() ) {
- s.delete( result.get()[0] );
- }
- for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- // Technically this is checked by other tests but let's do it anyway. J.G.
- public void testDefaultFetchSize() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- prepEmployeeIndex( s );
-
- s.clear();
- Transaction tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
-
- Query query = parser.parse( "dept:ITech" );
- org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
- hibQuery.setProjection( "id", "lastname", "dept" );
-
- ScrollableResults projections = hibQuery.scroll();
- projections.beforeFirst();
- Object[] projection = projections.get();
- assertNull( projection );
-
- projections.next();
- assertTrue( projections.isFirst() );
-
- //cleanup
- for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testFetchSizeLargerThanHits() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- prepEmployeeIndex( s );
-
- s.clear();
- Transaction tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
-
- Query query = parser.parse( "dept:ITech" );
- org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
- hibQuery.setProjection( "id", "lastname", "dept" );
- hibQuery.setFetchSize( 6 );
-
- ScrollableResults results = hibQuery.scroll();
- results.beforeFirst();
- results.next();
- Object[] result = results.get();
- assertEquals( "incorrect entityInfo returned", 1000, result[0] );
-
- //cleanup
- for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testFetchSizeDefaultFirstAndMax() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- prepEmployeeIndex( s );
-
- s.clear();
- Transaction tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
-
- Query query = parser.parse( "dept:ITech" );
- org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
- hibQuery.setProjection( "id", "lastname", "dept" );
- hibQuery.setFetchSize( 3 );
-
- ScrollableResults results = hibQuery.scroll();
- results.beforeFirst();
- results.next();
- Object[] result = results.get();
- assertEquals( "incorrect entityInfo returned", 1000, result[0] );
- results.scroll( 2 );
- result = results.get();
- assertEquals( "incorrect entityInfo returned", 1003, result[0] );
- // check cache addition
- results.next();
- result = results.get();
- assertEquals( "incorrect entityInfo returned", 1004, result[0] );
-
- results.scroll( -2 );
- result = results.get();
- assertEquals( "incorrect entityInfo returned", 1002, result[0] );
-
- //cleanup
- for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testFetchSizeNonDefaultFirstAndMax() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- prepEmployeeIndex( s );
-
- s.clear();
- Transaction tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
-
- Query query = parser.parse( "dept:ITech" );
- org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
- hibQuery.setProjection( "id", "lastname", "dept" );
- hibQuery.setFetchSize( 3 );
- hibQuery.setFirstResult( 1 );
- hibQuery.setMaxResults( 3 );
-
- ScrollableResults results = hibQuery.scroll();
- results.beforeFirst();
- results.next();
- Object[] result = results.get();
- assertEquals( "incorrect entityInfo returned", 1002, result[0] );
-
- results.scroll( 2 );
- result = results.get();
- assertEquals( "incorrect entityInfo returned", 1004, result[0] );
-
- results.next();
- result = results.get();
- assertNull( result );
-
- results.scroll( -8 );
- result = results.get();
- assertNull( result );
-
- // And test a bad forward scroll.
- results.scroll( 10 );
- result = results.get();
- assertNull( result );
-
- //cleanup
- for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testFetchSizeNonDefaultFirstAndMaxNoHits() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- prepEmployeeIndex( s );
-
- s.clear();
- Transaction tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
-
- Query query = parser.parse( "dept:XXX" );
- org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
- hibQuery.setProjection( "id", "lastname", "dept" );
- hibQuery.setFetchSize( 3 );
- hibQuery.setFirstResult( 1 );
- hibQuery.setMaxResults( 3 );
-
- ScrollableResults results = hibQuery.scroll();
- results.beforeFirst();
- Object[] result = results.get();
- assertNull( "non-null entity infos returned", result );
-
- //cleanup
- for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testCurrent() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- prepEmployeeIndex( s );
-
- s.clear();
- Transaction tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
-
- Query query = parser.parse( "dept:ITech" );
- org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
- hibQuery.setProjection( "id", "lastname", "dept" );
-
-
-
- ScrollableResults results = hibQuery.scroll();
- results.beforeFirst();
- results.next();
- assertTrue("beforeFirst() pointer incorrect", results.isFirst());
-
- results.afterLast();
- results.previous();
- assertTrue("afterLast() pointer incorrect", results.isLast());
-
- // Let's see if a bad reverse scroll screws things up
- results.scroll( -8 );
- results.next();
- assertTrue("large negative scroll() pointer incorrect", results.isFirst());
-
- // And test a bad forward scroll.
- results.scroll( 10 );
- results.previous();
- assertTrue("large positive scroll() pointer incorrect", results.isLast());
-
- // Finally, let's test a REAL screwup.
- hibQuery.setFirstResult( 3 );
- hibQuery.setMaxResults( 1 );
-
- results = hibQuery.scroll();
- results.first();
- Object[] result = results.get();
- assertEquals(1004, result[0]);
-
- results.last();
- result = results.get();
- assertEquals(1004, result[0]);
-
- //cleanup
- for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testMultipleEntityPerIndex() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
- Clock clock = new Clock( 1, "Seiko" );
- s.save( clock );
- Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
- s.save( book );
- AlternateBook alternateBook = new AlternateBook( 1, "La chute de la petite reine a travers les yeux de Festina" );
- s.save( alternateBook );
- tx.commit();
- s.clear();
- tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
-
- Query query = parser.parse( "summary:Festina" );
- org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- List result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "Query with explicit class filter", 1, result.size() );
-
- query = parser.parse( "summary:Festina" );
- hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- Iterator it = hibQuery.iterate();
- assertTrue( it.hasNext() );
- assertNotNull( it.next() );
- assertFalse( it.hasNext() );
-
- query = parser.parse( "summary:Festina" );
- hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- ScrollableResults sr = hibQuery.scroll();
- assertTrue( sr.first() );
- assertNotNull( sr.get() );
- assertFalse( sr.next() );
- sr.close();
-
- query = parser.parse( "summary:Festina OR brand:seiko" );
- hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
- hibQuery.setMaxResults( 2 );
- result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "Query with explicit class filter and limit", 2, result.size() );
-
- query = parser.parse( "summary:Festina" );
- hibQuery = s.createFullTextQuery( query );
- result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "Query with no class filter", 2, result.size() );
- for (Object element : result) {
- assertTrue( Hibernate.isInitialized( element ) );
- s.delete( element );
- }
- for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testCriteria() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
- Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
- s.save( book );
- Author emmanuel = new Author();
- emmanuel.setName( "Emmanuel" );
- s.save( emmanuel );
- book.getAuthors().add( emmanuel );
- tx.commit();
- s.clear();
- tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
-
- Query query = parser.parse( "summary:Festina" );
- org.hibernate.Query hibQuery = s.createFullTextQuery( query, Book.class );
- List result = hibQuery.list();
- assertNotNull( result );
- assertEquals( "Query with no explicit criteria", 1, result.size() );
- book = (Book) result.get( 0 );
- assertFalse( "Association should not be inintialized", Hibernate.isInitialized( book.getAuthors() ) );
-
- result = s.createFullTextQuery( query ).setCriteriaQuery(
- s.createCriteria( Book.class ).setFetchMode( "authors", FetchMode.JOIN ) ).list();
- assertNotNull( result );
- assertEquals( "Query with explicit criteria", 1, result.size() );
- book = (Book) result.get( 0 );
- assertTrue( "Association should be inintialized", Hibernate.isInitialized( book.getAuthors() ) );
- assertEquals( 1, book.getAuthors().size() );
-
- //cleanup
- Author author = book.getAuthors().iterator().next();
- book.getAuthors().remove( author );
-
- for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testScrollEmptyHits() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- prepEmployeeIndex( s );
-
- s.clear();
- Transaction tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
-
- Query query = parser.parse( "dept:XXX" );
- org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
-
- ScrollableResults projections = hibQuery.scroll();
- projections.beforeFirst();
- projections.next();
- Object[] projection = projections.get();
- assertNull( projection );
-
- hibQuery = s.createFullTextQuery( query, Employee.class ).setFirstResult( 10 ).setMaxResults( 20 );
-
- projections = hibQuery.scroll();
- projections.beforeFirst();
- projections.next();
- projection = projections.get();
- assertNull( projection );
-
- //cleanup
- for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testListEmptyHits() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- prepEmployeeIndex( s );
-
- s.clear();
- Transaction tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
-
- Query query = parser.parse( "dept:XXX" );
- org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
- List result = hibQuery.list();
- assertEquals( 0, result.size() );
-
- hibQuery = s.createFullTextQuery( query, Employee.class ).setFirstResult( 10 ).setMaxResults( 20 );
- result = hibQuery.list();
- assertEquals( 0, result.size() );
-
- //cleanup
- for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- public void testIterateEmptyHits() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- prepEmployeeIndex( s );
-
- s.clear();
- Transaction tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
-
- Query query = parser.parse( "dept:XXX" );
- org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
- Iterator iter = hibQuery.iterate();
- assertFalse( iter.hasNext() );
-
- hibQuery = s.createFullTextQuery( query, Employee.class ).setFirstResult( 10 ).setMaxResults( 20 );
- iter = hibQuery.iterate();
- assertFalse( iter.hasNext() );
-
- //cleanup
- for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
- tx.commit();
- s.close();
- }
-
- private void prepEmployeeIndex(FullTextSession s) {
- Transaction tx = s.beginTransaction();
- Employee e1 = new Employee( 1000, "Griffin", "ITech" );
- s.save( e1 );
- Employee e2 = new Employee( 1001, "Jackson", "Accounting" );
- s.save( e2 );
- Employee e3 = new Employee( 1002, "Jimenez", "ITech" );
- s.save( e3 );
- Employee e4 = new Employee( 1003, "Stejskal", "ITech" );
- s.save( e4 );
- Employee e5 = new Employee( 1004, "Whetbrook", "ITech" );
- s.save( e5 );
-
- tx.commit();
- }
-
-
- protected Class[] getMappings() {
- return new Class[] {
- Book.class,
- AlternateBook.class,
- Clock.class,
- Author.class,
- Employee.class
- };
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.query;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.hibernate.FetchMode;
+import org.hibernate.Hibernate;
+import org.hibernate.ScrollableResults;
+import org.hibernate.Transaction;
+import org.hibernate.search.FullTextQuery;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.stat.Statistics;
+
+
+/**
+ * @author Emmanuel Bernard
+ * @author John Griffin
+ */
+public class LuceneQueryTest extends SearchTestCase {
+
+ public void testList() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ Clock clock = new Clock( 1, "Seiko" );
+ s.save( clock );
+ clock = new Clock( 2, "Festina" );
+ s.save( clock );
+ Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
+ s.save( book );
+ book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
+ s.save( book );
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
+
+ Query query = parser.parse( "summary:noword" );
+ org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ List result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( 0, result.size() );
+
+ query = parser.parse( "summary:Festina Or brand:Seiko" );
+ hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Query with explicit class filter", 2, result.size() );
+
+ query = parser.parse( "summary:Festina Or brand:Seiko" );
+ hibQuery = s.createFullTextQuery( query, Clock.class );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Query with one class filter", 1, result.size() );
+
+ query = parser.parse( "summary:Festina Or brand:Seiko" );
+ hibQuery = s.createFullTextQuery( query );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Query with no class filter", 2, result.size() );
+ for (Object element : result) {
+ assertTrue( Hibernate.isInitialized( element ) );
+ s.delete( element );
+ }
+ s.flush();
+ query = parser.parse( "summary:Festina Or brand:Seiko" );
+ hibQuery = s.createFullTextQuery( query );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Query with delete objects", 0, result.size() );
+
+ for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testResultSize() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ Clock clock = new Clock( 1, "Seiko" );
+ s.save( clock );
+ clock = new Clock( 2, "Festina" );
+ s.save( clock );
+ Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
+ s.save( book );
+ book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
+ s.save( book );
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
+
+ Query query = parser.parse( "summary:Festina Or brand:Seiko" );
+ Statistics stats = s.getSessionFactory().getStatistics();
+ stats.clear();
+ boolean enabled = stats.isStatisticsEnabled();
+ if ( !enabled ) stats.setStatisticsEnabled( true );
+ FullTextQuery hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ assertEquals( "Exection of getResultSize without actual results", 2, hibQuery.getResultSize() );
+ assertEquals( "No entity should be loaded", 0, stats.getEntityLoadCount() );
+
+ query = parser.parse( "summary:Festina Or brand:Seiko" );
+ hibQuery = s.createFullTextQuery( query );
+ List result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "2 entities should be loaded", 2, stats.getEntityLoadCount() );
+ if ( !enabled ) stats.setStatisticsEnabled( false );
+ for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testFirstMax() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ Clock clock = new Clock( 1, "Seiko" );
+ s.save( clock );
+ clock = new Clock( 2, "Festina" );
+ s.save( clock );
+ Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
+ s.save( book );
+ book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
+ s.save( book );
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
+
+ Query query = parser.parse( "summary:Festina Or brand:Seiko" );
+ org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ hibQuery.setFirstResult( 1 );
+ List result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "first result no max result", 1, result.size() );
+
+ hibQuery.setFirstResult( 0 );
+ hibQuery.setMaxResults( 1 );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "max result set", 1, result.size() );
+
+ hibQuery.setFirstResult( 0 );
+ hibQuery.setMaxResults( 3 );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "max result out of limit", 2, result.size() );
+
+ hibQuery.setFirstResult( 2 );
+ hibQuery.setMaxResults( 3 );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "first result out of limit", 0, result.size() );
+
+ for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testIterator() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ Clock clock = new Clock( 1, "Seiko" );
+ s.save( clock );
+ clock = new Clock( 2, "Festina" );
+ s.save( clock );
+ Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
+ s.save( book );
+ book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
+ s.save( book );
+ tx.commit();//post commit events for lucene
+ s.clear();
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
+
+ Query query = parser.parse( "summary:noword" );
+ org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ Iterator result = hibQuery.iterate();
+ assertNotNull( result );
+ assertFalse( result.hasNext() );
+
+ query = parser.parse( "summary:Festina Or brand:Seiko" );
+ hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ result = hibQuery.iterate();
+ assertNotNull( result );
+ int index = 0;
+ while ( result.hasNext() ) {
+ index++;
+ s.delete( result.next() );
+ }
+ assertEquals( 2, index );
+
+ s.flush();
+
+ query = parser.parse( "summary:Festina Or brand:Seiko" );
+ hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ result = hibQuery.iterate();
+ assertNotNull( result );
+ assertFalse( result.hasNext() );
+
+ for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testScrollableResultSet() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ Clock clock = new Clock( 1, "Seiko" );
+ s.save( clock );
+ clock = new Clock( 2, "Festina" );
+ s.save( clock );
+ Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
+ s.save( book );
+ book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
+ s.save( book );
+ tx.commit();//post commit events for lucene
+ s.clear();
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
+
+ Query query = parser.parse( "summary:noword" );
+ org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ ScrollableResults result = hibQuery.scroll();
+ assertNotNull( result );
+ assertEquals( -1, result.getRowNumber() );
+ assertEquals( false, result.next() );
+ result.close();
+
+ query = parser.parse( "summary:Festina Or brand:Seiko" );
+ hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ result = hibQuery.scroll();
+ assertEquals( -1, result.getRowNumber() );
+ result.beforeFirst();
+ assertEquals( true, result.next() );
+ assertTrue( result.isFirst() );
+ assertTrue( result.scroll( 1 ) );
+ assertTrue( result.isLast() );
+ assertFalse( result.scroll( 1 ) );
+ result.beforeFirst();
+ while ( result.next() ) {
+ s.delete( result.get()[0] );
+ }
+ for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ // Technically this is checked by other tests but let's do it anyway. J.G.
+ public void testDefaultFetchSize() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ prepEmployeeIndex( s );
+
+ s.clear();
+ Transaction tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
+
+ Query query = parser.parse( "dept:ITech" );
+ org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
+ hibQuery.setProjection( "id", "lastname", "dept" );
+
+ ScrollableResults projections = hibQuery.scroll();
+ projections.beforeFirst();
+ Object[] projection = projections.get();
+ assertNull( projection );
+
+ projections.next();
+ assertTrue( projections.isFirst() );
+
+ //cleanup
+ for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testFetchSizeLargerThanHits() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ prepEmployeeIndex( s );
+
+ s.clear();
+ Transaction tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
+
+ Query query = parser.parse( "dept:ITech" );
+ org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
+ hibQuery.setProjection( "id", "lastname", "dept" );
+ hibQuery.setFetchSize( 6 );
+
+ ScrollableResults results = hibQuery.scroll();
+ results.beforeFirst();
+ results.next();
+ Object[] result = results.get();
+ assertEquals( "incorrect entityInfo returned", 1000, result[0] );
+
+ //cleanup
+ for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testFetchSizeDefaultFirstAndMax() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ prepEmployeeIndex( s );
+
+ s.clear();
+ Transaction tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
+
+ Query query = parser.parse( "dept:ITech" );
+ org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
+ hibQuery.setProjection( "id", "lastname", "dept" );
+ hibQuery.setFetchSize( 3 );
+
+ ScrollableResults results = hibQuery.scroll();
+ results.beforeFirst();
+ results.next();
+ Object[] result = results.get();
+ assertEquals( "incorrect entityInfo returned", 1000, result[0] );
+ results.scroll( 2 );
+ result = results.get();
+ assertEquals( "incorrect entityInfo returned", 1003, result[0] );
+ // check cache addition
+ results.next();
+ result = results.get();
+ assertEquals( "incorrect entityInfo returned", 1004, result[0] );
+
+ results.scroll( -2 );
+ result = results.get();
+ assertEquals( "incorrect entityInfo returned", 1002, result[0] );
+
+ //cleanup
+ for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testFetchSizeNonDefaultFirstAndMax() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ prepEmployeeIndex( s );
+
+ s.clear();
+ Transaction tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
+
+ Query query = parser.parse( "dept:ITech" );
+ org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
+ hibQuery.setProjection( "id", "lastname", "dept" );
+ hibQuery.setFetchSize( 3 );
+ hibQuery.setFirstResult( 1 );
+ hibQuery.setMaxResults( 3 );
+
+ ScrollableResults results = hibQuery.scroll();
+ results.beforeFirst();
+ results.next();
+ Object[] result = results.get();
+ assertEquals( "incorrect entityInfo returned", 1002, result[0] );
+
+ results.scroll( 2 );
+ result = results.get();
+ assertEquals( "incorrect entityInfo returned", 1004, result[0] );
+
+ results.next();
+ result = results.get();
+ assertNull( result );
+
+ results.scroll( -8 );
+ result = results.get();
+ assertNull( result );
+
+ // And test a bad forward scroll.
+ results.scroll( 10 );
+ result = results.get();
+ assertNull( result );
+
+ //cleanup
+ for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testFetchSizeNonDefaultFirstAndMaxNoHits() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ prepEmployeeIndex( s );
+
+ s.clear();
+ Transaction tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
+
+ Query query = parser.parse( "dept:XXX" );
+ org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
+ hibQuery.setProjection( "id", "lastname", "dept" );
+ hibQuery.setFetchSize( 3 );
+ hibQuery.setFirstResult( 1 );
+ hibQuery.setMaxResults( 3 );
+
+ ScrollableResults results = hibQuery.scroll();
+ results.beforeFirst();
+ Object[] result = results.get();
+ assertNull( "non-null entity infos returned", result );
+
+ //cleanup
+ for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testCurrent() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ prepEmployeeIndex( s );
+
+ s.clear();
+ Transaction tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
+
+ Query query = parser.parse( "dept:ITech" );
+ org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
+ hibQuery.setProjection( "id", "lastname", "dept" );
+
+
+
+ ScrollableResults results = hibQuery.scroll();
+ results.beforeFirst();
+ results.next();
+ assertTrue("beforeFirst() pointer incorrect", results.isFirst());
+
+ results.afterLast();
+ results.previous();
+ assertTrue("afterLast() pointer incorrect", results.isLast());
+
+ // Let's see if a bad reverse scroll screws things up
+ results.scroll( -8 );
+ results.next();
+ assertTrue("large negative scroll() pointer incorrect", results.isFirst());
+
+ // And test a bad forward scroll.
+ results.scroll( 10 );
+ results.previous();
+ assertTrue("large positive scroll() pointer incorrect", results.isLast());
+
+ // Finally, let's test a REAL screwup.
+ hibQuery.setFirstResult( 3 );
+ hibQuery.setMaxResults( 1 );
+
+ results = hibQuery.scroll();
+ results.first();
+ Object[] result = results.get();
+ assertEquals(1004, result[0]);
+
+ results.last();
+ result = results.get();
+ assertEquals(1004, result[0]);
+
+ //cleanup
+ for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testMultipleEntityPerIndex() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ Clock clock = new Clock( 1, "Seiko" );
+ s.save( clock );
+ Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
+ s.save( book );
+ AlternateBook alternateBook = new AlternateBook( 1, "La chute de la petite reine a travers les yeux de Festina" );
+ s.save( alternateBook );
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
+
+ Query query = parser.parse( "summary:Festina" );
+ org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ List result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Query with explicit class filter", 1, result.size() );
+
+ query = parser.parse( "summary:Festina" );
+ hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ Iterator it = hibQuery.iterate();
+ assertTrue( it.hasNext() );
+ assertNotNull( it.next() );
+ assertFalse( it.hasNext() );
+
+ query = parser.parse( "summary:Festina" );
+ hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ ScrollableResults sr = hibQuery.scroll();
+ assertTrue( sr.first() );
+ assertNotNull( sr.get() );
+ assertFalse( sr.next() );
+ sr.close();
+
+ query = parser.parse( "summary:Festina OR brand:seiko" );
+ hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
+ hibQuery.setMaxResults( 2 );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Query with explicit class filter and limit", 2, result.size() );
+
+ query = parser.parse( "summary:Festina" );
+ hibQuery = s.createFullTextQuery( query );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Query with no class filter", 2, result.size() );
+ for (Object element : result) {
+ assertTrue( Hibernate.isInitialized( element ) );
+ s.delete( element );
+ }
+ for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testCriteria() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
+ s.save( book );
+ Author emmanuel = new Author();
+ emmanuel.setName( "Emmanuel" );
+ s.save( emmanuel );
+ book.getAuthors().add( emmanuel );
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
+
+ Query query = parser.parse( "summary:Festina" );
+ org.hibernate.Query hibQuery = s.createFullTextQuery( query, Book.class );
+ List result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Query with no explicit criteria", 1, result.size() );
+ book = (Book) result.get( 0 );
+ assertFalse( "Association should not be inintialized", Hibernate.isInitialized( book.getAuthors() ) );
+
+ result = s.createFullTextQuery( query ).setCriteriaQuery(
+ s.createCriteria( Book.class ).setFetchMode( "authors", FetchMode.JOIN ) ).list();
+ assertNotNull( result );
+ assertEquals( "Query with explicit criteria", 1, result.size() );
+ book = (Book) result.get( 0 );
+ assertTrue( "Association should be inintialized", Hibernate.isInitialized( book.getAuthors() ) );
+ assertEquals( 1, book.getAuthors().size() );
+
+ //cleanup
+ Author author = book.getAuthors().iterator().next();
+ book.getAuthors().remove( author );
+
+ for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testScrollEmptyHits() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ prepEmployeeIndex( s );
+
+ s.clear();
+ Transaction tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
+
+ Query query = parser.parse( "dept:XXX" );
+ org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
+
+ ScrollableResults projections = hibQuery.scroll();
+ projections.beforeFirst();
+ projections.next();
+ Object[] projection = projections.get();
+ assertNull( projection );
+
+ hibQuery = s.createFullTextQuery( query, Employee.class ).setFirstResult( 10 ).setMaxResults( 20 );
+
+ projections = hibQuery.scroll();
+ projections.beforeFirst();
+ projections.next();
+ projection = projections.get();
+ assertNull( projection );
+
+ //cleanup
+ for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testListEmptyHits() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ prepEmployeeIndex( s );
+
+ s.clear();
+ Transaction tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
+
+ Query query = parser.parse( "dept:XXX" );
+ org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
+ List result = hibQuery.list();
+ assertEquals( 0, result.size() );
+
+ hibQuery = s.createFullTextQuery( query, Employee.class ).setFirstResult( 10 ).setMaxResults( 20 );
+ result = hibQuery.list();
+ assertEquals( 0, result.size() );
+
+ //cleanup
+ for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testIterateEmptyHits() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ prepEmployeeIndex( s );
+
+ s.clear();
+ Transaction tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
+
+ Query query = parser.parse( "dept:XXX" );
+ org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
+ Iterator iter = hibQuery.iterate();
+ assertFalse( iter.hasNext() );
+
+ hibQuery = s.createFullTextQuery( query, Employee.class ).setFirstResult( 10 ).setMaxResults( 20 );
+ iter = hibQuery.iterate();
+ assertFalse( iter.hasNext() );
+
+ //cleanup
+ for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ private void prepEmployeeIndex(FullTextSession s) {
+ Transaction tx = s.beginTransaction();
+ Employee e1 = new Employee( 1000, "Griffin", "ITech" );
+ s.save( e1 );
+ Employee e2 = new Employee( 1001, "Jackson", "Accounting" );
+ s.save( e2 );
+ Employee e3 = new Employee( 1002, "Jimenez", "ITech" );
+ s.save( e3 );
+ Employee e4 = new Employee( 1003, "Stejskal", "ITech" );
+ s.save( e4 );
+ Employee e5 = new Employee( 1004, "Whetbrook", "ITech" );
+ s.save( e5 );
+
+ tx.commit();
+ }
+
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Book.class,
+ AlternateBook.class,
+ Clock.class,
+ Author.class,
+ Employee.class
+ };
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/MultiClassesQueryLoaderTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/MultiClassesQueryLoaderTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/MultiClassesQueryLoaderTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query;
import java.sql.Statement;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/Music.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/Music.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/Music.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query;
import java.util.HashSet;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/Person.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/Person.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/Person.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query;
import javax.persistence.Entity;
@@ -29,4 +52,4 @@
public void setName(String name) {
this.name = name;
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/ProjectionQueryTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/ProjectionQueryTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/ProjectionQueryTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query;
import java.io.Serializable;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/ProjectionToDelimStringResultTransformer.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/ProjectionToDelimStringResultTransformer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/ProjectionToDelimStringResultTransformer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,24 +1,47 @@
-// $Id$
-package org.hibernate.search.test.query;
-
-import java.util.List;
-
-import org.hibernate.transform.ResultTransformer;
-
-/**
- * @author John Griffin
- */
-public class ProjectionToDelimStringResultTransformer implements ResultTransformer {
-
- public Object transformTuple(Object[] tuple, String[] aliases) {
- String s = tuple[0].toString();
- for (int i = 1; i < tuple.length; i++) {
- s = s + ", " + tuple[i].toString();
- }
- return s;
- }
-
- public List transformList(List collection) {
- return collection;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.query;
+
+import java.util.List;
+
+import org.hibernate.transform.ResultTransformer;
+
+/**
+ * @author John Griffin
+ */
+public class ProjectionToDelimStringResultTransformer implements ResultTransformer {
+
+ public Object transformTuple(Object[] tuple, String[] aliases) {
+ String s = tuple[0].toString();
+ for (int i = 1; i < tuple.length; i++) {
+ s = s + ", " + tuple[i].toString();
+ }
+ return s;
+ }
+
+ public List transformList(List collection) {
+ return collection;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/ProjectionToMapResultTransformer.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/ProjectionToMapResultTransformer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/ProjectionToMapResultTransformer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query;
import java.util.HashMap;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/QueryLoaderTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/QueryLoaderTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/QueryLoaderTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query;
import java.util.List;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/QueryUnindexedEntityTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/QueryUnindexedEntityTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/QueryUnindexedEntityTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
@@ -50,4 +73,4 @@
Person.class,
};
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/ScrollableResultsTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/ScrollableResultsTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/ScrollableResultsTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query;
import org.apache.lucene.index.Term;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/TermVectorTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/TermVectorTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/TermVectorTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query;
import org.apache.lucene.index.IndexReader;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/boost/BoostedDescriptionLibrary.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/boost/BoostedDescriptionLibrary.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/boost/BoostedDescriptionLibrary.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query.boost;
import javax.persistence.Entity;
@@ -65,4 +88,4 @@
public void setDescription(String description) {
this.description = description;
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/boost/BoostedFieldDescriptionLibrary.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/boost/BoostedFieldDescriptionLibrary.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/boost/BoostedFieldDescriptionLibrary.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query.boost;
import javax.persistence.Entity;
@@ -64,4 +87,4 @@
public void setDescription(String description) {
this.description = description;
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/boost/BoostedGetDescriptionLibrary.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/boost/BoostedGetDescriptionLibrary.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/boost/BoostedGetDescriptionLibrary.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query.boost;
import javax.persistence.Entity;
@@ -65,4 +88,4 @@
public void setDescription(String description) {
this.description = description;
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/boost/CustomBoostStrategy.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/boost/CustomBoostStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/boost/CustomBoostStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query.boost;
import org.hibernate.search.engine.BoostStrategy;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/boost/CustomFieldBoostStrategy.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/boost/CustomFieldBoostStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/boost/CustomFieldBoostStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query.boost;
import org.hibernate.search.engine.BoostStrategy;
@@ -20,4 +43,4 @@
return 1.0f;
}
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/boost/DynamicBoostedDescriptionLibrary.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/boost/DynamicBoostedDescriptionLibrary.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/boost/DynamicBoostedDescriptionLibrary.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query.boost;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/boost/DynamicBoostingTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/boost/DynamicBoostingTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/boost/DynamicBoostingTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query.boost;
import java.util.List;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/boost/FieldBoostTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/boost/FieldBoostTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/boost/FieldBoostTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query.boost;
import java.util.List;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/boost/Library.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/boost/Library.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/boost/Library.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query.boost;
import javax.persistence.Entity;
@@ -59,4 +82,4 @@
public void setDescription(String description) {
Description = description;
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/criteria/AbstractCar.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/criteria/AbstractCar.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/criteria/AbstractCar.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,52 +1,75 @@
-//$Id$
-package org.hibernate.search.test.query.criteria;
-
-import javax.persistence.DiscriminatorColumn;
-import javax.persistence.DiscriminatorType;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
-import javax.persistence.Table;
-
-import org.hibernate.search.annotations.Field;
-
-@Entity
-@Table(name = "Car")
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorColumn(name = "DISC", discriminatorType = DiscriminatorType.STRING, length = 5)
-public abstract class AbstractCar {
-
- @Id
- @GeneratedValue
- private Integer id;
-
- @Field
- private String kurztext;
-
- private boolean hasColor = false;
-
- protected AbstractCar() {
- }
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getKurztext() {
- return kurztext;
- }
-
- public void setKurztext(final String kurztext) {
- this.kurztext = kurztext;
- }
-
- public boolean isHasColor() {
- return hasColor;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.query.criteria;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import org.hibernate.search.annotations.Field;
+
+@Entity
+@Table(name = "Car")
+@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
+@DiscriminatorColumn(name = "DISC", discriminatorType = DiscriminatorType.STRING, length = 5)
+public abstract class AbstractCar {
+
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ @Field
+ private String kurztext;
+
+ private boolean hasColor = false;
+
+ protected AbstractCar() {
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getKurztext() {
+ return kurztext;
+ }
+
+ public void setKurztext(final String kurztext) {
+ this.kurztext = kurztext;
+ }
+
+ public boolean isHasColor() {
+ return hasColor;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/criteria/Bike.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/criteria/Bike.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/criteria/Bike.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query.criteria;
import javax.persistence.Entity;
@@ -41,4 +64,4 @@
public boolean isHasColor() {
return hasColor;
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/criteria/CombiCar.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/criteria/CombiCar.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/criteria/CombiCar.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,13 +1,36 @@
-//$Id$
-package org.hibernate.search.test.query.criteria;
-
-import javax.persistence.DiscriminatorValue;
-import javax.persistence.Entity;
-
-import org.hibernate.search.annotations.Indexed;
-
-@Entity
-@DiscriminatorValue(value = "Combi")
-@Indexed
-public class CombiCar extends AbstractCar {
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.query.criteria;
+
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+
+import org.hibernate.search.annotations.Indexed;
+
+@Entity
+@DiscriminatorValue(value = "Combi")
+@Indexed
+public class CombiCar extends AbstractCar {
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/criteria/MixedCriteriaTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/criteria/MixedCriteriaTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/criteria/MixedCriteriaTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,128 +1,151 @@
-//$Id$
-package org.hibernate.search.test.query.criteria;
-
-import java.util.List;
-
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.queryParser.MultiFieldQueryParser;
-import org.apache.lucene.search.Query;
-
-import org.hibernate.Criteria;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.criterion.Restrictions;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.SearchException;
-import org.hibernate.search.test.SearchTestCase;
-
-/**
- * @author Hardy Ferentschik
- */
-public class MixedCriteriaTest extends SearchTestCase {
- /**
- * HSEARCH-360
- */
- public void testCriteriaWithFilteredEntity() throws Exception {
- indexTestData();
-
- // Search
- Session session = openSession();
- Transaction tx = session.beginTransaction();
- FullTextSession fullTextSession = Search.getFullTextSession( session );
-
- MultiFieldQueryParser parser = new MultiFieldQueryParser(
- new String[] { "kurztext" }, new StandardAnalyzer()
- );
- Query query = parser.parse( "combi OR sport" );
-
- Criteria criteria = session.createCriteria( AbstractCar.class );
- criteria.add( Restrictions.eq( "hasColor", Boolean.FALSE ) );
-
- org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( query, AbstractCar.class )
- .setCriteriaQuery( criteria );
- List result = hibQuery.list();
- assertEquals( 2, result.size() );
- tx.commit();
- session.close();
- }
-
- public void testCriteriaWithoutFilteredEntity() throws Exception {
- indexTestData();
-
- // Search
- Session session = openSession();
- Transaction tx = session.beginTransaction();
- FullTextSession fullTextSession = Search.getFullTextSession( session );
-
- MultiFieldQueryParser parser = new MultiFieldQueryParser(
- new String[] { "kurztext" }, new StandardAnalyzer()
- );
- Query query = parser.parse( "combi OR sport" );
-
- Criteria criteria = session.createCriteria( AbstractCar.class );
- criteria.add( Restrictions.eq( "hasColor", Boolean.FALSE ) );
-
- org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( query )
- .setCriteriaQuery( criteria );
- List result = hibQuery.list();
- assertEquals( 2, result.size() );
- tx.commit();
- session.close();
- }
-
- public void testCriteriaWithMultipleEntities() throws Exception {
- indexTestData();
-
- // Search
- Session session = openSession();
- Transaction tx = session.beginTransaction();
- FullTextSession fullTextSession = Search.getFullTextSession( session );
-
- MultiFieldQueryParser parser = new MultiFieldQueryParser(
- new String[] { "kurztext" }, new StandardAnalyzer()
- );
- Query query = parser.parse( "combi OR sport" );
-
- Criteria criteria = session.createCriteria( AbstractCar.class );
- criteria.add( Restrictions.eq( "hasColor", Boolean.FALSE ) );
-
- try {
- org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( query, AbstractCar.class, Bike.class )
- .setCriteriaQuery( criteria );
- hibQuery.list();
- fail();
- }
- catch ( SearchException se ) {
- assertEquals( "Cannot mix criteria and multiple entity types", se.getMessage() );
- }
- tx.commit();
- session.close();
- }
-
- private void indexTestData() {
- Session s = openSession();
- Transaction tx = s.beginTransaction();
-
- CombiCar combi = new CombiCar();
- combi.setKurztext( "combi" );
- s.persist( combi );
-
- SportCar sport = new SportCar();
- sport.setKurztext( "sport" );
- s.persist( sport );
-
- Bike bike = new Bike();
- bike.setKurztext( "bike" );
- s.persist( bike );
- tx.commit();
- s.close();
- }
-
-
- protected Class[] getMappings() {
- return new Class[] {
- AbstractCar.class, CombiCar.class, SportCar.class, Bike.class
- };
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.query.criteria;
+
+import java.util.List;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.MultiFieldQueryParser;
+import org.apache.lucene.search.Query;
+
+import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.criterion.Restrictions;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.test.SearchTestCase;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class MixedCriteriaTest extends SearchTestCase {
+ /**
+ * HSEARCH-360
+ */
+ public void testCriteriaWithFilteredEntity() throws Exception {
+ indexTestData();
+
+ // Search
+ Session session = openSession();
+ Transaction tx = session.beginTransaction();
+ FullTextSession fullTextSession = Search.getFullTextSession( session );
+
+ MultiFieldQueryParser parser = new MultiFieldQueryParser(
+ new String[] { "kurztext" }, new StandardAnalyzer()
+ );
+ Query query = parser.parse( "combi OR sport" );
+
+ Criteria criteria = session.createCriteria( AbstractCar.class );
+ criteria.add( Restrictions.eq( "hasColor", Boolean.FALSE ) );
+
+ org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( query, AbstractCar.class )
+ .setCriteriaQuery( criteria );
+ List result = hibQuery.list();
+ assertEquals( 2, result.size() );
+ tx.commit();
+ session.close();
+ }
+
+ public void testCriteriaWithoutFilteredEntity() throws Exception {
+ indexTestData();
+
+ // Search
+ Session session = openSession();
+ Transaction tx = session.beginTransaction();
+ FullTextSession fullTextSession = Search.getFullTextSession( session );
+
+ MultiFieldQueryParser parser = new MultiFieldQueryParser(
+ new String[] { "kurztext" }, new StandardAnalyzer()
+ );
+ Query query = parser.parse( "combi OR sport" );
+
+ Criteria criteria = session.createCriteria( AbstractCar.class );
+ criteria.add( Restrictions.eq( "hasColor", Boolean.FALSE ) );
+
+ org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( query )
+ .setCriteriaQuery( criteria );
+ List result = hibQuery.list();
+ assertEquals( 2, result.size() );
+ tx.commit();
+ session.close();
+ }
+
+ public void testCriteriaWithMultipleEntities() throws Exception {
+ indexTestData();
+
+ // Search
+ Session session = openSession();
+ Transaction tx = session.beginTransaction();
+ FullTextSession fullTextSession = Search.getFullTextSession( session );
+
+ MultiFieldQueryParser parser = new MultiFieldQueryParser(
+ new String[] { "kurztext" }, new StandardAnalyzer()
+ );
+ Query query = parser.parse( "combi OR sport" );
+
+ Criteria criteria = session.createCriteria( AbstractCar.class );
+ criteria.add( Restrictions.eq( "hasColor", Boolean.FALSE ) );
+
+ try {
+ org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( query, AbstractCar.class, Bike.class )
+ .setCriteriaQuery( criteria );
+ hibQuery.list();
+ fail();
+ }
+ catch ( SearchException se ) {
+ assertEquals( "Cannot mix criteria and multiple entity types", se.getMessage() );
+ }
+ tx.commit();
+ session.close();
+ }
+
+ private void indexTestData() {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+
+ CombiCar combi = new CombiCar();
+ combi.setKurztext( "combi" );
+ s.persist( combi );
+
+ SportCar sport = new SportCar();
+ sport.setKurztext( "sport" );
+ s.persist( sport );
+
+ Bike bike = new Bike();
+ bike.setKurztext( "bike" );
+ s.persist( bike );
+ tx.commit();
+ s.close();
+ }
+
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ AbstractCar.class, CombiCar.class, SportCar.class, Bike.class
+ };
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/criteria/SportCar.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/criteria/SportCar.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/criteria/SportCar.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,13 +1,36 @@
-//$Id$
-package org.hibernate.search.test.query.criteria;
-
-import javax.persistence.DiscriminatorValue;
-import javax.persistence.Entity;
-
-import org.hibernate.search.annotations.Indexed;
-
-@Entity
-@DiscriminatorValue(value = "Sport")
-@Indexed
-public class SportCar extends AbstractCar {
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.query.criteria;
+
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+
+import org.hibernate.search.annotations.Indexed;
+
+@Entity
+@DiscriminatorValue(value = "Sport")
+@Indexed
+public class SportCar extends AbstractCar {
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/explain/Dvd.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/explain/Dvd.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/explain/Dvd.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query.explain;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/query/explain/ExplanationTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/query/explain/ExplanationTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/query/explain/ExplanationTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.query.explain;
import java.util.Map;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/Detective.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/Detective.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/Detective.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/NotSharedReaderPerfTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/NotSharedReaderPerfTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/NotSharedReaderPerfTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader;
import org.hibernate.cfg.Configuration;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/ReaderPerfTestCase.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/ReaderPerfTestCase.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/ReaderPerfTestCase.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader;
import java.io.File;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/SharedBufferedReaderPerfTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/SharedBufferedReaderPerfTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/SharedBufferedReaderPerfTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader;
import org.hibernate.cfg.Configuration;
@@ -13,4 +36,4 @@
super.configure( cfg );
cfg.setProperty( Environment.READER_STRATEGY, SharingBufferReaderProvider.class.getCanonicalName() );
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/SharedReaderPerfTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/SharedReaderPerfTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/SharedReaderPerfTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader;
import org.hibernate.cfg.Configuration;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/Suspect.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/Suspect.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/Suspect.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/functionality/FilterOnDirectoryTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/functionality/FilterOnDirectoryTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/functionality/FilterOnDirectoryTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader.functionality;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/functionality/SharingBufferIndexProviderTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/functionality/SharingBufferIndexProviderTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/functionality/SharingBufferIndexProviderTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader.functionality;
import java.util.ArrayList;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/functionality/TestableSharingBufferReaderProvider.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/functionality/TestableSharingBufferReaderProvider.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/functionality/TestableSharingBufferReaderProvider.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader.functionality;
import java.io.IOException;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/performance/AbstractActivity.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/performance/AbstractActivity.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/performance/AbstractActivity.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader.performance;
import java.util.concurrent.CountDownLatch;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/performance/BufferSharingReaderPerfTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/performance/BufferSharingReaderPerfTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/performance/BufferSharingReaderPerfTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader.performance;
import org.hibernate.search.reader.SharingBufferReaderProvider;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/performance/IndexFillRunnable.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/performance/IndexFillRunnable.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/performance/IndexFillRunnable.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader.performance;
import java.io.IOException;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/performance/InsertActivity.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/performance/InsertActivity.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/performance/InsertActivity.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader.performance;
import java.util.concurrent.CountDownLatch;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/performance/NotSharedReaderPerfTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/performance/NotSharedReaderPerfTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/performance/NotSharedReaderPerfTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader.performance;
/**
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/performance/ReaderPerformance.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/performance/ReaderPerformance.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/performance/ReaderPerformance.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader.performance;
import java.io.File;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/performance/SearchActivity.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/performance/SearchActivity.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/performance/SearchActivity.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader.performance;
import java.util.concurrent.CountDownLatch;
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/performance/SharedReaderPerfTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/performance/SharedReaderPerfTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/performance/SharedReaderPerfTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader.performance;
/**
Modified: search/trunk/src/test/java/org/hibernate/search/test/reader/performance/UpdateActivity.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/reader/performance/UpdateActivity.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/reader/performance/UpdateActivity.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.reader.performance;
import java.util.List;
Modified: search/trunk/src/test/java/org/hibernate/search/test/session/Categorie.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/session/Categorie.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/session/Categorie.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.session;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/session/DelegationWrapper.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/session/DelegationWrapper.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/session/DelegationWrapper.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.session;
import java.lang.reflect.InvocationTargetException;
Modified: search/trunk/src/test/java/org/hibernate/search/test/session/Domain.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/session/Domain.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/session/Domain.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.session;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/session/Email.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/session/Email.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/session/Email.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,75 +1,98 @@
-//$Id$
-package org.hibernate.search.test.session;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-import javax.persistence.FetchType;
-
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.IndexedEmbedded;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-@Indexed
-public class Email {
- @Id
- @DocumentId
- private Long id;
-
- @Field(index = Index.TOKENIZED)
- private String title;
-
- @Field(index = Index.TOKENIZED)
- private String body;
-
- private String header;
-
- @IndexedEmbedded @ManyToOne(fetch = FetchType.LAZY)
- private Domain domain;
-
- public Domain getDomain() {
- return domain;
- }
-
- public void setDomain(Domain domain) {
- this.domain = domain;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getBody() {
- return body;
- }
-
- public void setBody(String body) {
- this.body = body;
- }
-
- public String getHeader() {
- return header;
- }
-
- public void setHeader(String header) {
- this.header = header;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.session;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.FetchType;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.IndexedEmbedded;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed
+public class Email {
+ @Id
+ @DocumentId
+ private Long id;
+
+ @Field(index = Index.TOKENIZED)
+ private String title;
+
+ @Field(index = Index.TOKENIZED)
+ private String body;
+
+ private String header;
+
+ @IndexedEmbedded @ManyToOne(fetch = FetchType.LAZY)
+ private Domain domain;
+
+ public Domain getDomain() {
+ return domain;
+ }
+
+ public void setDomain(Domain domain) {
+ this.domain = domain;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getBody() {
+ return body;
+ }
+
+ public void setBody(String body) {
+ this.body = body;
+ }
+
+ public String getHeader() {
+ return header;
+ }
+
+ public void setHeader(String header) {
+ this.header = header;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/session/Entite.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/session/Entite.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/session/Entite.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.session;
import javax.persistence.Entity;
@@ -63,4 +86,4 @@
public void setCategorie(Categorie categorie) {
this.categorie = categorie;
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/session/MassIndexTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/session/MassIndexTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/session/MassIndexTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,205 +1,228 @@
-//$Id$
-package org.hibernate.search.test.session;
-
-import java.sql.Statement;
-import java.sql.SQLException;
-import java.util.List;
-import java.util.Iterator;
-
-import org.apache.lucene.analysis.StopAnalyzer;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-import org.hibernate.ScrollMode;
-import org.hibernate.ScrollableResults;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.search.Environment;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.impl.FullTextSessionImpl;
-import org.hibernate.search.test.SearchTestCase;
-
-/**
- * @author Emmanuel Bernard
- */
-public class MassIndexTest extends SearchTestCase {
-
- public void testBatchSize() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
- int loop = 14;
- for (int i = 0; i < loop; i++) {
- Statement statmt = s.connection().createStatement();
- statmt.executeUpdate( "insert into Domain(id, name) values( + "
- + ( i + 1 ) + ", 'sponge" + i + "')" );
- statmt.executeUpdate( "insert into Email(id, title, body, header, domain_id) values( + "
- + ( i + 1 ) + ", 'Bob Sponge', 'Meet the guys who create the software', 'nope', " + ( i + 1 ) +")" );
- statmt.close();
- }
- tx.commit();
- s.close();
-
- //check non created object does get found!!1
- s = new FullTextSessionImpl( openSession() );
- tx = s.beginTransaction();
- ScrollableResults results = s.createCriteria( Email.class ).scroll( ScrollMode.FORWARD_ONLY );
- int index = 0;
- while ( results.next() ) {
- index++;
- s.index( results.get( 0 ) );
- if ( index % 5 == 0 ) s.clear();
- }
- tx.commit();
- s.clear();
- tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
- List result = s.createFullTextQuery( parser.parse( "body:create" ) ).list();
- assertEquals( 14, result.size() );
- for (Object object : result) {
- s.delete( object );
- }
- tx.commit();
- s.close();
- }
-
-
- public void testTransactional() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
- int loop = 4;
- for (int i = 0; i < loop; i++) {
- Email email = new Email();
- email.setId( (long) i + 1 );
- email.setTitle( "JBoss World Berlin" );
- email.setBody( "Meet the guys who wrote the software" );
- s.persist( email );
- }
- tx.commit();
- s.close();
-
- //check non created object does get found!!1
- s = new FullTextSessionImpl( openSession() );
- tx = s.beginTransaction();
- QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
- List result = s.createFullTextQuery( parser.parse( "body:create" ) ).list();
- assertEquals( 0, result.size() );
- tx.commit();
- s.close();
-
- s = new FullTextSessionImpl( openSession() );
- s.getTransaction().begin();
- Statement stmt = s.connection().createStatement();
- stmt.executeUpdate( "update Email set body='Meet the guys who write the software'" );
- stmt.close();
- //insert an object never indexed
- stmt = s.connection().createStatement();
- stmt.executeUpdate( "insert into Email(id, title, body, header) values( + "
- + ( loop + 1 ) + ", 'Bob Sponge', 'Meet the guys who create the software', 'nope')" );
- stmt.close();
- s.getTransaction().commit();
- s.close();
-
- s = new FullTextSessionImpl( openSession() );
- tx = s.beginTransaction();
- parser = new QueryParser( "id", new StopAnalyzer() );
- result = s.createFullTextQuery( parser.parse( "body:write" ) ).list();
- assertEquals( 0, result.size() );
- result = s.createCriteria( Email.class ).list();
- for (int i = 0; i < loop / 2; i++)
- s.index( result.get( i ) );
- tx.commit(); //do the process
- s.index( result.get( loop / 2 ) ); //do the process out of tx
- tx = s.beginTransaction();
- for (int i = loop / 2 + 1; i < loop; i++)
- s.index( result.get( i ) );
- tx.commit(); //do the process
- s.close();
-
- s = Search.getFullTextSession( openSession() );
- tx = s.beginTransaction();
- //object never indexed
- Email email = (Email) s.get( Email.class, Long.valueOf( loop + 1 ) );
- s.index( email );
- tx.commit();
- s.close();
-
- //check non indexed object get indexed by s.index
- s = new FullTextSessionImpl( openSession() );
- tx = s.beginTransaction();
- result = s.createFullTextQuery( parser.parse( "body:create" ) ).list();
- assertEquals( 1, result.size() );
- tx.commit();
- s.close();
- }
-
- public void testLazyLoading() throws Exception {
- Categorie cat = new Categorie( "Livre" );
- Entite ent = new Entite( "Le temple des songes", cat );
- Session s = openSession();
- Transaction tx = s.beginTransaction();
- s.persist( cat );
- s.persist( ent );
- tx.commit();
- s.close();
-
- s = getSessionWithAutoCommit();
- FullTextSession session = Search.getFullTextSession( s );
- Query luceneQuery = new TermQuery( new Term( "categorie.nom", "livre" ) );
- List result = session.createFullTextQuery( luceneQuery, Entite.class ).list();
- assertEquals( 1, result.size() );
- s.close();
-
- s = getSessionWithAutoCommit();
- ent = (Entite) s.get( Entite.class, ent.getId() );
- session = Search.getFullTextSession( s );
- session.index( ent );
- s.close();
-
- s = getSessionWithAutoCommit();
- session = Search.getFullTextSession( s );
- luceneQuery = new TermQuery( new Term( "categorie.nom", "livre" ) );
- result = session.createFullTextQuery( luceneQuery, Entite.class ).list();
- assertEquals( "test lazy loading and indexing", 1, result.size() );
- s.close();
-
- s = getSessionWithAutoCommit();
- Iterator it = s.createQuery( "from Entite where id = :id").setParameter( "id", ent.getId() ).iterate();
- session = Search.getFullTextSession( s );
- while ( it.hasNext() ) {
- ent = (Entite) it.next();
- session.index( ent );
- }
- s.close();
-
- s = getSessionWithAutoCommit();
- session = Search.getFullTextSession( s );
- luceneQuery = new TermQuery( new Term( "categorie.nom", "livre" ) );
- result = session.createFullTextQuery( luceneQuery, Entite.class ).list();
- assertEquals( "test lazy loading and indexing", 1, result.size() );
- s.close();
- }
-
- private Session getSessionWithAutoCommit() throws SQLException {
- Session s;
- s = openSession();
- s.connection().setAutoCommit( true );
- return s;
- }
-
- protected void configure(org.hibernate.cfg.Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( "hibernate.search.worker.batch_size", "5" );
- cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
- }
-
- protected Class[] getMappings() {
- return new Class[] {
- Email.class,
- Entite.class,
- Categorie.class,
- Domain.class
- };
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.session;
+
+import java.sql.Statement;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Iterator;
+
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+import org.hibernate.ScrollMode;
+import org.hibernate.ScrollableResults;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.search.Environment;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.impl.FullTextSessionImpl;
+import org.hibernate.search.test.SearchTestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class MassIndexTest extends SearchTestCase {
+
+ public void testBatchSize() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ int loop = 14;
+ for (int i = 0; i < loop; i++) {
+ Statement statmt = s.connection().createStatement();
+ statmt.executeUpdate( "insert into Domain(id, name) values( + "
+ + ( i + 1 ) + ", 'sponge" + i + "')" );
+ statmt.executeUpdate( "insert into Email(id, title, body, header, domain_id) values( + "
+ + ( i + 1 ) + ", 'Bob Sponge', 'Meet the guys who create the software', 'nope', " + ( i + 1 ) +")" );
+ statmt.close();
+ }
+ tx.commit();
+ s.close();
+
+ //check non created object does get found!!1
+ s = new FullTextSessionImpl( openSession() );
+ tx = s.beginTransaction();
+ ScrollableResults results = s.createCriteria( Email.class ).scroll( ScrollMode.FORWARD_ONLY );
+ int index = 0;
+ while ( results.next() ) {
+ index++;
+ s.index( results.get( 0 ) );
+ if ( index % 5 == 0 ) s.clear();
+ }
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
+ List result = s.createFullTextQuery( parser.parse( "body:create" ) ).list();
+ assertEquals( 14, result.size() );
+ for (Object object : result) {
+ s.delete( object );
+ }
+ tx.commit();
+ s.close();
+ }
+
+
+ public void testTransactional() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ int loop = 4;
+ for (int i = 0; i < loop; i++) {
+ Email email = new Email();
+ email.setId( (long) i + 1 );
+ email.setTitle( "JBoss World Berlin" );
+ email.setBody( "Meet the guys who wrote the software" );
+ s.persist( email );
+ }
+ tx.commit();
+ s.close();
+
+ //check non created object does get found!!1
+ s = new FullTextSessionImpl( openSession() );
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
+ List result = s.createFullTextQuery( parser.parse( "body:create" ) ).list();
+ assertEquals( 0, result.size() );
+ tx.commit();
+ s.close();
+
+ s = new FullTextSessionImpl( openSession() );
+ s.getTransaction().begin();
+ Statement stmt = s.connection().createStatement();
+ stmt.executeUpdate( "update Email set body='Meet the guys who write the software'" );
+ stmt.close();
+ //insert an object never indexed
+ stmt = s.connection().createStatement();
+ stmt.executeUpdate( "insert into Email(id, title, body, header) values( + "
+ + ( loop + 1 ) + ", 'Bob Sponge', 'Meet the guys who create the software', 'nope')" );
+ stmt.close();
+ s.getTransaction().commit();
+ s.close();
+
+ s = new FullTextSessionImpl( openSession() );
+ tx = s.beginTransaction();
+ parser = new QueryParser( "id", new StopAnalyzer() );
+ result = s.createFullTextQuery( parser.parse( "body:write" ) ).list();
+ assertEquals( 0, result.size() );
+ result = s.createCriteria( Email.class ).list();
+ for (int i = 0; i < loop / 2; i++)
+ s.index( result.get( i ) );
+ tx.commit(); //do the process
+ s.index( result.get( loop / 2 ) ); //do the process out of tx
+ tx = s.beginTransaction();
+ for (int i = loop / 2 + 1; i < loop; i++)
+ s.index( result.get( i ) );
+ tx.commit(); //do the process
+ s.close();
+
+ s = Search.getFullTextSession( openSession() );
+ tx = s.beginTransaction();
+ //object never indexed
+ Email email = (Email) s.get( Email.class, Long.valueOf( loop + 1 ) );
+ s.index( email );
+ tx.commit();
+ s.close();
+
+ //check non indexed object get indexed by s.index
+ s = new FullTextSessionImpl( openSession() );
+ tx = s.beginTransaction();
+ result = s.createFullTextQuery( parser.parse( "body:create" ) ).list();
+ assertEquals( 1, result.size() );
+ tx.commit();
+ s.close();
+ }
+
+ public void testLazyLoading() throws Exception {
+ Categorie cat = new Categorie( "Livre" );
+ Entite ent = new Entite( "Le temple des songes", cat );
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist( cat );
+ s.persist( ent );
+ tx.commit();
+ s.close();
+
+ s = getSessionWithAutoCommit();
+ FullTextSession session = Search.getFullTextSession( s );
+ Query luceneQuery = new TermQuery( new Term( "categorie.nom", "livre" ) );
+ List result = session.createFullTextQuery( luceneQuery, Entite.class ).list();
+ assertEquals( 1, result.size() );
+ s.close();
+
+ s = getSessionWithAutoCommit();
+ ent = (Entite) s.get( Entite.class, ent.getId() );
+ session = Search.getFullTextSession( s );
+ session.index( ent );
+ s.close();
+
+ s = getSessionWithAutoCommit();
+ session = Search.getFullTextSession( s );
+ luceneQuery = new TermQuery( new Term( "categorie.nom", "livre" ) );
+ result = session.createFullTextQuery( luceneQuery, Entite.class ).list();
+ assertEquals( "test lazy loading and indexing", 1, result.size() );
+ s.close();
+
+ s = getSessionWithAutoCommit();
+ Iterator it = s.createQuery( "from Entite where id = :id").setParameter( "id", ent.getId() ).iterate();
+ session = Search.getFullTextSession( s );
+ while ( it.hasNext() ) {
+ ent = (Entite) it.next();
+ session.index( ent );
+ }
+ s.close();
+
+ s = getSessionWithAutoCommit();
+ session = Search.getFullTextSession( s );
+ luceneQuery = new TermQuery( new Term( "categorie.nom", "livre" ) );
+ result = session.createFullTextQuery( luceneQuery, Entite.class ).list();
+ assertEquals( "test lazy loading and indexing", 1, result.size() );
+ s.close();
+ }
+
+ private Session getSessionWithAutoCommit() throws SQLException {
+ Session s;
+ s = openSession();
+ s.connection().setAutoCommit( true );
+ return s;
+ }
+
+ protected void configure(org.hibernate.cfg.Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( "hibernate.search.worker.batch_size", "5" );
+ cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Email.class,
+ Entite.class,
+ Categorie.class,
+ Domain.class
+ };
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/session/MassIndexUsingManualFlushTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/session/MassIndexUsingManualFlushTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/session/MassIndexUsingManualFlushTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.session;
import java.sql.Statement;
Modified: search/trunk/src/test/java/org/hibernate/search/test/session/OptimizeTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/session/OptimizeTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/session/OptimizeTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.session;
import java.io.File;
Modified: search/trunk/src/test/java/org/hibernate/search/test/session/SessionTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/session/SessionTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/session/SessionTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.session;
import java.lang.reflect.Proxy;
Modified: search/trunk/src/test/java/org/hibernate/search/test/shards/Animal.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/Animal.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/Animal.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.shards;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategy.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.shards;
import java.io.Serializable;
Modified: search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategyTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategyTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategyTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.shards;
import junit.framework.TestCase;
@@ -54,4 +77,4 @@
));
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/shards/DirectoryProviderForQueryTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/DirectoryProviderForQueryTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/DirectoryProviderForQueryTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.shards;
import java.io.File;
Modified: search/trunk/src/test/java/org/hibernate/search/test/shards/Email.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/Email.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/Email.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.shards;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/shards/Furniture.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/Furniture.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/Furniture.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.shards;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/shards/IdShardingStrategyTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/IdShardingStrategyTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/IdShardingStrategyTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.shards;
import org.hibernate.search.store.DirectoryProvider;
@@ -37,4 +60,4 @@
}
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/shards/ShardsTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/ShardsTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/ShardsTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.shards;
import java.io.File;
Modified: search/trunk/src/test/java/org/hibernate/search/test/shards/SpecificShardingStrategy.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/SpecificShardingStrategy.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/SpecificShardingStrategy.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.shards;
import org.hibernate.search.FullTextFilter;
Modified: search/trunk/src/test/java/org/hibernate/search/test/similarity/Can.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/similarity/Can.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/similarity/Can.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.similarity;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/similarity/DummySimilarity.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/similarity/DummySimilarity.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/similarity/DummySimilarity.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.similarity;
import org.apache.lucene.search.DefaultSimilarity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/similarity/DummySimilarity2.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/similarity/DummySimilarity2.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/similarity/DummySimilarity2.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.similarity;
import org.apache.lucene.search.DefaultSimilarity;
@@ -38,4 +61,4 @@
public float coord(int overlap, int maxOverlap) {
return CONST;
}
-}
\ No newline at end of file
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/similarity/SimilarityTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/similarity/SimilarityTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/similarity/SimilarityTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.similarity;
import java.util.List;
Modified: search/trunk/src/test/java/org/hibernate/search/test/similarity/Trash.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/similarity/Trash.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/similarity/Trash.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.similarity;
import javax.persistence.Id;
Modified: search/trunk/src/test/java/org/hibernate/search/test/util/AnalyzerUtils.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/util/AnalyzerUtils.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/util/AnalyzerUtils.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.util;
import java.io.IOException;
Modified: search/trunk/src/test/java/org/hibernate/search/test/util/FileHelperTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/util/FileHelperTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/util/FileHelperTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,116 +1,139 @@
-//$Id$
-package org.hibernate.search.test.util;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-import org.slf4j.Logger;
-
-import org.hibernate.search.util.FileHelper;
-import org.hibernate.search.util.LoggerFactory;
-
-/**
- * @author Emmanuel Bernard
- * @author Hardy Ferentschik
- */
-public class FileHelperTest extends TestCase {
- private static final Logger log = LoggerFactory.make();
-
- private static File root;
-
- static {
- String buildDir = System.getProperty( "build.dir" );
- if ( buildDir == null ) {
- buildDir = ".";
- }
- root = new File( buildDir, "filehelper" );
- log.info( "Using {} as test directory.", root.getAbsolutePath() );
- }
-
- /**
- * Source directory
- */
- private String srcDir = "filehelpersrc";
-
- /**
- * Destination directory
- */
- private String destDir = "filehelperdest";
-
-
- private File createFile(File dir, String name) throws IOException {
- File file = new File( dir, name );
- file.createNewFile();
- writeDummyDataToFile( file );
- return file;
- }
-
- private void writeDummyDataToFile(File file) throws IOException {
- FileOutputStream os = new FileOutputStream( file, true );
- os.write( 1 );
- os.write( 2 );
- os.write( 3 );
- os.flush();
- os.close();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- File dir = new File( root, srcDir );
- FileHelper.delete( dir );
- dir = new File( root, destDir );
- FileHelper.delete( dir );
- FileHelper.delete( root );
- }
-
- public void testSynchronize() throws Exception {
- // create a src directory structure
- File src = new File( root, srcDir );
- src.mkdirs();
- String name = "a";
- createFile( src, name );
- name = "b";
- createFile( src, name );
- File subDir = new File( src, "subdir" );
- subDir.mkdirs();
- name = "c";
- createFile( subDir, name );
-
- // create destination and sync
- File dest = new File( root, destDir );
- assertFalse( "Directories should be out of sync", FileHelper.areInSync( src, dest ) );
- FileHelper.synchronize( src, dest, true );
- assertTrue( "Directories should be in sync", FileHelper.areInSync( src, dest ) );
- File destTestFile1 = new File( dest, "b" );
- assertTrue( destTestFile1.exists() );
- File destTestFile2 = new File( new File( dest, "subdir" ), "c" );
- assertTrue( destTestFile2.exists() );
-
- // create a new file in destination which does not exists in src. should be deleted after next sync
- File destTestFile3 = createFile( dest, "foo" );
-
- // create a file in the src directory and write some data to it
- File srcTestFile = new File( src, "c" );
- writeDummyDataToFile( srcTestFile );
- File destTestFile = new File( dest, "c" );
- assertNotSame( srcTestFile.lastModified(), destTestFile.lastModified() );
- assertFalse( "Directories should be out of sync", FileHelper.areInSync( src, dest ) );
-
- FileHelper.synchronize( src, dest, true );
-
- assertTrue("Directories should be in sync", FileHelper.areInSync( src, dest ));
- assertEquals( srcTestFile.lastModified(), destTestFile.lastModified() );
- assertEquals( srcTestFile.length(), destTestFile.length() );
- assertTrue( destTestFile1.exists() );
- assertTrue( destTestFile2.exists() );
- assertTrue( !destTestFile3.exists() );
-
- // delete src test file
- srcTestFile.delete();
- FileHelper.synchronize( src, dest, true );
- assertTrue( !destTestFile.exists() );
- assertTrue("Directories should be in sync", FileHelper.areInSync( src, dest ));
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.util;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+import org.slf4j.Logger;
+
+import org.hibernate.search.util.FileHelper;
+import org.hibernate.search.util.LoggerFactory;
+
+/**
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+public class FileHelperTest extends TestCase {
+ private static final Logger log = LoggerFactory.make();
+
+ private static File root;
+
+ static {
+ String buildDir = System.getProperty( "build.dir" );
+ if ( buildDir == null ) {
+ buildDir = ".";
+ }
+ root = new File( buildDir, "filehelper" );
+ log.info( "Using {} as test directory.", root.getAbsolutePath() );
+ }
+
+ /**
+ * Source directory
+ */
+ private String srcDir = "filehelpersrc";
+
+ /**
+ * Destination directory
+ */
+ private String destDir = "filehelperdest";
+
+
+ private File createFile(File dir, String name) throws IOException {
+ File file = new File( dir, name );
+ file.createNewFile();
+ writeDummyDataToFile( file );
+ return file;
+ }
+
+ private void writeDummyDataToFile(File file) throws IOException {
+ FileOutputStream os = new FileOutputStream( file, true );
+ os.write( 1 );
+ os.write( 2 );
+ os.write( 3 );
+ os.flush();
+ os.close();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ File dir = new File( root, srcDir );
+ FileHelper.delete( dir );
+ dir = new File( root, destDir );
+ FileHelper.delete( dir );
+ FileHelper.delete( root );
+ }
+
+ public void testSynchronize() throws Exception {
+ // create a src directory structure
+ File src = new File( root, srcDir );
+ src.mkdirs();
+ String name = "a";
+ createFile( src, name );
+ name = "b";
+ createFile( src, name );
+ File subDir = new File( src, "subdir" );
+ subDir.mkdirs();
+ name = "c";
+ createFile( subDir, name );
+
+ // create destination and sync
+ File dest = new File( root, destDir );
+ assertFalse( "Directories should be out of sync", FileHelper.areInSync( src, dest ) );
+ FileHelper.synchronize( src, dest, true );
+ assertTrue( "Directories should be in sync", FileHelper.areInSync( src, dest ) );
+ File destTestFile1 = new File( dest, "b" );
+ assertTrue( destTestFile1.exists() );
+ File destTestFile2 = new File( new File( dest, "subdir" ), "c" );
+ assertTrue( destTestFile2.exists() );
+
+ // create a new file in destination which does not exists in src. should be deleted after next sync
+ File destTestFile3 = createFile( dest, "foo" );
+
+ // create a file in the src directory and write some data to it
+ File srcTestFile = new File( src, "c" );
+ writeDummyDataToFile( srcTestFile );
+ File destTestFile = new File( dest, "c" );
+ assertNotSame( srcTestFile.lastModified(), destTestFile.lastModified() );
+ assertFalse( "Directories should be out of sync", FileHelper.areInSync( src, dest ) );
+
+ FileHelper.synchronize( src, dest, true );
+
+ assertTrue("Directories should be in sync", FileHelper.areInSync( src, dest ));
+ assertEquals( srcTestFile.lastModified(), destTestFile.lastModified() );
+ assertEquals( srcTestFile.length(), destTestFile.length() );
+ assertTrue( destTestFile1.exists() );
+ assertTrue( destTestFile2.exists() );
+ assertTrue( !destTestFile3.exists() );
+
+ // delete src test file
+ srcTestFile.delete();
+ FileHelper.synchronize( src, dest, true );
+ assertTrue( !destTestFile.exists() );
+ assertTrue("Directories should be in sync", FileHelper.areInSync( src, dest ));
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/util/FullTextSessionBuilder.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/util/FullTextSessionBuilder.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/util/FullTextSessionBuilder.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.util;
import java.io.File;
Modified: search/trunk/src/test/java/org/hibernate/search/test/util/PluginLoaderTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/util/PluginLoaderTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/util/PluginLoaderTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.util;
import org.apache.lucene.search.DefaultSimilarity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/util/textbuilder/SentenceInventor.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/util/textbuilder/SentenceInventor.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/util/textbuilder/SentenceInventor.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.util.textbuilder;
import java.util.Random;
Modified: search/trunk/src/test/java/org/hibernate/search/test/util/textbuilder/TextProductionTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/util/textbuilder/TextProductionTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/util/textbuilder/TextProductionTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.util.textbuilder;
import junit.framework.TestCase;
Modified: search/trunk/src/test/java/org/hibernate/search/test/util/textbuilder/WordDictionary.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/util/textbuilder/WordDictionary.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/util/textbuilder/WordDictionary.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.util.textbuilder;
import java.util.Arrays;
Modified: search/trunk/src/test/java/org/hibernate/search/test/worker/AsyncWorkerTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/worker/AsyncWorkerTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/worker/AsyncWorkerTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,24 +1,47 @@
-//$Id$
-package org.hibernate.search.test.worker;
-
-import org.hibernate.search.store.RAMDirectoryProvider;
-import org.hibernate.search.Environment;
-import org.hibernate.cfg.Configuration;
-import org.apache.lucene.analysis.StopAnalyzer;
-
-/**
- * @author Emmanuel Bernard
- */
-public class AsyncWorkerTest extends WorkerTestCase {
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( "hibernate.search.default.directory_provider", RAMDirectoryProvider.class.getName() );
- cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
- cfg.setProperty( Environment.WORKER_SCOPE, "transaction" );
- cfg.setProperty( Environment.WORKER_EXECUTION, "async" );
- cfg.setProperty( Environment.WORKER_PREFIX + "thread_pool.size", "1" );
- cfg.setProperty( Environment.WORKER_PREFIX + "buffer_queue.max", "10" );
- }
-
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.worker;
+
+import org.hibernate.search.store.RAMDirectoryProvider;
+import org.hibernate.search.Environment;
+import org.hibernate.cfg.Configuration;
+import org.apache.lucene.analysis.StopAnalyzer;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class AsyncWorkerTest extends WorkerTestCase {
+
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( "hibernate.search.default.directory_provider", RAMDirectoryProvider.class.getName() );
+ cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
+ cfg.setProperty( Environment.WORKER_SCOPE, "transaction" );
+ cfg.setProperty( Environment.WORKER_EXECUTION, "async" );
+ cfg.setProperty( Environment.WORKER_PREFIX + "thread_pool.size", "1" );
+ cfg.setProperty( Environment.WORKER_PREFIX + "buffer_queue.max", "10" );
+ }
+
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/worker/ConcurrencyTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/worker/ConcurrencyTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/worker/ConcurrencyTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.worker;
import org.hibernate.search.test.SearchTestCase;
Modified: search/trunk/src/test/java/org/hibernate/search/test/worker/Drink.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/worker/Drink.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/worker/Drink.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.worker;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/worker/Employee.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/worker/Employee.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/worker/Employee.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,43 +1,66 @@
-//$Id$
-package org.hibernate.search.test.worker;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
-
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-@Indexed(index="employee")
-public class Employee {
- @Id
- @GeneratedValue
- @DocumentId
- private long id;
-
- @Field(index = Index.TOKENIZED )
- private String name;
-
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.worker;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed(index="employee")
+public class Employee {
+ @Id
+ @GeneratedValue
+ @DocumentId
+ private long id;
+
+ @Field(index = Index.TOKENIZED )
+ private String name;
+
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/worker/Employer.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/worker/Employer.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/worker/Employer.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,43 +1,66 @@
-//$Id$
-package org.hibernate.search.test.worker;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
-
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.DocumentId;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-@Indexed(index="employer")
-public class Employer {
- @Id
- @GeneratedValue
- @DocumentId
- private long id;
-
- @Field(index = Index.TOKENIZED )
- private String name;
-
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.worker;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.DocumentId;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed(index="employer")
+public class Employer {
+ @Id
+ @GeneratedValue
+ @DocumentId
+ private long id;
+
+ @Field(index = Index.TOKENIZED )
+ private String name;
+
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/worker/Food.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/worker/Food.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/worker/Food.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-//$Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.worker;
import javax.persistence.Entity;
Modified: search/trunk/src/test/java/org/hibernate/search/test/worker/SyncWorkerTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/worker/SyncWorkerTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/worker/SyncWorkerTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,21 +1,44 @@
-//$Id$
-package org.hibernate.search.test.worker;
-
-import org.hibernate.cfg.Configuration;
-import org.hibernate.search.store.RAMDirectoryProvider;
-import org.hibernate.search.Environment;
-import org.apache.lucene.analysis.StopAnalyzer;
-
-/**
- * @author Emmanuel Bernard
- */
-public class SyncWorkerTest extends WorkerTestCase {
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( "hibernate.search.default.directory_provider", RAMDirectoryProvider.class.getName() );
- cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
- cfg.setProperty( Environment.WORKER_SCOPE, "transaction" );
- cfg.setProperty( Environment.WORKER_PREFIX, "sync" );
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.worker;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.search.store.RAMDirectoryProvider;
+import org.hibernate.search.Environment;
+import org.apache.lucene.analysis.StopAnalyzer;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class SyncWorkerTest extends WorkerTestCase {
+
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( "hibernate.search.default.directory_provider", RAMDirectoryProvider.class.getName() );
+ cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
+ cfg.setProperty( Environment.WORKER_SCOPE, "transaction" );
+ cfg.setProperty( Environment.WORKER_PREFIX, "sync" );
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/worker/WorkerTestCase.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/worker/WorkerTestCase.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/worker/WorkerTestCase.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,184 +1,207 @@
-//$Id$
-package org.hibernate.search.test.worker;
-
-import java.io.File;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.apache.lucene.analysis.StopAnalyzer;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.search.Environment;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.impl.FullTextSessionImpl;
-import org.hibernate.search.store.FSDirectoryProvider;
-import org.hibernate.search.test.SearchTestCase;
-import org.hibernate.search.util.FileHelper;
-
-/**
- * @author Emmanuel Bernard
- */
-public class WorkerTestCase extends SearchTestCase {
-
- protected void setUp() throws Exception {
- File sub = getBaseIndexDir();
- sub.mkdir();
- File[] files = sub.listFiles();
- for ( File file : files ) {
- if ( file.isDirectory() ) {
- FileHelper.delete( file );
- }
- }
- //super.setUp(); //we need a fresh session factory each time for index set up
- buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFiles() );
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- File sub = getBaseIndexDir();
- FileHelper.delete( sub );
- }
-
- public void testConcurrency() throws Exception {
- int nThreads = 15;
- ExecutorService es = Executors.newFixedThreadPool( nThreads );
- Work work = new Work( getSessions() );
- ReverseWork reverseWork = new ReverseWork( getSessions() );
- long start = System.currentTimeMillis();
- int iteration = 100;
- for ( int i = 0; i < iteration; i++ ) {
- es.execute( work );
- es.execute( reverseWork );
- }
- while ( work.count < iteration - 1 ) {
- Thread.sleep( 20 );
- }
- getSessions().close();
- System.out.println( iteration + " iterations (8 tx per iteration) in " + nThreads + " threads: " + ( System
- .currentTimeMillis() - start ) );
- }
-
- protected static class Work implements Runnable {
- private SessionFactory sf;
- public volatile int count = 0;
-
- public Work(SessionFactory sf) {
- this.sf = sf;
- }
-
- public void run() {
- Session s = sf.openSession();
- Transaction tx = s.beginTransaction();
- Employee ee = new Employee();
- ee.setName( "Emmanuel" );
- s.persist( ee );
- Employer er = new Employer();
- er.setName( "RH" );
- s.persist( er );
- tx.commit();
- s.close();
-
- s = sf.openSession();
- tx = s.beginTransaction();
- ee = (Employee) s.get( Employee.class, ee.getId() );
- ee.setName( "Emmanuel2" );
- er = (Employer) s.get( Employer.class, er.getId() );
- er.setName( "RH2" );
- tx.commit();
- s.close();
-
-// try {
-// Thread.sleep( 50 );
-// }
-// catch (InterruptedException e) {
-// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
-// }
-
- s = sf.openSession();
- tx = s.beginTransaction();
- FullTextSession fts = new FullTextSessionImpl( s );
- QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
- Query query;
- try {
- query = parser.parse( "name:emmanuel2" );
- }
- catch (ParseException e) {
- throw new RuntimeException( e );
- }
- boolean results = fts.createFullTextQuery( query ).list().size() > 0;
- //don't test because in case of async, it query happens before actual saving
- //if ( !results ) throw new RuntimeException( "No results!" );
- tx.commit();
- s.close();
-
- s = sf.openSession();
- tx = s.beginTransaction();
- ee = (Employee) s.get( Employee.class, ee.getId() );
- s.delete( ee );
- er = (Employer) s.get( Employer.class, er.getId() );
- s.delete( er );
- tx.commit();
- s.close();
- count++;
- }
- }
-
- protected static class ReverseWork implements Runnable {
- private SessionFactory sf;
-
- public ReverseWork(SessionFactory sf) {
- this.sf = sf;
- }
-
- public void run() {
- Session s = sf.openSession();
- Transaction tx = s.beginTransaction();
- Employer er = new Employer();
- er.setName( "RH" );
- s.persist( er );
- Employee ee = new Employee();
- ee.setName( "Emmanuel" );
- s.persist( ee );
- tx.commit();
- s.close();
-
- s = sf.openSession();
- tx = s.beginTransaction();
- er = (Employer) s.get( Employer.class, er.getId() );
- er.setName( "RH2" );
- ee = (Employee) s.get( Employee.class, ee.getId() );
- ee.setName( "Emmanuel2" );
- tx.commit();
- s.close();
-
- s = sf.openSession();
- tx = s.beginTransaction();
- er = (Employer) s.get( Employer.class, er.getId() );
- s.delete( er );
- ee = (Employee) s.get( Employee.class, ee.getId() );
- s.delete( ee );
- tx.commit();
- s.close();
- }
- }
-
- protected void configure(org.hibernate.cfg.Configuration cfg) {
- super.configure( cfg );
- File sub = getBaseIndexDir();
- cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath() );
- cfg.setProperty( "hibernate.search.Clock.directory_provider", FSDirectoryProvider.class.getName() );
- cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
- }
-
- @SuppressWarnings("unchecked")
- protected Class[] getMappings() {
- return new Class[]{
- Employee.class,
- Employer.class
- };
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.worker;
+
+import java.io.File;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.search.Environment;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.impl.FullTextSessionImpl;
+import org.hibernate.search.store.FSDirectoryProvider;
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.util.FileHelper;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class WorkerTestCase extends SearchTestCase {
+
+ protected void setUp() throws Exception {
+ File sub = getBaseIndexDir();
+ sub.mkdir();
+ File[] files = sub.listFiles();
+ for ( File file : files ) {
+ if ( file.isDirectory() ) {
+ FileHelper.delete( file );
+ }
+ }
+ //super.setUp(); //we need a fresh session factory each time for index set up
+ buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFiles() );
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ File sub = getBaseIndexDir();
+ FileHelper.delete( sub );
+ }
+
+ public void testConcurrency() throws Exception {
+ int nThreads = 15;
+ ExecutorService es = Executors.newFixedThreadPool( nThreads );
+ Work work = new Work( getSessions() );
+ ReverseWork reverseWork = new ReverseWork( getSessions() );
+ long start = System.currentTimeMillis();
+ int iteration = 100;
+ for ( int i = 0; i < iteration; i++ ) {
+ es.execute( work );
+ es.execute( reverseWork );
+ }
+ while ( work.count < iteration - 1 ) {
+ Thread.sleep( 20 );
+ }
+ getSessions().close();
+ System.out.println( iteration + " iterations (8 tx per iteration) in " + nThreads + " threads: " + ( System
+ .currentTimeMillis() - start ) );
+ }
+
+ protected static class Work implements Runnable {
+ private SessionFactory sf;
+ public volatile int count = 0;
+
+ public Work(SessionFactory sf) {
+ this.sf = sf;
+ }
+
+ public void run() {
+ Session s = sf.openSession();
+ Transaction tx = s.beginTransaction();
+ Employee ee = new Employee();
+ ee.setName( "Emmanuel" );
+ s.persist( ee );
+ Employer er = new Employer();
+ er.setName( "RH" );
+ s.persist( er );
+ tx.commit();
+ s.close();
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ ee = (Employee) s.get( Employee.class, ee.getId() );
+ ee.setName( "Emmanuel2" );
+ er = (Employer) s.get( Employer.class, er.getId() );
+ er.setName( "RH2" );
+ tx.commit();
+ s.close();
+
+// try {
+// Thread.sleep( 50 );
+// }
+// catch (InterruptedException e) {
+// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+// }
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ FullTextSession fts = new FullTextSessionImpl( s );
+ QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
+ Query query;
+ try {
+ query = parser.parse( "name:emmanuel2" );
+ }
+ catch (ParseException e) {
+ throw new RuntimeException( e );
+ }
+ boolean results = fts.createFullTextQuery( query ).list().size() > 0;
+ //don't test because in case of async, it query happens before actual saving
+ //if ( !results ) throw new RuntimeException( "No results!" );
+ tx.commit();
+ s.close();
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ ee = (Employee) s.get( Employee.class, ee.getId() );
+ s.delete( ee );
+ er = (Employer) s.get( Employer.class, er.getId() );
+ s.delete( er );
+ tx.commit();
+ s.close();
+ count++;
+ }
+ }
+
+ protected static class ReverseWork implements Runnable {
+ private SessionFactory sf;
+
+ public ReverseWork(SessionFactory sf) {
+ this.sf = sf;
+ }
+
+ public void run() {
+ Session s = sf.openSession();
+ Transaction tx = s.beginTransaction();
+ Employer er = new Employer();
+ er.setName( "RH" );
+ s.persist( er );
+ Employee ee = new Employee();
+ ee.setName( "Emmanuel" );
+ s.persist( ee );
+ tx.commit();
+ s.close();
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ er = (Employer) s.get( Employer.class, er.getId() );
+ er.setName( "RH2" );
+ ee = (Employee) s.get( Employee.class, ee.getId() );
+ ee.setName( "Emmanuel2" );
+ tx.commit();
+ s.close();
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ er = (Employer) s.get( Employer.class, er.getId() );
+ s.delete( er );
+ ee = (Employee) s.get( Employee.class, ee.getId() );
+ s.delete( ee );
+ tx.commit();
+ s.close();
+ }
+ }
+
+ protected void configure(org.hibernate.cfg.Configuration cfg) {
+ super.configure( cfg );
+ File sub = getBaseIndexDir();
+ cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath() );
+ cfg.setProperty( "hibernate.search.Clock.directory_provider", FSDirectoryProvider.class.getName() );
+ cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
+ }
+
+ @SuppressWarnings("unchecked")
+ protected Class[] getMappings() {
+ return new Class[]{
+ Employee.class,
+ Employer.class
+ };
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/EmailAddress.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/EmailAddress.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/EmailAddress.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,57 +1,80 @@
-// $Id$
-package org.hibernate.search.test.worker.duplication;
-
-import java.io.Serializable;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Store;
-
-/**
- * Test entity for HSEARCH-257.
- *
- * @author Hardy Ferentschik
- */
-@Entity
-public class EmailAddress implements Serializable {
- @Id
- @GeneratedValue
- @DocumentId
- private int id;
-
- private boolean isDefaultAddress;
-
- @Field(store = Store.YES, index = Index.NO)
- private String address;
-
- public EmailAddress() {
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getAddress() {
- return address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
-
- public boolean isDefaultAddress() {
- return isDefaultAddress;
- }
-
- public void setDefaultAddress(boolean isDefault) {
- isDefaultAddress = isDefault;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.worker.duplication;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * Test entity for HSEARCH-257.
+ *
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class EmailAddress implements Serializable {
+ @Id
+ @GeneratedValue
+ @DocumentId
+ private int id;
+
+ private boolean isDefaultAddress;
+
+ @Field(store = Store.YES, index = Index.NO)
+ private String address;
+
+ public EmailAddress() {
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public boolean isDefaultAddress() {
+ return isDefaultAddress;
+ }
+
+ public void setDefaultAddress(boolean isDefault) {
+ isDefaultAddress = isDefault;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/Person.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/Person.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/Person.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,4 +1,27 @@
-// $Id$
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.worker.duplication;
import javax.persistence.DiscriminatorColumn;
Modified: search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/SpecialPerson.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/SpecialPerson.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/SpecialPerson.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,127 +1,150 @@
-// $Id$
-package org.hibernate.search.test.worker.duplication;
-
-import java.util.HashSet;
-import java.util.Set;
-import javax.persistence.CascadeType;
-import javax.persistence.DiscriminatorValue;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToMany;
-
-import org.hibernate.annotations.Cascade;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.IndexedEmbedded;
-
-/**
- * Test entity for HSEARCH-257.
- *
- * @author Hardy Ferentschik
- */
-@Entity
-@Indexed
-@DiscriminatorValue("SpecialPerson")
-public class SpecialPerson extends Person {
-
- @OneToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL })
- @Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
- @JoinColumn(name = "SPECIALPERSON_FK")
- @IndexedEmbedded
- private Set<EmailAddress> emailAddressSet = new HashSet<EmailAddress>();
-
- public Set<EmailAddress> getEmailAddressSet() {
- return emailAddressSet;
- }
-
- public void setEmailAddressSet(Set<EmailAddress> emailAddresses) {
- EmailAddress defaultVal = getDefaultEmailAddressFromList( emailAddresses );
-
- super.setDefaultEmailAddress( defaultVal );
-
- emailAddressSet = emailAddresses;
- }
-
- /**
- * This function add the provided emailAddress to the existing set.
- *
- * @param emailAddress EmailAddress to add the the set
- */
- public void addEmailAddress(EmailAddress emailAddress) {
- if ( emailAddress != null ) {
- if ( emailAddressSet == null ) {
- emailAddressSet = new HashSet<EmailAddress>();
- }
-
- // We cannot add another default address to the list. Check if
- // default
- // address has been set before.
- if ( emailAddress.isDefaultAddress() ) {
- // Replace old default address with new one.
- processDefaultEmailAddress( emailAddress, emailAddressSet );
-
- super.setDefaultEmailAddress( emailAddress );
- }
- else {
- emailAddressSet.add( emailAddress );
- }
- }
- }
-
- private void processDefaultEmailAddress(EmailAddress defaultVal,
- Set<EmailAddress> list) {
- if ( defaultVal != null ) {
- boolean addToList = true;
-
- for ( EmailAddress aList : list ) {
-
- if ( defaultVal.equals( aList ) ) {
- aList.setDefaultAddress( true );
- addToList = false;
- }
- else if ( aList.isDefaultAddress() ) {
- // Reset default value.
- aList.setDefaultAddress( false );
- }
- }
-
- // Add Email Address to the list if list does not contain it.
- if ( addToList ) {
- list.add( defaultVal );
- }
- }
- }
-
- private EmailAddress getDefaultEmailAddressFromList(
- Set<EmailAddress> list) {
- EmailAddress address = null;
- EmailAddress firstAddressInList = null;
- boolean found = false;
-
- if ( list != null ) {
- for ( EmailAddress aList : list ) {
- address = aList;
-
- if ( address != null ) {
- if ( firstAddressInList == null ) {
- firstAddressInList = address;
- }
-
- if ( address.isDefaultAddress() ) {
- found = true;
- break;
- }
- }
- }
-
- if ( !found && firstAddressInList != null ) {
- // If default address was not found we set the first one as
- // default.
- firstAddressInList.setDefaultAddress( true );
- address = firstAddressInList;
- }
- }
-
- return address;
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.worker.duplication;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.persistence.CascadeType;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
+
+import org.hibernate.annotations.Cascade;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
+
+/**
+ * Test entity for HSEARCH-257.
+ *
+ * @author Hardy Ferentschik
+ */
+@Entity
+@Indexed
+@DiscriminatorValue("SpecialPerson")
+public class SpecialPerson extends Person {
+
+ @OneToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL })
+ @Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
+ @JoinColumn(name = "SPECIALPERSON_FK")
+ @IndexedEmbedded
+ private Set<EmailAddress> emailAddressSet = new HashSet<EmailAddress>();
+
+ public Set<EmailAddress> getEmailAddressSet() {
+ return emailAddressSet;
+ }
+
+ public void setEmailAddressSet(Set<EmailAddress> emailAddresses) {
+ EmailAddress defaultVal = getDefaultEmailAddressFromList( emailAddresses );
+
+ super.setDefaultEmailAddress( defaultVal );
+
+ emailAddressSet = emailAddresses;
+ }
+
+ /**
+ * This function add the provided emailAddress to the existing set.
+ *
+ * @param emailAddress EmailAddress to add the the set
+ */
+ public void addEmailAddress(EmailAddress emailAddress) {
+ if ( emailAddress != null ) {
+ if ( emailAddressSet == null ) {
+ emailAddressSet = new HashSet<EmailAddress>();
+ }
+
+ // We cannot add another default address to the list. Check if
+ // default
+ // address has been set before.
+ if ( emailAddress.isDefaultAddress() ) {
+ // Replace old default address with new one.
+ processDefaultEmailAddress( emailAddress, emailAddressSet );
+
+ super.setDefaultEmailAddress( emailAddress );
+ }
+ else {
+ emailAddressSet.add( emailAddress );
+ }
+ }
+ }
+
+ private void processDefaultEmailAddress(EmailAddress defaultVal,
+ Set<EmailAddress> list) {
+ if ( defaultVal != null ) {
+ boolean addToList = true;
+
+ for ( EmailAddress aList : list ) {
+
+ if ( defaultVal.equals( aList ) ) {
+ aList.setDefaultAddress( true );
+ addToList = false;
+ }
+ else if ( aList.isDefaultAddress() ) {
+ // Reset default value.
+ aList.setDefaultAddress( false );
+ }
+ }
+
+ // Add Email Address to the list if list does not contain it.
+ if ( addToList ) {
+ list.add( defaultVal );
+ }
+ }
+ }
+
+ private EmailAddress getDefaultEmailAddressFromList(
+ Set<EmailAddress> list) {
+ EmailAddress address = null;
+ EmailAddress firstAddressInList = null;
+ boolean found = false;
+
+ if ( list != null ) {
+ for ( EmailAddress aList : list ) {
+ address = aList;
+
+ if ( address != null ) {
+ if ( firstAddressInList == null ) {
+ firstAddressInList = address;
+ }
+
+ if ( address.isDefaultAddress() ) {
+ found = true;
+ break;
+ }
+ }
+ }
+
+ if ( !found && firstAddressInList != null ) {
+ // If default address was not found we set the first one as
+ // default.
+ firstAddressInList.setDefaultAddress( true );
+ address = firstAddressInList;
+ }
+ }
+
+ return address;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/WorkDuplicationTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/WorkDuplicationTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/WorkDuplicationTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,137 +1,160 @@
-// $Id$
-package org.hibernate.search.test.worker.duplication;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.TopDocs;
-
-import org.hibernate.Transaction;
-import org.hibernate.search.FullTextQuery;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.backend.WorkType;
-import org.hibernate.search.backend.LuceneWork;
-import org.hibernate.search.backend.AddLuceneWork;
-import org.hibernate.search.backend.DeleteLuceneWork;
-import org.hibernate.search.engine.DocumentBuilderIndexedEntity;
-import org.hibernate.search.impl.SearchFactoryImpl;
-import org.hibernate.search.reader.ReaderProvider;
-import org.hibernate.search.store.DirectoryProvider;
-import org.hibernate.search.test.SearchTestCase;
-
-/**
- * Testcase for HSEARCH-257.
- */
-public class WorkDuplicationTest extends SearchTestCase {
-
- /**
- * This test assures that HSEARCH-257. Before the fix Search would issue another <code>AddLuceneWork</code> after
- * the <code>DeleteLuceneWork</code>. This lead to the fact that after the deletion there was still a Lucene document
- * in the index.
- *
- * @throws Exception in case the test fails.
- */
- public void testNoWorkDuplication() throws Exception {
-
- FullTextSession s = org.hibernate.search.Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
-
- // create new customer
- SpecialPerson person = new SpecialPerson();
- person.setName( "Joe Smith" );
-
- EmailAddress emailAddress = new EmailAddress();
- emailAddress.setAddress( "foo(a)foobar.com" );
- emailAddress.setDefaultAddress(true);
-
- person.addEmailAddress( emailAddress );
-
- // persist the customer
- s.persist( person );
- tx.commit();
-
- // search if the record made it into the index
- tx = s.beginTransaction();
- String searchQuery = "Joe";
- QueryParser parser = new QueryParser( "Content", new StandardAnalyzer() );
- Query luceneQuery = parser.parse( searchQuery );
- FullTextQuery query = s.createFullTextQuery( luceneQuery );
- List results = query.list();
- assertTrue( "We should have a hit", results.size() == 1 );
- tx.commit();
-
- // Now try to delete
- tx = s.beginTransaction();
- int id = person.getId();
- person = ( SpecialPerson ) s.get( SpecialPerson.class, id );
- s.delete( person );
- tx.commit();
-
- // Search and the record via Lucene directly
- tx = s.beginTransaction();
-
- DirectoryProvider directoryProvider = s.getSearchFactory().getDirectoryProviders( SpecialPerson.class )[0];
- ReaderProvider readerProvider = s.getSearchFactory().getReaderProvider();
- IndexReader reader = readerProvider.openReader( directoryProvider );
- IndexSearcher searcher = new IndexSearcher( reader );
-
- try {
- // we have to test using Lucene directly since query loaders will ignore hits for which there is no
- // database entry
- TopDocs topDocs = searcher.search( luceneQuery, null, 1 );
- assertTrue( "We should have no hit", topDocs.totalHits == 0 );
- }
- finally {
- readerProvider.closeReader( reader );
- }
- tx.commit();
- s.close();
- }
-
- /**
- * Tests that adding and deleting the same entity only results into a single delete in the work queue.
- * See HSEARCH-293.
- *
- * @throws Exception in case the test fails.
- */
- @SuppressWarnings( "unchecked" )
- public void testAddWorkGetReplacedByDeleteWork() throws Exception {
- FullTextSession fullTextSession = org.hibernate.search.Search.getFullTextSession( openSession() );
- SearchFactoryImpl searchFactory = ( SearchFactoryImpl ) fullTextSession.getSearchFactory();
- DocumentBuilderIndexedEntity builder = searchFactory.getDocumentBuilderIndexedEntity( SpecialPerson.class );
-
- // create test entity
- SpecialPerson person = new SpecialPerson();
- person.setName( "Joe Smith" );
-
- EmailAddress emailAddress = new EmailAddress();
- emailAddress.setAddress( "foo(a)foobar.com" );
- emailAddress.setDefaultAddress(true);
-
- person.addEmailAddress( emailAddress );
-
- List<LuceneWork> queue = new ArrayList<LuceneWork>();
-
- builder.addWorkToQueue( SpecialPerson.class, person, 1, WorkType.ADD, queue, searchFactory );
-
- assertEquals("There should only be one job in the queue", 1, queue.size());
- assertTrue("Wrong job type", queue.get(0) instanceof AddLuceneWork );
-
- builder.addWorkToQueue( SpecialPerson.class, person, 1, WorkType.DELETE, queue, searchFactory );
-
- assertEquals("There should only be one job in the queue", 1, queue.size());
- assertTrue("Wrong job type. Add job should have been replaced by delete.", queue.get(0) instanceof DeleteLuceneWork );
-
- fullTextSession.close();
- }
-
-
- protected Class[] getMappings() {
- return new Class[] { Person.class, EmailAddress.class, SpecialPerson.class };
- }
-}
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.worker.duplication;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.TopDocs;
+
+import org.hibernate.Transaction;
+import org.hibernate.search.FullTextQuery;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.backend.WorkType;
+import org.hibernate.search.backend.LuceneWork;
+import org.hibernate.search.backend.AddLuceneWork;
+import org.hibernate.search.backend.DeleteLuceneWork;
+import org.hibernate.search.engine.DocumentBuilderIndexedEntity;
+import org.hibernate.search.impl.SearchFactoryImpl;
+import org.hibernate.search.reader.ReaderProvider;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.test.SearchTestCase;
+
+/**
+ * Testcase for HSEARCH-257.
+ */
+public class WorkDuplicationTest extends SearchTestCase {
+
+ /**
+ * This test assures that HSEARCH-257. Before the fix Search would issue another <code>AddLuceneWork</code> after
+ * the <code>DeleteLuceneWork</code>. This lead to the fact that after the deletion there was still a Lucene document
+ * in the index.
+ *
+ * @throws Exception in case the test fails.
+ */
+ public void testNoWorkDuplication() throws Exception {
+
+ FullTextSession s = org.hibernate.search.Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+
+ // create new customer
+ SpecialPerson person = new SpecialPerson();
+ person.setName( "Joe Smith" );
+
+ EmailAddress emailAddress = new EmailAddress();
+ emailAddress.setAddress( "foo(a)foobar.com" );
+ emailAddress.setDefaultAddress(true);
+
+ person.addEmailAddress( emailAddress );
+
+ // persist the customer
+ s.persist( person );
+ tx.commit();
+
+ // search if the record made it into the index
+ tx = s.beginTransaction();
+ String searchQuery = "Joe";
+ QueryParser parser = new QueryParser( "Content", new StandardAnalyzer() );
+ Query luceneQuery = parser.parse( searchQuery );
+ FullTextQuery query = s.createFullTextQuery( luceneQuery );
+ List results = query.list();
+ assertTrue( "We should have a hit", results.size() == 1 );
+ tx.commit();
+
+ // Now try to delete
+ tx = s.beginTransaction();
+ int id = person.getId();
+ person = ( SpecialPerson ) s.get( SpecialPerson.class, id );
+ s.delete( person );
+ tx.commit();
+
+ // Search and the record via Lucene directly
+ tx = s.beginTransaction();
+
+ DirectoryProvider directoryProvider = s.getSearchFactory().getDirectoryProviders( SpecialPerson.class )[0];
+ ReaderProvider readerProvider = s.getSearchFactory().getReaderProvider();
+ IndexReader reader = readerProvider.openReader( directoryProvider );
+ IndexSearcher searcher = new IndexSearcher( reader );
+
+ try {
+ // we have to test using Lucene directly since query loaders will ignore hits for which there is no
+ // database entry
+ TopDocs topDocs = searcher.search( luceneQuery, null, 1 );
+ assertTrue( "We should have no hit", topDocs.totalHits == 0 );
+ }
+ finally {
+ readerProvider.closeReader( reader );
+ }
+ tx.commit();
+ s.close();
+ }
+
+ /**
+ * Tests that adding and deleting the same entity only results into a single delete in the work queue.
+ * See HSEARCH-293.
+ *
+ * @throws Exception in case the test fails.
+ */
+ @SuppressWarnings( "unchecked" )
+ public void testAddWorkGetReplacedByDeleteWork() throws Exception {
+ FullTextSession fullTextSession = org.hibernate.search.Search.getFullTextSession( openSession() );
+ SearchFactoryImpl searchFactory = ( SearchFactoryImpl ) fullTextSession.getSearchFactory();
+ DocumentBuilderIndexedEntity builder = searchFactory.getDocumentBuilderIndexedEntity( SpecialPerson.class );
+
+ // create test entity
+ SpecialPerson person = new SpecialPerson();
+ person.setName( "Joe Smith" );
+
+ EmailAddress emailAddress = new EmailAddress();
+ emailAddress.setAddress( "foo(a)foobar.com" );
+ emailAddress.setDefaultAddress(true);
+
+ person.addEmailAddress( emailAddress );
+
+ List<LuceneWork> queue = new ArrayList<LuceneWork>();
+
+ builder.addWorkToQueue( SpecialPerson.class, person, 1, WorkType.ADD, queue, searchFactory );
+
+ assertEquals("There should only be one job in the queue", 1, queue.size());
+ assertTrue("Wrong job type", queue.get(0) instanceof AddLuceneWork );
+
+ builder.addWorkToQueue( SpecialPerson.class, person, 1, WorkType.DELETE, queue, searchFactory );
+
+ assertEquals("There should only be one job in the queue", 1, queue.size());
+ assertTrue("Wrong job type. Add job should have been replaced by delete.", queue.get(0) instanceof DeleteLuceneWork );
+
+ fullTextSession.close();
+ }
+
+
+ protected Class[] getMappings() {
+ return new Class[] { Person.class, EmailAddress.class, SpecialPerson.class };
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/WorkSequencesTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/WorkSequencesTest.java 2009-10-06 09:21:51 UTC (rev 17629)
+++ search/trunk/src/test/java/org/hibernate/search/test/worker/duplication/WorkSequencesTest.java 2009-10-06 13:38:43 UTC (rev 17630)
@@ -1,3 +1,27 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.test.worker.duplication;
import java.io.IOException;
@@ -121,4 +145,4 @@
};
}
-}
\ No newline at end of file
+}
14 years, 7 months
Hibernate SVN: r17629 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/query.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-10-06 05:21:51 -0400 (Tue, 06 Oct 2009)
New Revision: 17629
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/query/Twilight.java
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/query/Darkness.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java
Log:
HHH-4364 add tests for superclasses
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/query/Darkness.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/query/Darkness.java 2009-10-06 08:18:12 UTC (rev 17628)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/query/Darkness.java 2009-10-06 09:21:51 UTC (rev 17629)
@@ -1,3 +1,27 @@
+//$Id: BasicHibernateAnnotationsTest.java 17531 2009-09-22 17:43:48Z epbernard $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.test.annotations.query;
import javax.persistence.MappedSuperclass;
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java 2009-10-06 08:18:12 UTC (rev 17628)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java 2009-10-06 09:21:51 UTC (rev 17629)
@@ -1,4 +1,27 @@
//$Id$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.test.annotations.query;
import java.util.Calendar;
@@ -111,13 +134,23 @@
s.close();
}
+
+ /**
+ * We are testing 2 things here:
+ * 1. The query 'night.olderThan' is defined in a MappedSuperClass - Darkness.
+ * We are verifying that queries defined in a MappedSuperClass are processed.
+ * 2. There are 2 Entity classes that extend from Darkness - Night and Twilight.
+ * We are verifying that this does not cause any issues.eg. Double processing of the
+ * MappedSuperClass
+ */
+
public void testImportQueryFromMappedSuperclass() {
Session s = openSession();
try {
s.getNamedQuery( "night.olderThan" );
}
catch(MappingException ex) {
- assertTrue("Query imported from MappedSuperclass", false);
+ fail("Query imported from MappedSuperclass");
}
s.close();
}
@@ -364,10 +397,12 @@
protected Class[] getMappings() {
return new Class[] {
+ Darkness.class,
Plane.class,
A320.class,
A320b.class,
Night.class,
+ Twilight.class,
Area.class,
SpaceShip.class,
Dictionary.class,
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/query/Twilight.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/query/Twilight.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/query/Twilight.java 2009-10-06 09:21:51 UTC (rev 17629)
@@ -0,0 +1,49 @@
+//$Id: BasicHibernateAnnotationsTest.java 17531 2009-09-22 17:43:48Z epbernard $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.query;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author Sharath Reddy
+ */
+@Entity
+public class Twilight extends Darkness {
+
+ private int id;
+
+ @Id
+ @GeneratedValue
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+}
14 years, 7 months
Hibernate SVN: r17628 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-10-06 04:18:12 -0400 (Tue, 06 Oct 2009)
New Revision: 17628
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/FormalLastName.java
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java
Log:
HHH-4232 add missing test
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java 2009-10-06 08:15:27 UTC (rev 17627)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java 2009-10-06 08:18:12 UTC (rev 17628)
@@ -1,4 +1,27 @@
//$Id$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.test.annotations.entity;
import java.math.BigDecimal;
@@ -143,19 +166,33 @@
}
- //Test import of TypeDefs from MappedSuperclass and
- //Embedded classes
+ /*
+ * Test import of TypeDefs from MappedSuperclass and
+ * Embedded classes.
+ * The classes 'Name' and 'FormalLastName' both embed the same
+ * component 'LastName'. This is to verify that processing the
+ * typedef defined in the component TWICE does not create any
+ * issues.
+ *
+ */
public void testImportTypeDefinitions() throws Exception {
+ LastName lastName = new LastName();
+ lastName.setName("reddy");
+
Name name = new Name();
name.setFirstName("SHARATH");
- LastName lastName = new LastName();
- lastName.setName("reddy");
name.setLastName(lastName);
+
+ FormalLastName formalName = new FormalLastName();
+ formalName.setLastName(lastName);
+ formalName.setDesignation("Mr");
+
Session s;
Transaction tx;
s = openSession();
tx = s.beginTransaction();
s.persist(name);
+ s.persist(formalName);
tx.commit();
s.close();
@@ -165,7 +202,12 @@
assertNotNull( name );
assertEquals( "sharath", name.getFirstName() );
assertEquals( "REDDY", name.getLastName().getName() );
+
+ formalName = (FormalLastName) s.get(FormalLastName.class, formalName.getId());
+ assertEquals( "REDDY", formalName.getLastName().getName() );
+
s.delete(name);
+ s.delete(formalName);
tx.commit();
s.close();
}
@@ -424,6 +466,7 @@
ZipCode.class,
Flight.class,
Name.class,
+ FormalLastName.class,
Car.class,
Peugot.class,
ContactDetails.class
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/FormalLastName.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/FormalLastName.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/FormalLastName.java 2009-10-06 08:18:12 UTC (rev 17628)
@@ -0,0 +1,71 @@
+//$Id: BasicHibernateAnnotationsTest.java 17531 2009-09-22 17:43:48Z epbernard $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.entity;
+
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author Sharath Reddy
+ */
+@Entity
+public class FormalLastName {
+
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ @Embedded
+ private LastName lastName;
+
+ private String designation; /* Mr/Mrs/Master */
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public LastName getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(LastName lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getDesignation() {
+ return designation;
+ }
+
+ public void setDesignation(String designation) {
+ this.designation = designation;
+ }
+
+}
14 years, 7 months
Hibernate SVN: r17627 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-10-06 04:15:27 -0400 (Tue, 06 Oct 2009)
New Revision: 17627
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/ContactDetails.java
Log:
HHH-3000 Allow a TypeDef to be associated with a class (Sharath Reddy)
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/ContactDetails.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/ContactDetails.java 2009-10-06 07:50:35 UTC (rev 17626)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/ContactDetails.java 2009-10-06 08:15:27 UTC (rev 17627)
@@ -4,7 +4,7 @@
* Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat, Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
14 years, 7 months
Hibernate SVN: r17626 - in core/trunk/annotations/src: main/java/org/hibernate/cfg and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-10-06 03:50:35 -0400 (Tue, 06 Oct 2009)
New Revision: 17626
Added:
core/trunk/annotations/src/main/java/org/hibernate/cfg/SetSimpleValueTypeSecondPass.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Car.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/ContactDetails.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/OverseasPhoneNumberType.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Peugot.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/PhoneNumber.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/PhoneNumberType.java
Modified:
core/trunk/annotations/src/main/java/org/hibernate/annotations/TypeDef.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/ExtendedMappings.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java
Log:
HHH-3000 Allow a TypeDef to be associated with a class (Sharath Reddy)
Modified: core/trunk/annotations/src/main/java/org/hibernate/annotations/TypeDef.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/annotations/TypeDef.java 2009-10-05 16:48:45 UTC (rev 17625)
+++ core/trunk/annotations/src/main/java/org/hibernate/annotations/TypeDef.java 2009-10-06 07:50:35 UTC (rev 17626)
@@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
@@ -37,9 +37,9 @@
@Target({TYPE, PACKAGE})
@Retention(RUNTIME)
public @interface TypeDef {
- String name();
-
- Class typeClass();
-
+ String name() default "";
+ Class<?> typeClass();
+ Class<?> defaultForType() default void.class;
+
Parameter[] parameters() default {};
}
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java 2009-10-05 16:48:45 UTC (rev 17625)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java 2009-10-06 07:50:35 UTC (rev 17626)
@@ -104,7 +104,6 @@
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.annotations.ManyToAny;
-import org.hibernate.annotations.MapKeyManyToMany;
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
@@ -137,7 +136,6 @@
import org.hibernate.cfg.annotations.SimpleValueBinder;
import org.hibernate.cfg.annotations.TableBinder;
import org.hibernate.cfg.annotations.MapKeyColumnDelegator;
-import org.hibernate.cfg.annotations.CustomizableColumns;
import org.hibernate.cfg.annotations.MapKeyJoinColumnDelegator;
import org.hibernate.engine.FilterDefinition;
import org.hibernate.engine.Versioning;
@@ -1005,10 +1003,24 @@
for (Parameter param : defAnn.parameters()) {
params.setProperty( param.name(), param.value() );
}
- log.info( "Binding type definition: {}", defAnn.name() );
- mappings.addTypeDef( defAnn.name(), defAnn.typeClass().getName(), params );
+
+ if (BinderHelper.isDefault(defAnn.name()) && defAnn.defaultForType().equals(void.class)) {
+ throw new AnnotationException("Both name and defaultForType attributes cannot be set in a TypeDef");
+ }
+ if (!BinderHelper.isDefault(defAnn.name())) {
+ log.info( "Binding type definition: {}", defAnn.name() );
+ mappings.addTypeDef( defAnn.name(), defAnn.typeClass().getName(), params );
+ }
+ else if (!defAnn.defaultForType().equals(void.class)) {
+ log.info( "Binding type definition: {}", defAnn.defaultForType().getName() );
+ mappings.addTypeDef( defAnn.defaultForType().getName(), defAnn.typeClass().getName(), params );
+ }
+ else {
+ throw new AnnotationException("Either name or defaultForType attribute should be set in a TypeDef");
+ }
}
-
+
+
private static void bindDiscriminatorToPersistentClass(
RootClass rootClass,
Ejb3DiscriminatorColumn discriminatorColumn, Map<String, Join> secondaryTables,
@@ -1365,12 +1377,13 @@
propBinder.setHolder( propertyHolder ); //PropertyHolderBuilder.buildPropertyHolder(rootClass)
propBinder.setProperty( property );
propBinder.setReturnedClass( inferredData.getPropertyClass() );
-
propBinder.setMappings( mappings );
+
Property prop = propBinder.bind();
+ propBinder.getSimpleValueBinder().setVersion(true);
rootClass.setVersion( prop );
+
SimpleValue simpleValue = (SimpleValue) prop.getValue();
- if ( !simpleValue.isTypeSpecified() ) simpleValue.setTypeName( "integer" );
simpleValue.setNullValue( "undefined" );
rootClass.setOptimisticLockMode( Versioning.OPTIMISTIC_LOCK_VERSION );
log.debug(
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java 2009-10-05 16:48:45 UTC (rev 17625)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java 2009-10-06 07:50:35 UTC (rev 17626)
@@ -283,7 +283,7 @@
AnnotationBinder.bindDefaults( createExtendedMappings() );
isDefaultProcessed = true;
}
-
+
//process entities
if ( precedence == null ) precedence = getProperties().getProperty( ARTEFACT );
if ( precedence == null ) precedence = DEFAULT_PRECEDENCE;
@@ -312,10 +312,19 @@
caches.clear();
try {
inSecondPass = true;
- processFkSecondPassInOrder();
Iterator iter = secondPasses.iterator();
while ( iter.hasNext() ) {
SecondPass sp = (SecondPass) iter.next();
+ //do the second pass of simple value types first and remove them
+ if ( sp instanceof SetSimpleValueTypeSecondPass ) {
+ sp.doSecondPass( classes );
+ iter.remove();
+ }
+ }
+ processFkSecondPassInOrder();
+ iter = secondPasses.iterator();
+ while ( iter.hasNext() ) {
+ SecondPass sp = (SecondPass) iter.next();
//do the second pass of fk before the others and remove them
if ( sp instanceof CreateKeySecondPass ) {
sp.doSecondPass( classes );
@@ -1111,6 +1120,11 @@
defaultNamedGenerators.add( generator.getName() );
}
+ public boolean isInSecondPass() {
+ return inSecondPass;
+ }
+
+
public IdGenerator getGenerator(String name) {
return getGenerator( name, null );
}
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/ExtendedMappings.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/ExtendedMappings.java 2009-10-05 16:48:45 UTC (rev 17625)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/ExtendedMappings.java 2009-10-06 07:50:35 UTC (rev 17626)
@@ -156,4 +156,7 @@
public void addAnyMetaDef(AnyMetaDef defAnn) throws AnnotationException;
public AnyMetaDef getAnyMetaDef(String name);
+
+ public boolean isInSecondPass();
+
}
\ No newline at end of file
Added: core/trunk/annotations/src/main/java/org/hibernate/cfg/SetSimpleValueTypeSecondPass.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/SetSimpleValueTypeSecondPass.java (rev 0)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/SetSimpleValueTypeSecondPass.java 2009-10-06 07:50:35 UTC (rev 17626)
@@ -0,0 +1,46 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.cfg;
+
+import java.util.Map;
+import org.hibernate.MappingException;
+import org.hibernate.cfg.annotations.SimpleValueBinder;
+
+/**
+ * @author Sharath Reddy
+ *
+ */
+public class SetSimpleValueTypeSecondPass implements SecondPass {
+
+ SimpleValueBinder binder;
+
+ public SetSimpleValueTypeSecondPass(SimpleValueBinder val) {
+ binder = val;
+ }
+
+ public void doSecondPass(Map persistentClasses) throws MappingException {
+ binder.fillSimpleValue();
+ }
+
+}
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java 2009-10-05 16:48:45 UTC (rev 17625)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java 2009-10-06 07:50:35 UTC (rev 17626)
@@ -61,6 +61,8 @@
private boolean insertable = true;
private boolean updatable = true;
private String cascade;
+ private SimpleValueBinder simpleValueBinder;
+
/*
* property can be null
* prefer propertyName to property.getName() since some are overloaded
@@ -133,15 +135,15 @@
String containerClassName = holder == null ?
null :
holder.getClassName();
- SimpleValueBinder value = new SimpleValueBinder();
- value.setMappings( mappings );
- value.setPropertyName( name );
- value.setReturnedClassName( returnedClassName );
- value.setColumns( columns );
- value.setPersistentClassName( containerClassName );
- value.setType( property, returnedClass );
- value.setMappings( mappings );
- SimpleValue propertyValue = value.make();
+ simpleValueBinder = new SimpleValueBinder();
+ simpleValueBinder.setMappings( mappings );
+ simpleValueBinder.setPropertyName( name );
+ simpleValueBinder.setReturnedClassName( returnedClassName );
+ simpleValueBinder.setColumns( columns );
+ simpleValueBinder.setPersistentClassName( containerClassName );
+ simpleValueBinder.setType( property, returnedClass );
+ simpleValueBinder.setMappings( mappings );
+ SimpleValue propertyValue = simpleValueBinder.make();
setValue( propertyValue );
Property prop = make();
holder.addProperty( prop, columns );
@@ -214,4 +216,9 @@
public void setReturnedClass(XClass returnedClass) {
this.returnedClass = returnedClass;
}
+
+ public SimpleValueBinder getSimpleValueBinder() {
+ return simpleValueBinder;
+ }
+
}
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java 2009-10-05 16:48:45 UTC (rev 17625)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java 2009-10-06 07:50:35 UTC (rev 17626)
@@ -42,6 +42,7 @@
import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.NotYetImplementedException;
+import org.hibernate.cfg.SetSimpleValueTypeSecondPass;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.type.ByteArrayBlobType;
@@ -68,7 +69,17 @@
private Properties typeParameters = new Properties();
private ExtendedMappings mappings;
private Table table;
+ private SimpleValue simpleValue;
+ private boolean isVersion;
+ public boolean isVersion() {
+ return isVersion;
+ }
+
+ public void setVersion(boolean isVersion) {
+ this.isVersion = isVersion;
+ }
+
public void setPropertyName(String propertyName) {
this.propertyName = propertyName;
}
@@ -216,7 +227,7 @@
public void setExplicitType(String explicitType) {
this.explicitType = explicitType;
}
-
+
//FIXME raise an assertion failure if setExplicitType(String) and setExplicitType(Type) are use at the same time
public void setExplicitType(Type typeAnn) {
if ( typeAnn != null ) {
@@ -238,16 +249,35 @@
}
public SimpleValue make() {
+
validate();
log.debug( "building SimpleValue for {}", propertyName );
if ( table == null ) {
table = columns[0].getTable();
}
- SimpleValue simpleValue = new SimpleValue( table );
- return fillSimpleValue( simpleValue );
+ simpleValue = new SimpleValue( table );
+
+ for (Ejb3Column column : columns) {
+ column.linkWithValue( simpleValue );
+ }
+
+ boolean isInSecondPass = mappings.isInSecondPass();
+ if (!isInSecondPass) {
+ //Defer this to the second pass
+ SetSimpleValueTypeSecondPass secondPass = new SetSimpleValueTypeSecondPass(this);
+ mappings.addSecondPass(secondPass);
+ }
+ else {
+ //We are already in second pass
+ fillSimpleValue();
+ }
+ return simpleValue;
}
- public SimpleValue fillSimpleValue(SimpleValue simpleValue) {
+ public void fillSimpleValue() {
+
+ log.debug( "setting SimpleValue typeName for {}", propertyName );
+
String type = BinderHelper.isDefault( explicitType ) ? returnedClassName : explicitType;
org.hibernate.mapping.TypeDef typeDef = mappings.getTypeDef( type );
if ( typeDef != null ) {
@@ -262,9 +292,10 @@
if ( persistentClassName != null ) {
simpleValue.setTypeUsingReflection( persistentClassName, propertyName );
}
- for (Ejb3Column column : columns) {
- column.linkWithValue( simpleValue );
+
+ if ( !simpleValue.isTypeSpecified() && isVersion()) {
+ simpleValue.setTypeName( "integer" );
}
- return simpleValue;
+
}
}
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java 2009-10-05 16:48:45 UTC (rev 17625)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java 2009-10-06 07:50:35 UTC (rev 17626)
@@ -158,7 +158,7 @@
s.persist(name);
tx.commit();
s.close();
-
+
s = openSession();
tx = s.beginTransaction();
name = (Name) s.get( Name.class, name.getId() );
@@ -341,6 +341,76 @@
tx.commit();
s.close();
}
+
+
+ /**
+ * We persist and retrieve properties of type 'PhoneNumber'. We set this type to delegate to
+ * the Hibernate UserType 'PhoneNumberType' for persistence and retrieval (with the 'defaultForType' attribute).
+ * However, we can also use the @TypeDef 'name' attribute and @Type annotation to over-ride this and
+ * delegate to OverseasPhoneNumberType.
+ *
+ */
+ public void testTypeDefsUsingNameAndDefaultForType() {
+
+ ContactDetails contactDetails = new ContactDetails();
+ contactDetails.setLocalPhoneNumber(new PhoneNumber("999999"));
+ contactDetails.setOverseasPhoneNumber(new PhoneNumber("111111"));
+
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist(contactDetails);
+ tx.commit();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+ contactDetails =
+ (ContactDetails) s.get( ContactDetails.class, contactDetails.getId() );
+ assertNotNull( contactDetails );
+ assertEquals( "999999", contactDetails.getLocalPhoneNumber().getNumber() );
+ assertEquals( "041111111", contactDetails.getOverseasPhoneNumber().getNumber() );
+ s.delete(contactDetails);
+ tx.commit();
+ s.close();
+
+
+
+ }
+
+
+
+ /**
+ * A custom type is used in the base class, but defined in the derived class.
+ * This would have caused an exception, because the base class is processed
+ * BEFORE the derived class, and the custom type is not yet defined. However,
+ * it works now because we are setting the typeName for SimpleValue in the second
+ * pass.
+ *
+ *
+ * @throws Exception
+ */
+ public void testSetSimpleValueTypeNameInSecondPass() throws Exception {
+ Peugot derived = new Peugot();
+ derived.setName("sharath");
+
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ s.persist(derived);
+ tx.commit();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+ derived = (Peugot) s.get( Peugot.class, derived.getId() );
+ assertNotNull( derived );
+ assertEquals( "SHARATH", derived.getName() );
+ s.delete(derived);
+ tx.commit();
+ s.close();
+ }
+
public BasicHibernateAnnotationsTest(String x) {
super( x );
@@ -353,7 +423,10 @@
Ransom.class,
ZipCode.class,
Flight.class,
- Name.class
+ Name.class,
+ Car.class,
+ Peugot.class,
+ ContactDetails.class
};
}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Car.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Car.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Car.java 2009-10-06 07:50:35 UTC (rev 17626)
@@ -0,0 +1,58 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.test.annotations.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import org.hibernate.annotations.Type;
+
+
+/**
+ * Uses a custom type which is defined in a subclass
+ * @author Sharath Reddy
+ */
+@Entity
+public class Car {
+
+ @Id
+ @GeneratedValue
+ private int id;
+ @Type(type="definedInDerivedClass")
+ private String name;
+ public int getId() {
+ return id;
+ }
+ public void setId(int id) {
+ this.id = id;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/ContactDetails.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/ContactDetails.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/ContactDetails.java 2009-10-06 07:50:35 UTC (rev 17626)
@@ -0,0 +1,89 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.annotations.Type;
+import org.hibernate.annotations.TypeDef;
+import org.hibernate.annotations.TypeDefs;
+
+
+@TypeDefs(
+ {
+ @TypeDef(
+ name = "overseasPhoneNumber",
+ typeClass = OverseasPhoneNumberType.class
+
+ ),
+ @TypeDef(
+ defaultForType = PhoneNumber.class,
+ typeClass = PhoneNumberType.class
+
+ )
+ }
+)
+
+/**
+ * @author Sharath Reddy
+ *
+ */
+@Entity
+public class ContactDetails {
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ private PhoneNumber localPhoneNumber;
+ @Type(type="overseasPhoneNumber")
+ private PhoneNumber overseasPhoneNumber;
+
+ public int getId() {
+ return id;
+ }
+ public void setId(int id) {
+ this.id = id;
+ }
+ public PhoneNumber getLocalPhoneNumber() {
+ return localPhoneNumber;
+ }
+ public void setLocalPhoneNumber(PhoneNumber localPhoneNumber) {
+ this.localPhoneNumber = localPhoneNumber;
+ }
+ public PhoneNumber getOverseasPhoneNumber() {
+ return overseasPhoneNumber;
+ }
+ public void setOverseasPhoneNumber(PhoneNumber overseasPhoneNumber) {
+ this.overseasPhoneNumber = overseasPhoneNumber;
+ }
+
+
+
+
+
+
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/OverseasPhoneNumberType.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/OverseasPhoneNumberType.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/OverseasPhoneNumberType.java 2009-10-06 07:50:35 UTC (rev 17626)
@@ -0,0 +1,98 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.entity;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import org.hibernate.HibernateException;
+import org.hibernate.usertype.UserType;
+
+/**
+ * Used to persist and retrieve objects of type 'PhoneNumber'
+ *
+ * @author Sharath Reddy
+ */
+public class OverseasPhoneNumberType implements UserType {
+
+ public int[] sqlTypes() {
+ return new int[]{Types.VARCHAR};
+ }
+
+ public Class returnedClass() {
+ return PhoneNumber.class;
+ }
+
+ public boolean equals(Object x, Object y) throws HibernateException {
+ return ( x == y ) || ( x != null && x.equals( y ) );
+ }
+
+ public int hashCode(Object x) throws HibernateException {
+ return x.hashCode();
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
+ String result = rs.getString( names[0] );
+ if ( rs.wasNull() ) return null;
+ return new PhoneNumber(result);
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
+ if ( value == null ) {
+ st.setNull( index, sqlTypes()[0] );
+ }
+ else {
+ PhoneNumber phoneNumber = (PhoneNumber) value;
+ st.setString( index, getCountryCode() + phoneNumber.getNumber() );
+ }
+ }
+
+
+ private String getCountryCode() {
+ return "041";
+ }
+
+ public Object deepCopy(Object value) throws HibernateException {
+ return value;
+ }
+
+ public boolean isMutable() {
+ return false;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException {
+ return (Serializable) value;
+ }
+
+ public Object assemble(Serializable cached, Object owner) throws HibernateException {
+ return cached;
+ }
+
+ public Object replace(Object original, Object target, Object owner) throws HibernateException {
+ return original;
+ }
+
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Peugot.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Peugot.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Peugot.java 2009-10-06 07:50:35 UTC (rev 17626)
@@ -0,0 +1,48 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.entity;
+
+import javax.persistence.Entity;
+
+import org.hibernate.annotations.Parameter;
+import org.hibernate.annotations.TypeDef;
+
+@TypeDef(
+ name = "definedInDerivedClass",
+ typeClass = CasterStringType.class,
+ parameters = {
+ @Parameter(name = "cast", value = "upper")
+ }
+)
+
+/**
+ * Defines a custom type that is used in the
+ * base class.
+ * @author Sharath Reddy
+ *
+ */
+@Entity
+public class Peugot extends Car {
+
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/PhoneNumber.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/PhoneNumber.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/PhoneNumber.java 2009-10-06 07:50:35 UTC (rev 17626)
@@ -0,0 +1,42 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.entity;
+
+public class PhoneNumber {
+
+ private String number;
+
+ public PhoneNumber(String val) {
+ number = val;
+ }
+
+ public String getNumber() {
+ return number;
+ }
+
+ public void setNumber(String number) {
+ this.number = number;
+ }
+
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/PhoneNumberType.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/PhoneNumberType.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/PhoneNumberType.java 2009-10-06 07:50:35 UTC (rev 17626)
@@ -0,0 +1,93 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.entity;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import org.hibernate.HibernateException;
+import org.hibernate.usertype.UserType;
+
+/**
+ * Used to persist and retrieve objects of type 'PhoneNumber'
+ *
+ * @author Sharath Reddy
+ */
+public class PhoneNumberType implements UserType {
+
+ public int[] sqlTypes() {
+ return new int[]{Types.VARCHAR};
+ }
+
+ public Class returnedClass() {
+ return PhoneNumber.class;
+ }
+
+ public boolean equals(Object x, Object y) throws HibernateException {
+ return ( x == y ) || ( x != null && x.equals( y ) );
+ }
+
+ public int hashCode(Object x) throws HibernateException {
+ return x.hashCode();
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
+ String result = rs.getString( names[0] );
+ if ( rs.wasNull() ) return null;
+ return new PhoneNumber(result);
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
+ if ( value == null ) {
+ st.setNull( index, sqlTypes()[0] );
+ }
+ else {
+ PhoneNumber phoneNumber = (PhoneNumber) value;
+ st.setString( index, phoneNumber.getNumber() );
+ }
+ }
+
+ public Object deepCopy(Object value) throws HibernateException {
+ return value;
+ }
+
+ public boolean isMutable() {
+ return false;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException {
+ return (Serializable) value;
+ }
+
+ public Object assemble(Serializable cached, Object owner) throws HibernateException {
+ return cached;
+ }
+
+ public Object replace(Object original, Object target, Object owner) throws HibernateException {
+ return original;
+ }
+
+}
14 years, 7 months
Hibernate SVN: r17625 - in beanvalidation/api/trunk/src/main/java/javax/validation: metadata and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-10-05 12:48:45 -0400 (Mon, 05 Oct 2009)
New Revision: 17625
Modified:
beanvalidation/api/trunk/src/main/java/javax/validation/Validator.java
beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java
Log:
Enhance JavaDoc
Modified: beanvalidation/api/trunk/src/main/java/javax/validation/Validator.java
===================================================================
--- beanvalidation/api/trunk/src/main/java/javax/validation/Validator.java 2009-10-05 15:33:16 UTC (rev 17624)
+++ beanvalidation/api/trunk/src/main/java/javax/validation/Validator.java 2009-10-05 16:48:45 UTC (rev 17625)
@@ -95,7 +95,7 @@
* The returned object (and associated objects including
* <code>ConstraintDescriptor<code>s) are immutable.
*
- * @param clazz class type evaluated
+ * @param clazz class or interface type evaluated
*
* @return the bean descriptor for the specified class.
*
Modified: beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java
===================================================================
--- beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java 2009-10-05 15:33:16 UTC (rev 17624)
+++ beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java 2009-10-05 16:48:45 UTC (rev 17625)
@@ -117,7 +117,5 @@
* @return is there any constraint
*/
boolean hasConstraints();
-
}
-
-}
+}
\ No newline at end of file
14 years, 7 months
Hibernate SVN: r17624 - beanvalidation/api/trunk/src/main/java/javax/validation/metadata.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-10-05 11:33:16 -0400 (Mon, 05 Oct 2009)
New Revision: 17624
Modified:
beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java
Log:
Enhance JavaDoc
Modified: beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java
===================================================================
--- beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java 2009-10-05 14:39:55 UTC (rev 17623)
+++ beanvalidation/api/trunk/src/main/java/javax/validation/metadata/ElementDescriptor.java 2009-10-05 15:33:16 UTC (rev 17624)
@@ -29,8 +29,8 @@
public interface ElementDescriptor {
/**
- * @return <code>true</code> if at least one constraint declaration is
- * present on the element, <code>false</code> otherwise.
+ * Return <code>true</code> if at least one constraint declaration is present
+ * for this element in the class hierarchy, <code>false</code> otherwise.
*/
boolean hasConstraints();
@@ -40,8 +40,8 @@
Class<?> getElementClass();
/**
- * Return all constraint descriptors for this element or an
- * empty <code>Set</code> if none are present.
+ * Return all constraint descriptors for this element in the class hierarchy
+ * or an empty <code>Set</code> if none are present.
*
* @return <code>Set</code> of constraint descriptors for this element
*/
14 years, 7 months