Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-3170 Allow to set additional bean configurers from configurat…
…ion properties This will help when testing, in particular
- Loading branch information
Showing
4 changed files
with
116 additions
and
8 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
engine/src/main/java/org/hibernate/search/engine/cfg/SearchEngineSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.engine.cfg; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.hibernate.search.engine.environment.bean.BeanReference; | ||
import org.hibernate.search.engine.environment.bean.spi.BeanConfigurer; | ||
import org.hibernate.search.engine.environment.bean.spi.BeanResolver; | ||
|
||
/** | ||
* Configuration properties for the Hibernate Search engine. | ||
*/ | ||
public final class SearchEngineSettings { | ||
|
||
private SearchEngineSettings() { | ||
} | ||
|
||
/** | ||
* The {@link BeanConfigurer} instances | ||
* used to pre-define beans. | ||
* <p> | ||
* Accepts either: | ||
* <ul> | ||
* <li>A list, containing {@link BeanConfigurer} instances, | ||
* or {@link BeanConfigurer} implementation classes to be resolved against the {@link BeanResolver}, | ||
* or Strings to be considered as bean name and resolved against the {@link BeanResolver} | ||
* (fully-qualified class names will be instantiated using reflection). | ||
* </li> | ||
* <li>A String containing whitespace-separated bean names to be resolved against the {@link BeanResolver} | ||
* (fully-qualified class names will be instantiated using reflection).</li> | ||
* </ul> | ||
*/ | ||
public static final String BEAN_CONFIGURERS = "bean_configurers"; | ||
|
||
/** | ||
* Default values for the different settings if no values are given. | ||
*/ | ||
public static final class Defaults { | ||
|
||
private Defaults() { | ||
} | ||
|
||
public static final List<BeanReference<? extends BeanConfigurer>> BEAN_CONFIGURERS = Collections.emptyList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
.../java/org/hibernate/search/engine/environment/bean/impl/BeanResolverOnlyBeanProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.engine.environment.bean.impl; | ||
|
||
import org.hibernate.search.engine.environment.bean.BeanHolder; | ||
import org.hibernate.search.engine.environment.bean.BeanProvider; | ||
import org.hibernate.search.engine.environment.bean.spi.BeanResolver; | ||
import org.hibernate.search.util.impl.common.Contracts; | ||
|
||
/** | ||
* A BeanProvider that ignores the explicitly configured beans. | ||
* Used in the ConfiguredBeanProvider constructor to retrieve bean configurers. | ||
*/ | ||
final class BeanResolverOnlyBeanProvider implements BeanProvider { | ||
private final BeanResolver beanResolver; | ||
|
||
BeanResolverOnlyBeanProvider(BeanResolver beanResolver) { | ||
this.beanResolver = beanResolver; | ||
} | ||
|
||
@Override | ||
public <T> BeanHolder<T> getBean(Class<T> typeReference) { | ||
Contracts.assertNotNull( typeReference, "typeReference" ); | ||
return beanResolver.resolve( typeReference ); | ||
} | ||
|
||
@Override | ||
public <T> BeanHolder<T> getBean(Class<T> typeReference, String nameReference) { | ||
Contracts.assertNotNull( typeReference, "typeReference" ); | ||
Contracts.assertNotNullNorEmpty( nameReference, "nameReference" ); | ||
return beanResolver.resolve( typeReference, nameReference ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters