See In Search 5, the @Factory annotation allowed to use a factory type instead of the actual implementation type as a reference when injecting a component (bridge, full-text filter, ...). We don't have that in Search 6, and we won't be able to implement it following some changes in HSEARCH-3386.
The factory annotation worked for the following components:
# Bridges: {{org.hibernate.search. v6poc. engine. service.beanresolver. spi.ReflectionBeanResolver #resolve }} # Full-text filters: {{org.hibernate.search.engine.impl.ConfigContext#interpretFullTextFilterDef}} # Programmatic mappings: {{org.hibernate.search.engine.spi.SearchMappingHelper#extractSearchMapping}} # Analysis definition providers: {{org.hibernate.search.util.impl.ReflectionHelper#createInstance}}
For all these components, users of a dependency injection framework integrated into ORM (Spring, CDI) can replace the {{@Factory}} annotation advantageously by defining a custom bean factory in their framework; Search 6 now supports DI framework integration for *all* injected components.
For users that don't rely on a DI framework:
* For item 1, they can use bridge builders instead of direct reference to bridges. * For items 2 and 3, factories are no longer necessary in Search 6, since the equivalent objects passed to Hibernate Search (configurers) are already factories of sorts: they contribute information to a context passed to the configurer. Thus, users who want to implement a stateful singleton can do so by passing a configurer instance in the Hibernate ORM properties, or registering a "caching" bean factory using the {{org.hibernate.search.engine.environment.bean.spi.BeanConfigurer}} introduced in HSEARCH-3101. * As to item 4, full-text filters are not implemented yet, but I expect we will implement it either with builders (like item 1) or configurers (like item 2 and 3), which means the {{@Factory}} annotation won't be necessary either.
In every case, the new solution is more powerful than the old one, since users will get passed a context object in their "factory method", giving them access to more information and handles to create other beans. |
|