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.
 Analyzer getAnalyzer(Class<?> clazz)
          Retrieves the scoped analyzer for a given class.
 Analyzer getAnalyzer(String name)
          Retrieve an analyzer instance by its definition name
 Map<String,Analyzer> getAnalyzers()
           
 BackendQueueProcessorFactory getBackendQueueProcessorFactory()
           
 int getCacheBitResultsSize()
           
 Set<Class<?>> getClassesInDirectoryProvider(DirectoryProvider<?> directoryProvider)
           
 Properties getConfigurationProperties()
           
 Map<DirectoryProvider<?>,DirectoryProviderData> getDirectoryProviderData()
           
 DirectoryProviderData getDirectoryProviderData(DirectoryProvider<?> provider)
           
 Map<DirectoryProvider,LuceneIndexingParameters> getDirectoryProviderIndexingParams()
           
 ReentrantLock getDirectoryProviderLock(DirectoryProvider<?> dp)
          This method cannot be used in initialize methods.
 Set<DirectoryProvider<?>> getDirectoryProviders()
           
 DirectoryProvider[] getDirectoryProviders(Class<?> entity)
          Provide access to the DirectoryProviders for a given entity.
<T> DocumentBuilderContainedEntity<T>
getDocumentBuilderContainedEntity(Class<T> entityType)
           
<T> DocumentBuilderIndexedEntity<T>
getDocumentBuilderIndexedEntity(Class<T> entityType)
           
 Map<Class<?>,DocumentBuilderContainedEntity<?>> getDocumentBuildersContainedEntities()
           
 Map<Class<?>,DocumentBuilderIndexedEntity<?>> getDocumentBuildersIndexedEntities()
           
 ErrorHandler getErrorHandler()
           
 int getFilterCacheBitResultsSize()
           
 FilterCachingStrategy getFilterCachingStrategy()
           
 FilterDef getFilterDefinition(String name)
           
 Map<String,FilterDef> getFilterDefinitions()
           
 Set<Class<?>> getIndexedTypesPolymorphic(Class<?>[] classes)
           
 PolymorphicIndexHierarchy getIndexHierarchy()
           
 LuceneIndexingParameters getIndexingParameters(DirectoryProvider<?> provider)
           
 String getIndexingStrategy()
           
 OptimizerStrategy getOptimizerStrategy(DirectoryProvider<?> provider)
           
 ReaderProvider getReaderProvider()
           
 ServiceManager getServiceManager()
           
 Similarity getSimilarity(DirectoryProvider<?> provider)
           
 Statistics getStatistics()
          Retrieve the statistics instance for this factory.
 StatisticsImplementor getStatisticsImplementor()
          Retrieve the statistics implementor instance for this factory.
 SearchFactoryImplementor getUninitializedSearchFactory()
          Returns the SessionFactoryImplementor instance.
 Worker getWorker()
           
 boolean isDirtyChecksEnabled()
           
 boolean isJMXEnabled()
           
 boolean isStopped()
           
 BatchBackend makeBatchBackend(MassIndexerProgressMonitor progressMonitor, Integer forceToNumWriterThreads)
           
 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 setBackendQueueProcessorFactory(BackendQueueProcessorFactory backendQueueProcessorFactory)
          Register the backend queue processor factory.
 
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

getBackendQueueProcessorFactory

public BackendQueueProcessorFactory getBackendQueueProcessorFactory()
Specified by:
getBackendQueueProcessorFactory in interface SearchFactoryImplementor
Specified by:
getBackendQueueProcessorFactory in interface SearchFactoryState

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

getClassesInDirectoryProvider

public Set<Class<?>> getClassesInDirectoryProvider(DirectoryProvider<?> directoryProvider)
Specified by:
getClassesInDirectoryProvider in interface SearchFactoryImplementor
Specified by:
getClassesInDirectoryProvider in interface WorkerBuildContext

getDocumentBuildersContainedEntities

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

getDirectoryProviderData

public Map<DirectoryProvider<?>,DirectoryProviderData> getDirectoryProviderData()
Specified by:
getDirectoryProviderData in interface SearchFactoryState

getDocumentBuildersIndexedEntities

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

getDocumentBuilderIndexedEntity

public <T> DocumentBuilderIndexedEntity<T> getDocumentBuilderIndexedEntity(Class<T> entityType)
Specified by:
getDocumentBuilderIndexedEntity in interface SearchFactoryImplementor
Specified by:
getDocumentBuilderIndexedEntity in interface WorkerBuildContext

getDocumentBuilderContainedEntity

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

getDirectoryProviders

public Set<DirectoryProvider<?>> getDirectoryProviders()
Specified by:
getDirectoryProviders in interface SearchFactoryImplementor
Specified by:
getDirectoryProviders in interface BuildContext

addClasses

public void addClasses(Class<?>... classes)
Description copied from interface: SearchFactoryIntegrator
Add the following classes to the SearchFactory

Specified by:
addClasses in interface SearchFactoryIntegrator

getWorker

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

setBackendQueueProcessorFactory

public void setBackendQueueProcessorFactory(BackendQueueProcessorFactory backendQueueProcessorFactory)
Description copied from interface: WorkerBuildContext
Register the backend queue processor factory. Should only be called by the Worker implementation. TODO should we move it to a different interface

Specified by:
setBackendQueueProcessorFactory in interface SearchFactoryState
Specified by:
setBackendQueueProcessorFactory in interface WorkerBuildContext

getOptimizerStrategy

public OptimizerStrategy getOptimizerStrategy(DirectoryProvider<?> provider)
Specified by:
getOptimizerStrategy in interface SearchFactoryImplementor
Specified by:
getOptimizerStrategy in interface WorkerBuildContext

getIndexingParameters

public LuceneIndexingParameters getIndexingParameters(DirectoryProvider<?> provider)
Specified by:
getIndexingParameters in interface SearchFactoryImplementor
Specified by:
getIndexingParameters in interface WorkerBuildContext

getReaderProvider

public ReaderProvider getReaderProvider()
Specified by:
getReaderProvider in interface SearchFactory
Specified by:
getReaderProvider in interface SearchFactoryState
Returns:
Return the configured reader provider.

getDirectoryProviders

public DirectoryProvider[] getDirectoryProviders(Class<?> entity)
Description copied from interface: SearchFactory
Provide access to the DirectoryProviders for a given entity. In most cases, the returned type will be a one element array. But if the given entity is configured to use sharded indexes, then multiple elements will be returned. In this case all of them should be considered.

Specified by:
getDirectoryProviders in interface SearchFactory
Parameters:
entity - the entity for which to return the directory providers
Returns:
array of DirectoryProviders for the specified entity

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 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 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,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

getDirectoryProviderLock

public ReentrantLock getDirectoryProviderLock(DirectoryProvider<?> dp)
Description copied from interface: BuildContext
This method cannot be used in initialize methods. start methods can use it though.

Specified by:
getDirectoryProviderLock in interface SearchFactoryImplementor
Specified by:
getDirectoryProviderLock in interface BuildContext
Returns:

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,
                                     Integer forceToNumWriterThreads)
Specified by:
makeBatchBackend in interface SearchFactoryImplementor

getSimilarity

public Similarity getSimilarity(DirectoryProvider<?> provider)
Specified by:
getSimilarity in interface SearchFactoryImplementor
Specified by:
getSimilarity in interface WorkerBuildContext

getDirectoryProviderData

public DirectoryProviderData getDirectoryProviderData(DirectoryProvider<?> provider)
Specified by:
getDirectoryProviderData in interface WorkerBuildContext

getErrorHandler

public ErrorHandler getErrorHandler()
Specified by:
getErrorHandler in interface SearchFactoryImplementor
Specified by:
getErrorHandler in interface SearchFactoryState
Specified by:
getErrorHandler in interface WorkerBuildContext

getIndexHierarchy

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

getDirectoryProviderIndexingParams

public Map<DirectoryProvider,LuceneIndexingParameters> getDirectoryProviderIndexingParams()
Specified by:
getDirectoryProviderIndexingParams 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


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