Allow to define custom prefix for settings when components do not use the org.elasticsearch package

This commit is contained in:
kimchy 2010-04-07 18:30:39 +03:00
parent bd5260a4f8
commit 9464c390ac
4 changed files with 47 additions and 1 deletions

View File

@ -48,6 +48,14 @@ public abstract class AbstractIndexComponent implements IndexComponent {
this.logger = Loggers.getLogger(getClass(), indexSettings, index);
}
protected AbstractIndexComponent(Index index, @IndexSettings Settings indexSettings, String prefixSettings) {
this.index = index;
this.indexSettings = indexSettings;
this.componentSettings = indexSettings.getComponentSettings(prefixSettings, getClass());
this.logger = Loggers.getLogger(getClass(), indexSettings, index);
}
@Override public Index index() {
return this.index;
}

View File

@ -28,7 +28,7 @@ import org.slf4j.Logger;
import static org.elasticsearch.index.shard.IndexShardManagement.*;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
public abstract class AbstractIndexShardComponent implements IndexShardComponent {
@ -48,6 +48,14 @@ public abstract class AbstractIndexShardComponent implements IndexShardComponent
this.logger = Loggers.getLogger(getClass(), indexSettings, shardId);
}
protected AbstractIndexShardComponent(ShardId shardId, @IndexSettings Settings indexSettings, String prefixSettings) {
this.shardId = shardId;
this.indexSettings = indexSettings;
this.componentSettings = indexSettings.getComponentSettings(prefixSettings, getClass());
this.logger = Loggers.getLogger(getClass(), indexSettings, shardId);
}
@Override public ShardId shardId() {
return this.shardId;
}

View File

@ -40,18 +40,36 @@ public class AbstractComponent {
this.componentSettings = settings.getComponentSettings(getClass());
}
public AbstractComponent(Settings settings, String prefixSettings) {
this.logger = Loggers.getLogger(getClass(), settings);
this.settings = settings;
this.componentSettings = settings.getComponentSettings(prefixSettings, getClass());
}
public AbstractComponent(Settings settings, Class customClass) {
this.logger = Loggers.getLogger(customClass, settings);
this.settings = settings;
this.componentSettings = settings.getComponentSettings(customClass);
}
public AbstractComponent(Settings settings, String prefixSettings, Class customClass) {
this.logger = Loggers.getLogger(customClass, settings);
this.settings = settings;
this.componentSettings = settings.getComponentSettings(prefixSettings, customClass);
}
public AbstractComponent(Settings settings, Class loggerClass, Class componentClass) {
this.logger = Loggers.getLogger(loggerClass, settings);
this.settings = settings;
this.componentSettings = settings.getComponentSettings(componentClass);
}
public AbstractComponent(Settings settings, String prefixSettings, Class loggerClass, Class componentClass) {
this.logger = Loggers.getLogger(loggerClass, settings);
this.settings = settings;
this.componentSettings = settings.getComponentSettings(prefixSettings, componentClass);
}
public String nodeName() {
return settings.get("name", "");
}

View File

@ -46,6 +46,18 @@ public abstract class AbstractLifecycleComponent<T> extends AbstractComponent im
super(settings, loggerClass, componentClass);
}
protected AbstractLifecycleComponent(Settings settings, String prefixSettings) {
super(settings, prefixSettings);
}
protected AbstractLifecycleComponent(Settings settings, String prefixSettings, Class customClass) {
super(settings, prefixSettings, customClass);
}
protected AbstractLifecycleComponent(Settings settings, String prefixSettings, Class loggerClass, Class componentClass) {
super(settings, prefixSettings, loggerClass, componentClass);
}
@Override public Lifecycle.State lifecycleState() {
return this.lifecycle.state();
}