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_SINGLETON
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
applyIndexConfigurers
(String indexName, Iterable<IndexConfigurer> indexConfigurers) protected void
applyIndexConfigurers
(String indexName, IndexConfigurer... indexConfigurers) Applies the given array ofIndexConfigurers
to thisLuceneIndexFactoryBean
.protected LuceneIndex
createLuceneIndex
(String indexName, String regionPath) Creates aLuceneIndex
with the givenindexName
on theGemFireCache
Region
identified by the givenregionPath
.void
destroy()
protected GemFireCache
getCache()
Returns a reference to theGemFireCache
.protected IndexConfigurer
Returns a reference to the CompositeIndexConfigurer
used to apply additional configuration to thisLuceneIndexFactoryBean
on Spring container initialization.Returns aMap
of application domain object field names toAnalyzers
used in the construction of theLucene Indexes
for each field.Returns aList
of application domain object fields to be indexed.protected String
Returns the name of theLuceneIndex
as identified in theGemFireCache
.protected LuceneSerializer<?>
Returns a reference to theLuceneSerializer
used to convertobjects
to Lucene documents for theLuceneIndex
created by thisLuceneIndexFactoryBean
.protected LuceneService
Class<?>
protected Region<?,
?> protected String
Returns the fully-qualified pathname to theGemFireCache
Region
on which theLuceneIndex
will be created.protected boolean
Determines whether theLuceneIndex
will be destroyed on shutdown.protected boolean
isLuceneIndexDestroyable
(LuceneIndex luceneIndex) Determine whether the givenLuceneIndex
created by thisFactoryBean
is destroyable.protected LuceneIndex
postProcess
(LuceneIndex luceneIndex) Performs additional post processing to the newly createdLuceneIndex
.protected LuceneIndexFactory
postProcess
(LuceneIndexFactory luceneIndexFactory) Performs additional post processing to the newly createdLuceneIndexFactory
.protected GemFireCache
Resolves a reference to theGemFireCache
.resolveFields
(List<String> fields) Resolves theList
of fields on the object to index.protected LuceneIndex
resolveLuceneIndex
(String indexName, String regionPath) Attempts to resolve aLuceneIndex
by the givenindexName
first then attempts to create theLuceneIndex
with the givenRegion path
.protected LuceneIndexFactory
Resolves the appropriateLuceneIndexFactory
from theLuceneService
.protected LuceneService
protected LuceneService
resolveLuceneService
(GemFireCache gemfireCache) protected Region<?,
?> protected String
Resolves the fully-qualified pathname of theGemFireCache
Region
on which theLuceneIndex
will be created.void
setBeanName
(String name) Sets thebean name
assigned to thisFactoryBean
as declared in the Spring container.void
setCache
(GemFireCache gemfireCache) Sets a reference to theGemFireCache
.void
setDestroy
(boolean destroy) Sets whether to destroy theLuceneIndex
on shutdown.void
setFieldAnalyzers
(Map<String, org.apache.lucene.analysis.Analyzer> fieldAnalyzers) Set aMap
of application domain object field names toAnalyzers
used in the construction of theLucene Indexes
for each field.void
Sets the application domain object fields to index.void
Sets the application domain object fields to index.void
setIndexConfigurers
(List<IndexConfigurer> indexConfigurers) Null-safe operation to set anIterable
ofIndexConfigurers
used to apply additional configuration to thisLuceneIndexFactoryBean
when using Annotation-based configuration.void
setIndexConfigurers
(IndexConfigurer... indexConfigurers) Null-safe operation to set an array ofIndexConfigurers
used to apply additional configuration to thisLuceneIndexFactoryBean
when using Annotation-based configuration.void
setIndexName
(String indexName) Sets the name of theLuceneIndex
as identified in theGemFireCache
.setLuceneIndex
(LuceneIndex luceneIndex) Sets the givenLuceneIndex
as the index created by thisFactoryBean
.void
setLuceneSerializer
(LuceneSerializer<?> luceneSerializer) Configures a reference to theLuceneSerializer
used to convertobjects
to Lucene documents for theLuceneIndex
created by thisLuceneIndexFactoryBean
.void
setLuceneService
(LuceneService luceneService) void
void
setRegionPath
(String pathname) Sets the fully-qualified pathname to theGemFireCache
Region
on which theLuceneIndex
will be created.Methods inherited from class org.springframework.data.gemfire.support.AbstractFactoryBeanSupport
getBeanClassLoader, getBeanFactory, getBeanName, getLog, getOptionalLog, isDebugLoggingEnabled, isErrorLoggingEnabled, isInfoLoggingEnabled, isSingleton, isWarnLoggingEnabled, logDebug, logDebug, logError, logError, logInfo, logInfo, logWarning, logWarning, newLog, setBeanClassLoader, setBeanFactory
-
Field Details
-
DEFAULT_DESTROY
protected static final boolean DEFAULT_DESTROY- See Also:
-
-
Constructor Details
-
LuceneIndexFactoryBean
public LuceneIndexFactoryBean()
-
-
Method Details
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
Exception
-
applyIndexConfigurers
Applies the given array ofIndexConfigurers
to thisLuceneIndexFactoryBean
.- Parameters:
indexName
-String
containing the name of theLuceneIndex
.indexConfigurers
- array ofIndexConfigurers
applied to thisLuceneIndexFactoryBean
.- See Also:
-
applyIndexConfigurers
- Parameters:
indexName
-String
containing the name of theLuceneIndex
.indexConfigurers
-Iterable
ofIndexConfigurers
applied to thisLuceneIndexFactoryBean
.- See Also:
-
createLuceneIndex
Creates aLuceneIndex
with the givenindexName
on theGemFireCache
Region
identified by the givenregionPath
.- Parameters:
indexName
-String
containing the name for theLuceneIndex
.regionPath
-String
containing the fully-qualified pathname to theGemFireCache
Region
.- Returns:
- a new instance of
LuceneIndex
with the givenindexName
on the namedRegion
. - See Also:
-
postProcess
Performs additional post processing to the newly createdLuceneIndexFactory
.- Parameters:
luceneIndexFactory
-LuceneIndexFactory
to post process.- Returns:
- the given
LuceneIndexFactory
. - See Also:
-
postProcess
Performs additional post processing to the newly createdLuceneIndex
.- Parameters:
luceneIndex
-LuceneIndex
created by thisLuceneIndexFactoryBean
.- Returns:
- the given
LuceneIndex
. - See Also:
-
resolveLuceneIndex
Attempts to resolve aLuceneIndex
by the givenindexName
first then attempts to create theLuceneIndex
with the givenRegion path
.- Parameters:
indexName
-name
of theLuceneIndex
to resolve.regionPath
-Region path
on which theLuceneIndex
is applied.- Returns:
- the resolved
LuceneIndex
by the givenindexName
or the createdLuceneIndex
with the givenRegion path
if theLuceneIndex
could not be resolved byindexName
. - See Also:
-
destroy
- Specified by:
destroy
in interfaceDisposableBean
- Throws:
Exception
-
isLuceneIndexDestroyable
Determine whether the givenLuceneIndex
created by thisFactoryBean
is destroyable.- Parameters:
luceneIndex
-LuceneIndex
subject to destruction.- Returns:
- a boolean value indicating whether the given
LuceneIndex
created by thisFactoryBean
is destroyable. - See Also:
-
getObject
- Specified by:
getObject
in interfaceFactoryBean<LuceneIndex>
- Throws:
Exception
-
getObjectType
- Specified by:
getObjectType
in interfaceFactoryBean<LuceneIndex>
-
resolveCache
Resolves a reference to theGemFireCache
.- Returns:
- a reference to the single instance of the
GemFireCache
. - See Also:
-
resolveFields
Resolves theList
of fields on the object to index. -
resolveLuceneIndexFactory
Resolves the appropriateLuceneIndexFactory
from theLuceneService
.- Returns:
- a newly created instance of the
LuceneIndexFactory
from the resolvedLuceneService
. - See Also:
-
resolveLuceneService
- Returns:
- a reference to the
GemFireCache
,LuceneService
. - See Also:
-
resolveLuceneService
- Parameters:
gemfireCache
-GemFireCache
used to resolve theLuceneService
.- Returns:
- a reference to the
GemFireCache
LuceneService
. - Throws:
IllegalArgumentException
- ifGemFireCache
is null.- See Also:
-
resolveRegion
- Returns:
- a reference to the
GemFireCache
Region
on which heLuceneIndex
will be created. Returns null if theRegion
cannot be resolved. - See Also:
-
resolveRegionPath
Resolves the fully-qualified pathname of theGemFireCache
Region
on which theLuceneIndex
will be created.- Returns:
- a
String
containing the fully-qualified pathname of theGemFireCache
Region
on which theLuceneIndex
will be created. - Throws:
IllegalStateException
- if theRegion
pathname could not resolved.- See Also:
-
setBeanName
Description copied from class:AbstractFactoryBeanSupport
Sets thebean name
assigned to thisFactoryBean
as declared in the Spring container.- Specified by:
setBeanName
in interfaceBeanNameAware
- Overrides:
setBeanName
in classAbstractFactoryBeanSupport<LuceneIndex>
- Parameters:
name
-bean name
assigned to thisFactoryBean
as declared in the Spring container.- See Also:
-
setCache
Sets a reference to theGemFireCache
.- Parameters:
gemfireCache
-GemFireCache
reference.- See Also:
-
getCache
Returns a reference to theGemFireCache
.- Returns:
- a reference to the
GemFireCache
. - See Also:
-
getCompositeIndexConfigurer
Returns a reference to the CompositeIndexConfigurer
used to apply additional configuration to thisLuceneIndexFactoryBean
on Spring container initialization.- Returns:
- the Composite
IndexConfigurer
. - See Also:
-
setDestroy
public void setDestroy(boolean destroy) Sets whether to destroy theLuceneIndex
on shutdown.- Parameters:
destroy
- boolean value indicating whether to destroy theLuceneIndex
on shutdown.
-
isDestroy
protected boolean isDestroy()Determines whether theLuceneIndex
will be destroyed on shutdown.- Returns:
- a boolean value indicating whether the
LuceneIndex
will be destroyed on shutdown. - See Also:
-
setFieldAnalyzers
Set aMap
of application domain object field names toAnalyzers
used in the construction of theLucene Indexes
for each field. -
getFieldAnalyzers
Returns aMap
of application domain object field names toAnalyzers
used in the construction of theLucene Indexes
for each field.- Returns:
- a
Map
of fields names toAnalyzers
. - See Also:
-
Analyzer
Map
getFields()
-
setFields
Sets the application domain object fields to index.- Parameters:
fields
- array ofStrings
containing the names of the object fields ot index.- See Also:
-
setFields
Sets the application domain object fields to index. -
getFields
Returns aList
of application domain object fields to be indexed.- Returns:
- a
List
of application domain object fields to be indexed. - See Also:
-
setIndexConfigurers
Null-safe operation to set an array ofIndexConfigurers
used to apply additional configuration to thisLuceneIndexFactoryBean
when using Annotation-based configuration.- Parameters:
indexConfigurers
- array ofIndexConfigurers
used to apply additional configuration to thisLuceneIndexFactoryBean
.- See Also:
-
setIndexConfigurers
Null-safe operation to set anIterable
ofIndexConfigurers
used to apply additional configuration to thisLuceneIndexFactoryBean
when using Annotation-based configuration.- Parameters:
indexConfigurers
-Iterable
ofIndexConfigurers
used to apply additional configuration to thisLuceneIndexFactoryBean
.- See Also:
-
setIndexName
Sets the name of theLuceneIndex
as identified in theGemFireCache
.- Parameters:
indexName
-String
containing the name of theLuceneIndex
.- See Also:
-
getIndexName
Returns the name of theLuceneIndex
as identified in theGemFireCache
.- Returns:
- a
String
containing the name of theLuceneIndex
. - Throws:
IllegalStateException
- if theindexName
was not specified.
-
getLuceneIndex
- Returns:
- an
Optional
reference to theLuceneIndex
created by thisLuceneIndexFactoryBean
. - See Also:
-
setLuceneIndex
Sets the givenLuceneIndex
as the index created by thisFactoryBean
. This method is generally used for testing purposes only.- Parameters:
luceneIndex
-LuceneIndex
created by thisFactoryBean
.- Returns:
- this
LuceneIndexFactoryBean
. - See Also:
-
setLuceneSerializer
Configures a reference to theLuceneSerializer
used to convertobjects
to Lucene documents for theLuceneIndex
created by thisLuceneIndexFactoryBean
.- Parameters:
luceneSerializer
-LuceneSerializer
used to convertobjects
to Lucene documents for theLuceneIndex
.- See Also:
-
getLuceneSerializer
Returns a reference to theLuceneSerializer
used to convertobjects
to Lucene documents for theLuceneIndex
created by thisLuceneIndexFactoryBean
.- Returns:
- a
LuceneSerializer
used to convertobjects
to Lucene documents for theLuceneIndex
. - See Also:
-
setLuceneService
- Parameters:
luceneService
-LuceneService
used to create theLuceneIndex
.- See Also:
-
getLuceneService
- Returns:
- a reference to the
LuceneService
used to create theLuceneIndex
. - See Also:
-
setRegion
- Parameters:
region
-Region
on which theLuceneIndex
will be created.- See Also:
-
getRegion
- Returns:
- a reference to the
Region
on which theLuceneIndex
will be created. - See Also:
-
setRegionPath
Sets the fully-qualified pathname to theGemFireCache
Region
on which theLuceneIndex
will be created.- Parameters:
pathname
-String
containing the fully-qualified pathname to theGemFireCache
Region
on which theLuceneIndex
will be created.- See Also:
-
getRegionPath
Returns the fully-qualified pathname to theGemFireCache
Region
on which theLuceneIndex
will be created.- Returns:
- a
String
containing the fully-qualified pathname to theGemFireCache
Region
on which theLuceneIndex
will be created. - See Also:
-