Class LuceneIndexFactoryBean
java.lang.Object
org.springframework.data.gemfire.support.AbstractFactoryBeanSupport<LuceneIndex>
org.springframework.data.gemfire.search.lucene.LuceneIndexFactoryBean
- All Implemented Interfaces:
Aware,BeanClassLoaderAware,BeanFactoryAware,BeanNameAware,DisposableBean,FactoryBean<LuceneIndex>,InitializingBean
public class LuceneIndexFactoryBean
extends AbstractFactoryBeanSupport<LuceneIndex>
implements DisposableBean, InitializingBean
Spring
FactoryBean used to construct, configure and initialize Lucene Indexes
on application domain object fields.- Since:
- 1.1.0
- Author:
- John Blum
- See Also:
-
Field Summary
FieldsFields inherited from class org.springframework.data.gemfire.support.AbstractFactoryBeanSupport
DEFAULT_SINGLETONFields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidapplyIndexConfigurers(String indexName, Iterable<IndexConfigurer> indexConfigurers) protected voidapplyIndexConfigurers(String indexName, IndexConfigurer... indexConfigurers) Applies the given array ofIndexConfigurersto thisLuceneIndexFactoryBean.protected LuceneIndexcreateLuceneIndex(String indexName, String regionPath) Creates aLuceneIndexwith the givenindexNameon theGemFireCacheRegionidentified by the givenregionPath.voiddestroy()protected GemFireCachegetCache()Returns a reference to theGemFireCache.protected IndexConfigurerReturns a reference to the CompositeIndexConfigurerused to apply additional configuration to thisLuceneIndexFactoryBeanon Spring container initialization.Returns aMapof application domain object field names toAnalyzersused in the construction of theLucene Indexesfor each field.Returns aListof application domain object fields to be indexed.protected StringReturns the name of theLuceneIndexas identified in theGemFireCache.protected LuceneSerializer<?>Returns a reference to theLuceneSerializerused to convertobjectsto Lucene documents for theLuceneIndexcreated by thisLuceneIndexFactoryBean.protected LuceneServiceClass<?>protected Region<?,?> protected StringReturns the fully-qualified pathname to theGemFireCacheRegionon which theLuceneIndexwill be created.protected booleanDetermines whether theLuceneIndexwill be destroyed on shutdown.protected booleanisLuceneIndexDestroyable(LuceneIndex luceneIndex) Determine whether the givenLuceneIndexcreated by thisFactoryBeanis destroyable.protected LuceneIndexpostProcess(LuceneIndex luceneIndex) Performs additional post processing to the newly createdLuceneIndex.protected LuceneIndexFactorypostProcess(LuceneIndexFactory luceneIndexFactory) Performs additional post processing to the newly createdLuceneIndexFactory.protected GemFireCacheResolves a reference to theGemFireCache.resolveFields(List<String> fields) Resolves theListof fields on the object to index.protected LuceneIndexresolveLuceneIndex(String indexName, String regionPath) Attempts to resolve aLuceneIndexby the givenindexNamefirst then attempts to create theLuceneIndexwith the givenRegion path.protected LuceneIndexFactoryResolves the appropriateLuceneIndexFactoryfrom theLuceneService.protected LuceneServiceprotected LuceneServiceresolveLuceneService(GemFireCache gemfireCache) protected Region<?,?> protected StringResolves the fully-qualified pathname of theGemFireCacheRegionon which theLuceneIndexwill be created.voidsetBeanName(String name) Sets thebean nameassigned to thisFactoryBeanas declared in the Spring container.voidsetCache(GemFireCache gemfireCache) Sets a reference to theGemFireCache.voidsetDestroy(boolean destroy) Sets whether to destroy theLuceneIndexon shutdown.voidsetFieldAnalyzers(Map<String, org.apache.lucene.analysis.Analyzer> fieldAnalyzers) Set aMapof application domain object field names toAnalyzersused in the construction of theLucene Indexesfor each field.voidSets the application domain object fields to index.voidSets the application domain object fields to index.voidsetIndexConfigurers(List<IndexConfigurer> indexConfigurers) Null-safe operation to set anIterableofIndexConfigurersused to apply additional configuration to thisLuceneIndexFactoryBeanwhen using Annotation-based configuration.voidsetIndexConfigurers(IndexConfigurer... indexConfigurers) Null-safe operation to set an array ofIndexConfigurersused to apply additional configuration to thisLuceneIndexFactoryBeanwhen using Annotation-based configuration.voidsetIndexName(String indexName) Sets the name of theLuceneIndexas identified in theGemFireCache.setLuceneIndex(LuceneIndex luceneIndex) Sets the givenLuceneIndexas the index created by thisFactoryBean.voidsetLuceneSerializer(LuceneSerializer<?> luceneSerializer) Configures a reference to theLuceneSerializerused to convertobjectsto Lucene documents for theLuceneIndexcreated by thisLuceneIndexFactoryBean.voidsetLuceneService(LuceneService luceneService) voidvoidsetRegionPath(String pathname) Sets the fully-qualified pathname to theGemFireCacheRegionon which theLuceneIndexwill be created.Methods inherited from class org.springframework.data.gemfire.support.AbstractFactoryBeanSupport
getBeanClassLoader, getBeanFactory, getBeanName, getLogger, getOptionalLogger, isDebugLoggingEnabled, isErrorLoggingEnabled, isInfoLoggingEnabled, isSingleton, isWarnLoggingEnabled, logDebug, logDebug, logError, logError, logInfo, logInfo, logWarning, logWarning, newLogger, setBeanClassLoader, setBeanFactory
-
Field Details
-
DEFAULT_DESTROY
protected static final boolean DEFAULT_DESTROY- See Also:
-
-
Constructor Details
-
LuceneIndexFactoryBean
public LuceneIndexFactoryBean()
-
-
Method Details
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceInitializingBean- Throws:
Exception
-
applyIndexConfigurers
Applies the given array ofIndexConfigurersto thisLuceneIndexFactoryBean.- Parameters:
indexName-Stringcontaining the name of theLuceneIndex.indexConfigurers- array ofIndexConfigurersapplied to thisLuceneIndexFactoryBean.- See Also:
-
applyIndexConfigurers
- Parameters:
indexName-Stringcontaining the name of theLuceneIndex.indexConfigurers-IterableofIndexConfigurersapplied to thisLuceneIndexFactoryBean.- See Also:
-
createLuceneIndex
Creates aLuceneIndexwith the givenindexNameon theGemFireCacheRegionidentified by the givenregionPath.- Parameters:
indexName-Stringcontaining the name for theLuceneIndex.regionPath-Stringcontaining the fully-qualified pathname to theGemFireCacheRegion.- Returns:
- a new instance of
LuceneIndexwith the givenindexNameon the namedRegion. - See Also:
-
postProcess
Performs additional post processing to the newly createdLuceneIndexFactory.- Parameters:
luceneIndexFactory-LuceneIndexFactoryto post process.- Returns:
- the given
LuceneIndexFactory. - See Also:
-
postProcess
Performs additional post processing to the newly createdLuceneIndex.- Parameters:
luceneIndex-LuceneIndexcreated by thisLuceneIndexFactoryBean.- Returns:
- the given
LuceneIndex. - See Also:
-
resolveLuceneIndex
Attempts to resolve aLuceneIndexby the givenindexNamefirst then attempts to create theLuceneIndexwith the givenRegion path.- Parameters:
indexName-nameof theLuceneIndexto resolve.regionPath-Region pathon which theLuceneIndexis applied.- Returns:
- the resolved
LuceneIndexby the givenindexNameor the createdLuceneIndexwith the givenRegion pathif theLuceneIndexcould not be resolved byindexName. - See Also:
-
destroy
- Specified by:
destroyin interfaceDisposableBean- Throws:
Exception
-
isLuceneIndexDestroyable
Determine whether the givenLuceneIndexcreated by thisFactoryBeanis destroyable.- Parameters:
luceneIndex-LuceneIndexsubject to destruction.- Returns:
- a boolean value indicating whether the given
LuceneIndexcreated by thisFactoryBeanis destroyable. - See Also:
-
getObject
- Specified by:
getObjectin interfaceFactoryBean<LuceneIndex>- Throws:
Exception
-
getObjectType
- Specified by:
getObjectTypein interfaceFactoryBean<LuceneIndex>
-
resolveCache
Resolves a reference to theGemFireCache.- Returns:
- a reference to the single instance of the
GemFireCache. - See Also:
-
resolveFields
Resolves theListof fields on the object to index. -
resolveLuceneIndexFactory
Resolves the appropriateLuceneIndexFactoryfrom theLuceneService.- Returns:
- a newly created instance of the
LuceneIndexFactoryfrom the resolvedLuceneService. - See Also:
-
resolveLuceneService
- Returns:
- a reference to the
GemFireCache,LuceneService. - See Also:
-
resolveLuceneService
- Parameters:
gemfireCache-GemFireCacheused to resolve theLuceneService.- Returns:
- a reference to the
GemFireCacheLuceneService. - Throws:
IllegalArgumentException- ifGemFireCacheis null.- See Also:
-
resolveRegion
- Returns:
- a reference to the
GemFireCacheRegionon which heLuceneIndexwill be created. Returns null if theRegioncannot be resolved. - See Also:
-
resolveRegionPath
Resolves the fully-qualified pathname of theGemFireCacheRegionon which theLuceneIndexwill be created.- Returns:
- a
Stringcontaining the fully-qualified pathname of theGemFireCacheRegionon which theLuceneIndexwill be created. - Throws:
IllegalStateException- if theRegionpathname could not resolved.- See Also:
-
setBeanName
Description copied from class:AbstractFactoryBeanSupportSets thebean nameassigned to thisFactoryBeanas declared in the Spring container.- Specified by:
setBeanNamein interfaceBeanNameAware- Overrides:
setBeanNamein classAbstractFactoryBeanSupport<LuceneIndex>- Parameters:
name-bean nameassigned to thisFactoryBeanas declared in the Spring container.- See Also:
-
setCache
Sets a reference to theGemFireCache.- Parameters:
gemfireCache-GemFireCachereference.- See Also:
-
getCache
Returns a reference to theGemFireCache.- Returns:
- a reference to the
GemFireCache. - See Also:
-
getCompositeIndexConfigurer
Returns a reference to the CompositeIndexConfigurerused to apply additional configuration to thisLuceneIndexFactoryBeanon Spring container initialization.- Returns:
- the Composite
IndexConfigurer. - See Also:
-
setDestroy
public void setDestroy(boolean destroy) Sets whether to destroy theLuceneIndexon shutdown.- Parameters:
destroy- boolean value indicating whether to destroy theLuceneIndexon shutdown.
-
isDestroy
protected boolean isDestroy()Determines whether theLuceneIndexwill be destroyed on shutdown.- Returns:
- a boolean value indicating whether the
LuceneIndexwill be destroyed on shutdown. - See Also:
-
setFieldAnalyzers
Set aMapof application domain object field names toAnalyzersused in the construction of theLucene Indexesfor each field. -
getFieldAnalyzers
Returns aMapof application domain object field names toAnalyzersused in the construction of theLucene Indexesfor each field.- Returns:
- a
Mapof fields names toAnalyzers. - See Also:
-
AnalyzerMapgetFields()
-
setFields
Sets the application domain object fields to index.- Parameters:
fields- array ofStringscontaining the names of the object fields ot index.- See Also:
-
setFields
Sets the application domain object fields to index. -
getFields
Returns aListof application domain object fields to be indexed.- Returns:
- a
Listof application domain object fields to be indexed. - See Also:
-
setIndexConfigurers
Null-safe operation to set an array ofIndexConfigurersused to apply additional configuration to thisLuceneIndexFactoryBeanwhen using Annotation-based configuration.- Parameters:
indexConfigurers- array ofIndexConfigurersused to apply additional configuration to thisLuceneIndexFactoryBean.- See Also:
-
setIndexConfigurers
Null-safe operation to set anIterableofIndexConfigurersused to apply additional configuration to thisLuceneIndexFactoryBeanwhen using Annotation-based configuration.- Parameters:
indexConfigurers-IterableofIndexConfigurersused to apply additional configuration to thisLuceneIndexFactoryBean.- See Also:
-
setIndexName
Sets the name of theLuceneIndexas identified in theGemFireCache.- Parameters:
indexName-Stringcontaining the name of theLuceneIndex.- See Also:
-
getIndexName
Returns the name of theLuceneIndexas identified in theGemFireCache.- Returns:
- a
Stringcontaining the name of theLuceneIndex. - Throws:
IllegalStateException- if theindexNamewas not specified.
-
getLuceneIndex
- Returns:
- an
Optionalreference to theLuceneIndexcreated by thisLuceneIndexFactoryBean. - See Also:
-
setLuceneIndex
Sets the givenLuceneIndexas the index created by thisFactoryBean. This method is generally used for testing purposes only.- Parameters:
luceneIndex-LuceneIndexcreated by thisFactoryBean.- Returns:
- this
LuceneIndexFactoryBean. - See Also:
-
setLuceneSerializer
Configures a reference to theLuceneSerializerused to convertobjectsto Lucene documents for theLuceneIndexcreated by thisLuceneIndexFactoryBean.- Parameters:
luceneSerializer-LuceneSerializerused to convertobjectsto Lucene documents for theLuceneIndex.- See Also:
-
getLuceneSerializer
Returns a reference to theLuceneSerializerused to convertobjectsto Lucene documents for theLuceneIndexcreated by thisLuceneIndexFactoryBean.- Returns:
- a
LuceneSerializerused to convertobjectsto Lucene documents for theLuceneIndex. - See Also:
-
setLuceneService
- Parameters:
luceneService-LuceneServiceused to create theLuceneIndex.- See Also:
-
getLuceneService
- Returns:
- a reference to the
LuceneServiceused to create theLuceneIndex. - See Also:
-
setRegion
- Parameters:
region-Regionon which theLuceneIndexwill be created.- See Also:
-
getRegion
- Returns:
- a reference to the
Regionon which theLuceneIndexwill be created. - See Also:
-
setRegionPath
Sets the fully-qualified pathname to theGemFireCacheRegionon which theLuceneIndexwill be created.- Parameters:
pathname-Stringcontaining the fully-qualified pathname to theGemFireCacheRegionon which theLuceneIndexwill be created.- See Also:
-
getRegionPath
Returns the fully-qualified pathname to theGemFireCacheRegionon which theLuceneIndexwill be created.- Returns:
- a
Stringcontaining the fully-qualified pathname to theGemFireCacheRegionon which theLuceneIndexwill be created. - See Also:
-