make settings prefix simpler and not bail when not prefixed with org.elasticsearch, allow to provide settings prefix for analyzer provider
This commit is contained in:
parent
f73a5e62d3
commit
e3322836b5
|
@ -76,8 +76,12 @@ public class ImmutableSettings implements Settings {
|
|||
}
|
||||
|
||||
@Override public Settings getComponentSettings(Class component) {
|
||||
if (component.getName().startsWith("org.elasticsearch")) {
|
||||
return getComponentSettings("org.elasticsearch", component);
|
||||
}
|
||||
// not starting with org.elasticsearch, just remove the first package part (probably org/net/com)
|
||||
return getComponentSettings(component.getName().substring(0, component.getName().indexOf('.')), component);
|
||||
}
|
||||
|
||||
@Override public Settings getComponentSettings(String prefix, Class component) {
|
||||
String type = component.getName();
|
||||
|
|
|
@ -41,7 +41,8 @@ public interface Settings {
|
|||
|
||||
/**
|
||||
* Component settings for a specific component. Returns all the settings for the given class, where the
|
||||
* FQN of the class is used, without the <tt>org.elasticsearch<tt> prefix.
|
||||
* FQN of the class is used, without the <tt>org.elasticsearch<tt> prefix. If there is no <tt>org.elasticsearch</tt>
|
||||
* prefix, then the prefix used is the first part of the package name (<tt>org</tt> / <tt>com</tt> / ...)
|
||||
*/
|
||||
Settings getComponentSettings(Class component);
|
||||
|
||||
|
|
|
@ -40,6 +40,12 @@ public abstract class AbstractIndexComponent implements IndexComponent {
|
|||
|
||||
protected final Settings componentSettings;
|
||||
|
||||
/**
|
||||
* Constructs a new index component, with the index name and its settings.
|
||||
*
|
||||
* @param index The index name
|
||||
* @param indexSettings The index settings
|
||||
*/
|
||||
protected AbstractIndexComponent(Index index, @IndexSettings Settings indexSettings) {
|
||||
this.index = index;
|
||||
this.indexSettings = indexSettings;
|
||||
|
@ -48,6 +54,13 @@ public abstract class AbstractIndexComponent implements IndexComponent {
|
|||
this.logger = Loggers.getLogger(getClass(), indexSettings, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new index component, with the index name and its settings, as well as settings prefix.
|
||||
*
|
||||
* @param index The index name
|
||||
* @param indexSettings The index settings
|
||||
* @param prefixSettings A settings prefix (like "com.mycompany") to simplify extracting the component settings
|
||||
*/
|
||||
protected AbstractIndexComponent(Index index, @IndexSettings Settings indexSettings, String prefixSettings) {
|
||||
this.index = index;
|
||||
this.indexSettings = indexSettings;
|
||||
|
|
|
@ -32,11 +32,31 @@ public abstract class AbstractIndexAnalyzerProvider<T extends Analyzer> extends
|
|||
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Constructs a new analyzer component, with the index name and its settings and the analyzer name.
|
||||
*
|
||||
* @param index The index name
|
||||
* @param indexSettings The index settings
|
||||
* @param name The analyzer name
|
||||
*/
|
||||
public AbstractIndexAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, String name) {
|
||||
super(index, indexSettings);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new analyzer component, with the index name and its settings and the analyzer name.
|
||||
*
|
||||
* @param index The index name
|
||||
* @param indexSettings The index settings
|
||||
* @param prefixSettings A settings prefix (like "com.mycompany") to simplify extracting the component settings
|
||||
* @param name The analyzer name
|
||||
*/
|
||||
public AbstractIndexAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, String prefixSettings, String name) {
|
||||
super(index, indexSettings, prefixSettings);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override public String name() {
|
||||
return this.name;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue