-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce @SearchExtension to configure Hibernate Search through anno…
…tated beans
- Loading branch information
Showing
15 changed files
with
524 additions
and
103 deletions.
There are no files selected for viewing
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
12 changes: 12 additions & 0 deletions
12
...nt/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/deployment/ClassNames.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,12 @@ | ||
package io.quarkus.hibernate.search.orm.elasticsearch.deployment; | ||
|
||
import org.jboss.jandex.DotName; | ||
|
||
class ClassNames { | ||
|
||
static final DotName SEARCH_EXTENSION = DotName | ||
.createSimple("io.quarkus.hibernate.search.orm.elasticsearch.SearchExtension"); | ||
static final DotName INDEXED = DotName | ||
.createSimple("org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed"); | ||
|
||
} |
10 changes: 0 additions & 10 deletions
10
...java/io/quarkus/hibernate/search/orm/elasticsearch/deployment/HibernateSearchClasses.java
This file was deleted.
Oops, something went wrong.
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
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
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
83 changes: 83 additions & 0 deletions
83
.../runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/SearchExtension.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,83 @@ | ||
package io.quarkus.hibernate.search.orm.elasticsearch; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Repeatable; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import javax.enterprise.util.AnnotationLiteral; | ||
import javax.inject.Qualifier; | ||
|
||
import io.quarkus.hibernate.orm.PersistenceUnit; | ||
|
||
/** | ||
* CDI qualifier for beans representing an "extension" of Hibernate Search in a given persistence unit, | ||
* i.e. beans injected into Hibernate Search as part of its configuration. | ||
* <p> | ||
* See the reference documentation for information about extensions that supports this annotation. | ||
*/ | ||
@Target({ TYPE, FIELD, METHOD, PARAMETER }) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@Qualifier | ||
@Repeatable(SearchExtension.List.class) | ||
public @interface SearchExtension { | ||
|
||
/** | ||
* @return The name of the persistence unit that the qualified bean should be assigned to. | ||
*/ | ||
String persistenceUnit() default PersistenceUnit.DEFAULT; | ||
|
||
/** | ||
* @return The name of the Hibernate Search backend that the qualified bean should be assigned to. | ||
*/ | ||
String backend() default ""; | ||
|
||
/** | ||
* @return The name of the Hibernate Search index that the qualified bean should be assigned to. | ||
*/ | ||
String index() default ""; | ||
|
||
class Literal | ||
extends AnnotationLiteral<SearchExtension> | ||
implements SearchExtension { | ||
|
||
private final String persistenceUnit; | ||
private final String backend; | ||
private final String index; | ||
|
||
public Literal(String persistenceUnit, String backend, String index) { | ||
this.persistenceUnit = persistenceUnit; | ||
this.backend = backend; | ||
this.index = index; | ||
} | ||
|
||
@Override | ||
public String persistenceUnit() { | ||
return persistenceUnit; | ||
} | ||
|
||
@Override | ||
public String backend() { | ||
return backend; | ||
} | ||
|
||
@Override | ||
public String index() { | ||
return index; | ||
} | ||
} | ||
|
||
@Target({ TYPE, FIELD, METHOD, PARAMETER }) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@interface List { | ||
SearchExtension[] value(); | ||
} | ||
} |
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
Oops, something went wrong.