Interface FacetSearchContextFactory<T extends FacetSearchContext>
- All Known Implementing Classes:
DefaultFacetSearchContextFactory
public interface FacetSearchContextFactory<T extends FacetSearchContext>
Implementations of this interface are responsible for creating and destroying instances of
FacetSearchContext
.
Code creating/destroying contexts should normally use the following pattern:
try
{
final FacetSearchContext facetSearchContext = facetSearchContextFactory.createContext(facetSearchConfig, indexedType, searchQuery);
// call additional setters on the context object
facetSearchContextFactory.initializeContext();
// put your logic here
facetSearchContextFactory.destroyContext();
}
catch (final FacetSearchException | ... | RuntimeException e)
{
facetSearchContextFactory.destroyContext(e);
throw e;
}
-
Method Summary
Modifier and TypeMethodDescriptioncreateContext(FacetSearchConfig facetSearchConfig, IndexedType indexedType, SearchQuery searchQuery) Creates a new facet search context and sets it as current one.voidDestroys the current context.voiddestroyContext(Exception exception) Destroys the current context because an exception occurred.Returns the current context.voidInitializes the current context and executes before search query listeners (seeFacetSearchListener.beforeSearch(FacetSearchContext)).
-
Method Details
-
createContext
T createContext(FacetSearchConfig facetSearchConfig, IndexedType indexedType, SearchQuery searchQuery) Creates a new facet search context and sets it as current one.- Parameters:
facetSearchConfig- - the facet search configurationindexedType- - the indexed typesearchQuery- - the search- Returns:
- the new context
-
initializeContext
Initializes the current context and executes before search query listeners (seeFacetSearchListener.beforeSearch(FacetSearchContext)).- Throws:
FacetSearchException- if an error occurs during the listeners execution
-
getContext
T getContext()Returns the current context.- Returns:
- the current context
-
destroyContext
Destroys the current context. Before destroying an active context it executes the after search query listeners (seeFacetSearchListener.afterSearch(FacetSearchContext)).- Throws:
FacetSearchException- if an error occurs during the listeners execution
-
destroyContext
Destroys the current context because an exception occurred. Before destroying an active context it executes the after batch error listeners (seeFacetSearchListener.afterSearchError(FacetSearchContext)).
-