org.hibernate.search.impl
Class ImmutableSearchFactory

java.lang.Object
  extended by org.hibernate.search.impl.ImmutableSearchFactory
All Implemented Interfaces:
SearchFactoryImplementor, SearchFactory, BuildContext, SearchFactoryImplementorWithShareableState, SearchFactoryState, SearchFactoryIntegrator, WorkerBuildContext

public class ImmutableSearchFactory
extends Object
implements SearchFactoryImplementorWithShareableState, WorkerBuildContext

This implementation is never directly exposed to the user, it is always wrapped into a MutableSearchFactory

Author:
Emmanuel Bernard

Constructor Summary
ImmutableSearchFactory(SearchFactoryState state)
           
 
Method Summary
 void addClasses(Class<?>... classes)
          Add the following classes to the SearchFactory.
 QueryContextBuilder buildQueryBuilder()
           
 void close()
           
 HSQuery createHSQuery()
          Return an Hibernate Search query object.
 IndexManagerHolder getAllIndexesManager()
           
 org.apache.lucene.analysis.Analyzer getAnalyzer(Class<?> clazz)
          Retrieves the scoped analyzer for a given class.
 org.apache.lucene.analysis.Analyzer getAnalyzer(String name)
          Retrieve an analyzer instance by its definition name
 Map<String,org.apache.lucene.analysis.Analyzer> getAnalyzers()
           
 int getCacheBitResultsSize()
           
 Properties getConfigurationProperties()
           
 TimeoutExceptionFactory getDefaultTimeoutExceptionFactory()
           
<T> DocumentBuilderContainedEntity<T>
getDocumentBuilderContainedEntity(Class<T> entityType)
           
 Map<Class<?>,DocumentBuilderContainedEntity<?>> getDocumentBuildersContainedEntities()
           
 ErrorHandler getErrorHandler()
          Used to catch exceptions in all synchronous operations; but default they are logged, the user can configure alternative error management means.
 int getFilterCacheBitResultsSize()
           
 FilterCachingStrategy getFilterCachingStrategy()
           
 FilterDef getFilterDefinition(String name)
           
 Map<String,FilterDef> getFilterDefinitions()
           
 Map<Class<?>,EntityIndexBinder> getIndexBindingForEntity()
           
 EntityIndexBinder getIndexBindingForEntity(Class<?> entityType)
           
 Set<Class<?>> getIndexedTypesPolymorphic(Class<?>[] classes)
           
 PolymorphicIndexHierarchy getIndexHierarchy()
           
 String getIndexingStrategy()
           
 IndexReaderAccessor getIndexReaderAccessor()
          Provides access to the IndexReader API
 InstanceInitializer getInstanceInitializer()
           
 SearchMapping getProgrammaticMapping()
           
 EntityIndexBinder getSafeIndexBindingForEntity(Class<?> entityType)
           
 ServiceManager getServiceManager()
           
 Statistics getStatistics()
          Retrieve the statistics instance for this factory.
 StatisticsImplementor getStatisticsImplementor()
          Retrieve the statistics implementor instance for this factory.
 TimingSource getTimingSource()
           
 SearchFactoryImplementor getUninitializedSearchFactory()
          Returns the SessionFactoryImplementor instance.
 Worker getWorker()
           
 boolean isDirtyChecksEnabled()
           
 boolean isIndexMetadataComplete()
           
 boolean isJMXEnabled()
           
 boolean isStopped()
           
 boolean isTransactionManagerExpected()
           
 BatchBackend makeBatchBackend(MassIndexerProgressMonitor progressMonitor)
           
 void optimize()
          Optimize all indexes
 void optimize(Class entityType)
          Optimize the index holding entityType
 void releaseService(Class<? extends ServiceProvider<?>> provider)
          Release a service from duty.
<T> T
requestService(Class<? extends ServiceProvider<T>> provider)
          Declare the use of a service.
 void setBackendQueueProcessor(BackendQueueProcessor backendQueueProcessor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImmutableSearchFactory

public ImmutableSearchFactory(SearchFactoryState state)
Method Detail

getFilterDefinitions

public Map<String,FilterDef> getFilterDefinitions()
Specified by:
getFilterDefinitions in interface SearchFactoryState

getIndexingStrategy

public String getIndexingStrategy()
Specified by:
getIndexingStrategy in interface SearchFactoryImplementor
Specified by:
getIndexingStrategy in interface BuildContext
Specified by:
getIndexingStrategy in interface SearchFactoryState

close

public void close()
Specified by:
close in interface SearchFactoryIntegrator

createHSQuery

public HSQuery createHSQuery()
Description copied from interface: SearchFactoryIntegrator
Return an Hibernate Search query object. This object uses fluent APIs to define the query executed. Offers a few execution approaches: - return the list of results eagerly - return the list of results lazily - get the number of results

Specified by:
createHSQuery in interface SearchFactoryIntegrator

getDocumentBuildersContainedEntities

public Map<Class<?>,DocumentBuilderContainedEntity<?>> getDocumentBuildersContainedEntities()
Specified by:
getDocumentBuildersContainedEntities in interface SearchFactoryState

getIndexBindingForEntity

public Map<Class<?>,EntityIndexBinder> getIndexBindingForEntity()
Specified by:
getIndexBindingForEntity in interface SearchFactoryImplementor
Specified by:
getIndexBindingForEntity in interface SearchFactoryState

getIndexBindingForEntity

public EntityIndexBinder getIndexBindingForEntity(Class<?> entityType)
Specified by:
getIndexBindingForEntity in interface SearchFactoryIntegrator

getDocumentBuilderContainedEntity

public <T> DocumentBuilderContainedEntity<T> getDocumentBuilderContainedEntity(Class<T> entityType)
Specified by:
getDocumentBuilderContainedEntity in interface SearchFactoryImplementor

addClasses

public void addClasses(Class<?>... classes)
Description copied from interface: SearchFactoryIntegrator
Add the following classes to the SearchFactory. If these classes are new to the SearchFactory this will trigger a reconfiguration.

Specified by:
addClasses in interface SearchFactoryIntegrator

getWorker

public Worker getWorker()
Specified by:
getWorker in interface SearchFactoryState
Specified by:
getWorker in interface SearchFactoryIntegrator

setBackendQueueProcessor

public void setBackendQueueProcessor(BackendQueueProcessor backendQueueProcessor)

optimize

public void optimize()
Description copied from interface: SearchFactory
Optimize all indexes

Specified by:
optimize in interface SearchFactory

optimize

public void optimize(Class entityType)
Description copied from interface: SearchFactory
Optimize the index holding entityType

Specified by:
optimize in interface SearchFactory
Parameters:
entityType - the entity type (index) to optimize

getAnalyzer

public org.apache.lucene.analysis.Analyzer getAnalyzer(String name)
Description copied from interface: SearchFactory
Retrieve an analyzer instance by its definition name

Specified by:
getAnalyzer in interface SearchFactory
Parameters:
name - the name of the analyzer
Returns:
analyzer with the specified name

getAnalyzer

public org.apache.lucene.analysis.Analyzer getAnalyzer(Class<?> clazz)
Description copied from interface: SearchFactory
Retrieves the scoped analyzer for a given class.

Specified by:
getAnalyzer in interface SearchFactory
Parameters:
clazz - The class for which to retrieve the analyzer.
Returns:
The scoped analyzer for the specified class.

buildQueryBuilder

public QueryContextBuilder buildQueryBuilder()
Specified by:
buildQueryBuilder in interface SearchFactory
Returns:
return a query builder providing a fluent API to create Lucene queries

getStatistics

public Statistics getStatistics()
Description copied from interface: SearchFactory
Retrieve the statistics instance for this factory.

Specified by:
getStatistics in interface SearchFactory
Returns:
The statistics.

getStatisticsImplementor

public StatisticsImplementor getStatisticsImplementor()
Description copied from interface: SearchFactoryImplementor
Retrieve the statistics implementor instance for this factory.

Specified by:
getStatisticsImplementor in interface SearchFactoryImplementor
Returns:
The statistics implementor.

getFilterCachingStrategy

public FilterCachingStrategy getFilterCachingStrategy()
Specified by:
getFilterCachingStrategy in interface SearchFactoryImplementor
Specified by:
getFilterCachingStrategy in interface SearchFactoryState

getAnalyzers

public Map<String,org.apache.lucene.analysis.Analyzer> getAnalyzers()
Specified by:
getAnalyzers in interface SearchFactoryState

getCacheBitResultsSize

public int getCacheBitResultsSize()
Specified by:
getCacheBitResultsSize in interface SearchFactoryState

getConfigurationProperties

public Properties getConfigurationProperties()
Specified by:
getConfigurationProperties in interface SearchFactoryState

getFilterDefinition

public FilterDef getFilterDefinition(String name)
Specified by:
getFilterDefinition in interface SearchFactoryImplementor

requestService

public <T> T requestService(Class<? extends ServiceProvider<T>> provider)
Description copied from interface: BuildContext
Declare the use of a service. All callers of this method must call (@link #releaseService} or the service will not be released

Specified by:
requestService in interface BuildContext
Type Parameters:
T - class of the service
Parameters:
provider - of the service
Returns:
the service instance

releaseService

public void releaseService(Class<? extends ServiceProvider<?>> provider)
Description copied from interface: BuildContext
Release a service from duty. Each call to (@link #requestService} should be coupled with a call to (@link #releaseService} when the service is no longer needed.

Specified by:
releaseService in interface BuildContext
Parameters:
provider - of the service

getFilterCacheBitResultsSize

public int getFilterCacheBitResultsSize()
Specified by:
getFilterCacheBitResultsSize in interface SearchFactoryImplementor

getIndexedTypesPolymorphic

public Set<Class<?>> getIndexedTypesPolymorphic(Class<?>[] classes)
Specified by:
getIndexedTypesPolymorphic in interface SearchFactoryImplementor

makeBatchBackend

public BatchBackend makeBatchBackend(MassIndexerProgressMonitor progressMonitor)
Specified by:
makeBatchBackend in interface SearchFactoryImplementor

getIndexHierarchy

public PolymorphicIndexHierarchy getIndexHierarchy()
Specified by:
getIndexHierarchy in interface SearchFactoryState

getServiceManager

public ServiceManager getServiceManager()
Specified by:
getServiceManager in interface SearchFactoryState

getUninitializedSearchFactory

public SearchFactoryImplementor getUninitializedSearchFactory()
Description copied from interface: BuildContext
Returns the SessionFactoryImplementor instance. Do not use until after the initialize and/or start method is fully executed. Implementations should not cache values provided by the SessionFactoryImplementor but rather access them each time: when the configuration is dynamically updated, new changes are available through the SearchFactoryImplementor For example, prefer void method() { int size = sfi.getDirectoryProviders().size(); } to void method() { int size = directoryProviders.size(); } where directoryProviders is a class variable.

Specified by:
getUninitializedSearchFactory in interface BuildContext

isJMXEnabled

public boolean isJMXEnabled()
Specified by:
isJMXEnabled in interface SearchFactoryImplementor

isDirtyChecksEnabled

public boolean isDirtyChecksEnabled()
Specified by:
isDirtyChecksEnabled in interface SearchFactoryImplementor
Returns:
true if we are allowed to inspect entity state to potentially skip some indexing operations. Can be disabled to get pre-3.4 behavior (always rebuild document)

isStopped

public boolean isStopped()
Specified by:
isStopped in interface SearchFactoryIntegrator
Returns:
true if the SearchFactory was stopped

isTransactionManagerExpected

public boolean isTransactionManagerExpected()
Specified by:
isTransactionManagerExpected in interface SearchFactoryState
Specified by:
isTransactionManagerExpected in interface WorkerBuildContext
Returns:
true if a transaction manager is expected, false otherwise.
See Also:
SearchConfiguration.isTransactionManagerExpected()

getAllIndexesManager

public IndexManagerHolder getAllIndexesManager()
Specified by:
getAllIndexesManager in interface SearchFactoryImplementor
Specified by:
getAllIndexesManager in interface BuildContext
Specified by:
getAllIndexesManager in interface SearchFactoryState
Returns:
a reference to the IndexManagerHolder, storing all IndexManager instances.

getSafeIndexBindingForEntity

public EntityIndexBinder getSafeIndexBindingForEntity(Class<?> entityType)

getErrorHandler

public ErrorHandler getErrorHandler()
Description copied from interface: SearchFactoryIntegrator
Used to catch exceptions in all synchronous operations; but default they are logged, the user can configure alternative error management means.

Specified by:
getErrorHandler in interface BuildContext
Specified by:
getErrorHandler in interface SearchFactoryState
Specified by:
getErrorHandler in interface SearchFactoryIntegrator
Returns:
the configured ErrorHandler, global to the SearchFactory

getIndexReaderAccessor

public IndexReaderAccessor getIndexReaderAccessor()
Description copied from interface: SearchFactory
Provides access to the IndexReader API

Specified by:
getIndexReaderAccessor in interface SearchFactory
Returns:
the IndexReaderAccessor for this SearchFactory

getInstanceInitializer

public InstanceInitializer getInstanceInitializer()
Specified by:
getInstanceInitializer in interface SearchFactoryImplementor
Specified by:
getInstanceInitializer in interface SearchFactoryState
Specified by:
getInstanceInitializer in interface WorkerBuildContext
Returns:
returns an instance of InstanceInitializer for class/object initialization.

getDefaultTimeoutExceptionFactory

public TimeoutExceptionFactory getDefaultTimeoutExceptionFactory()
Specified by:
getDefaultTimeoutExceptionFactory in interface SearchFactoryState
Specified by:
getDefaultTimeoutExceptionFactory in interface SearchFactoryIntegrator

getTimingSource

public TimingSource getTimingSource()
Specified by:
getTimingSource in interface SearchFactoryImplementor
Specified by:
getTimingSource in interface SearchFactoryState

getProgrammaticMapping

public SearchMapping getProgrammaticMapping()
Specified by:
getProgrammaticMapping in interface SearchFactoryState

isIndexMetadataComplete

public boolean isIndexMetadataComplete()
Specified by:
isIndexMetadataComplete in interface SearchFactoryState
Specified by:
isIndexMetadataComplete in interface WorkerBuildContext
Returns:
true if it is safe to assume that the information we have about index metadata is accurate. This should be set to false for example if the index could contain Documents related to types not known to this SearchFactory instance.
See Also:
org.hibernate.search.cfg.spi.SearchConfiguration#isIndexMetadateComplete


Copyright © 2006-2012 Red Hat Middleware, LLC. All Rights Reserved